Class GenerateActionOptions

java.lang.Object
com.google.genkit.ai.GenerateActionOptions

public class GenerateActionOptions extends Object
High-level options for the generate action, representing the generate request before model and tool resolution. This is the Java equivalent of the JS GenerateActionOptions type.

This type is used by:

  • The /util/generate action (Dev UI)
  • The wrapGenerate middleware hook

Unlike ModelRequest, which is the low-level resolved request sent to a model, this class retains high-level information such as the model name as a string and tool names as string references. This allows wrapGenerate middleware to modify these values before resolution occurs (e.g., swapping the model, adding/removing tools by name, changing output format).

See Also:
  • Constructor Details

    • GenerateActionOptions

      public GenerateActionOptions()
      Default constructor for JSON deserialization.
  • Method Details

    • withMessages

      public GenerateActionOptions withMessages(List<Message> newMessages)
      Returns a new GenerateActionOptions with the given messages, preserving all other fields. This is used in the tool loop to advance the conversation without mutating the original.
      Parameters:
      newMessages - the updated message list
      Returns:
      a new options instance
    • withModel

      public GenerateActionOptions withModel(String newModel)
      Returns a new GenerateActionOptions with the given model name, preserving all other fields.
      Parameters:
      newModel - the model name
      Returns:
      a new options instance
    • getModel

      public String getModel()
    • setModel

      public void setModel(String model)
    • getMessages

      public List<Message> getMessages()
    • setMessages

      public void setMessages(List<Message> messages)
    • getTools

      public List<String> getTools()
    • setTools

      public void setTools(List<String> tools)
    • getResources

      public List<String> getResources()
    • setResources

      public void setResources(List<String> resources)
    • getToolChoice

      public String getToolChoice()
    • setToolChoice

      public void setToolChoice(String toolChoice)
    • getConfig

      public GenerationConfig getConfig()
    • setConfig

      public void setConfig(GenerationConfig config)
    • getOutput

      public OutputConfig getOutput()
    • setOutput

      public void setOutput(OutputConfig output)
    • getDocs

      public List<Document> getDocs()
    • setDocs

      public void setDocs(List<Document> docs)
    • getReturnToolRequests

      public Boolean getReturnToolRequests()
    • setReturnToolRequests

      public void setReturnToolRequests(Boolean returnToolRequests)
    • getMaxTurns

      public Integer getMaxTurns()
    • setMaxTurns

      public void setMaxTurns(Integer maxTurns)
    • getStepName

      public String getStepName()
    • setStepName

      public void setStepName(String stepName)