Class GenerateOptions<T>

java.lang.Object
com.google.genkit.ai.GenerateOptions<T>
Type Parameters:
T - the output type for structured output (use Void if not using typed output)

public class GenerateOptions<T> extends Object
Options for text generation requests.
  • Constructor Details

    • GenerateOptions

      public GenerateOptions(String model, String prompt, List<Message> messages, List<Document> docs, String system, List<Tool<?,?>> tools, Object toolChoice, OutputConfig output, GenerationConfig config, Map<String,Object> context, Integer maxTurns, ResumeOptions resume, Class<T> outputClass)
      Creates new GenerateOptions.
      Parameters:
      model - the model name
      prompt - simple text prompt
      messages - conversation messages
      docs - documents for context
      system - system prompt
      tools - available tools
      toolChoice - tool selection strategy
      output - output configuration
      config - generation configuration
      context - additional context
      maxTurns - maximum conversation turns
      resume - options for resuming after an interrupt
      outputClass - the output class for structured output
  • Method Details

    • builder

      public static <T> GenerateOptions.Builder<T> builder()
      Creates a builder for GenerateOptions.
      Type Parameters:
      T - the output type
      Returns:
      a new builder
    • getModel

      public String getModel()
      Gets the model name.
      Returns:
      the model name
    • getPrompt

      public String getPrompt()
      Gets the text prompt.
      Returns:
      the prompt
    • getMessages

      public List<Message> getMessages()
      Gets the conversation messages.
      Returns:
      the messages
    • getDocs

      public List<Document> getDocs()
      Gets the documents for context.
      Returns:
      the documents
    • getSystem

      public String getSystem()
      Gets the system prompt.
      Returns:
      the system prompt
    • getTools

      public List<Tool<?,?>> getTools()
      Gets the available tools.
      Returns:
      the tools
    • getToolChoice

      public Object getToolChoice()
      Gets the tool choice strategy.
      Returns:
      the tool choice
    • getOutput

      public OutputConfig getOutput()
      Gets the output configuration.
      Returns:
      the output config
    • getConfig

      public GenerationConfig getConfig()
      Gets the generation configuration.
      Returns:
      the config
    • getContext

      public Map<String,Object> getContext()
      Gets the additional context.
      Returns:
      the context
    • getMaxTurns

      public Integer getMaxTurns()
      Gets the maximum conversation turns.
      Returns:
      the max turns
    • getResume

      public ResumeOptions getResume()
      Gets the resume options for continuing after an interrupt.
      Returns:
      the resume options, or null if not resuming
    • toModelRequest

      public ModelRequest toModelRequest()
      Converts these options to a ModelRequest.
      Returns:
      a ModelRequest
    • getOutputClass

      public Class<T> getOutputClass()
      Gets the output class for structured output.
      Returns:
      the output class, or null if not using typed output