Record Class OllamaApi.GenerateRequest

java.lang.Object
java.lang.Record
org.springframework.ai.ollama.api.OllamaApi.GenerateRequest
Record Components:
model - (required) The model to use for completion.
prompt - (required) The prompt(s) to generate completions for.
format - (optional) The format to return the response in. Currently the only accepted value is "json".
options - (optional) additional model parameters listed in the documentation for the Modelfile such as temperature.
system - (optional) system prompt to (overrides what is defined in the Modelfile).
template - (optional) the full prompt or prompt template (overrides what is defined in the Modelfile).
context - the context parameter returned from a previous request to /generate, this can be used to keep a short conversational memory.
stream - (optional) if false the response will be returned as a single response object, rather than a stream of objects.
raw - (optional) if true no formatting will be applied to the prompt and no context will be returned. You may choose to use the raw parameter if you are specifying a full templated prompt in your request to the API, and are managing history yourself.
Enclosing class:
OllamaApi

public static record OllamaApi.GenerateRequest(String model, String prompt, String format, Map<String,Object> options, String system, String template, List<Integer> context, Boolean stream, Boolean raw) extends Record
The request object sent to the /generate endpoint.
  • Constructor Details

    • GenerateRequest

      public GenerateRequest(String model, String prompt, Boolean stream)
      Short cut constructor to create a CompletionRequest without options.
      Parameters:
      model - The model used for completion.
      prompt - The prompt(s) to generate completions for.
      stream - Whether to stream the response.
    • GenerateRequest

      public GenerateRequest(String model, String prompt, boolean enableJsonFormat, Boolean stream)
      Short cut constructor to create a CompletionRequest without options.
      Parameters:
      model - The model used for completion.
      prompt - The prompt(s) to generate completions for.
      enableJsonFormat - Whether to return the response in json format.
      stream - Whether to stream the response.
    • GenerateRequest

      public GenerateRequest(String model, String prompt, String format, Map<String,Object> options, String system, String template, List<Integer> context, Boolean stream, Boolean raw)
      Creates an instance of a GenerateRequest record class.
      Parameters:
      model - the value for the model record component
      prompt - the value for the prompt record component
      format - the value for the format record component
      options - the value for the options record component
      system - the value for the system record component
      template - the value for the template record component
      context - the value for the context record component
      stream - the value for the stream record component
      raw - the value for the raw record component
  • Method Details

    • builder

      public static OllamaApi.GenerateRequest.Builder builder(String prompt)
      Create a CompletionRequest builder.
      Parameters:
      prompt - The prompt(s) to generate completions for.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • model

      public String model()
      Returns the value of the model record component.
      Returns:
      the value of the model record component
    • prompt

      public String prompt()
      Returns the value of the prompt record component.
      Returns:
      the value of the prompt record component
    • format

      public String format()
      Returns the value of the format record component.
      Returns:
      the value of the format record component
    • options

      public Map<String,Object> options()
      Returns the value of the options record component.
      Returns:
      the value of the options record component
    • system

      public String system()
      Returns the value of the system record component.
      Returns:
      the value of the system record component
    • template

      public String template()
      Returns the value of the template record component.
      Returns:
      the value of the template record component
    • context

      public List<Integer> context()
      Returns the value of the context record component.
      Returns:
      the value of the context record component
    • stream

      public Boolean stream()
      Returns the value of the stream record component.
      Returns:
      the value of the stream record component
    • raw

      public Boolean raw()
      Returns the value of the raw record component.
      Returns:
      the value of the raw record component