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.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionGenerateRequest
(String model, String prompt, boolean enableJsonFormat, Boolean stream) Short cut constructor to create a CompletionRequest without options.GenerateRequest
(String model, String prompt, Boolean stream) Short cut constructor to create a CompletionRequest without options.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 aGenerateRequest
record class. -
Method Summary
Modifier and TypeMethodDescriptionCreate a CompletionRequest builder.context()
Returns the value of thecontext
record component.final boolean
Indicates whether some other object is "equal to" this one.format()
Returns the value of theformat
record component.final int
hashCode()
Returns a hash code value for this object.model()
Returns the value of themodel
record component.options()
Returns the value of theoptions
record component.prompt()
Returns the value of theprompt
record component.raw()
Returns the value of theraw
record component.stream()
Returns the value of thestream
record component.system()
Returns the value of thesystem
record component.template()
Returns the value of thetemplate
record component.final String
toString()
Returns a string representation of this record class.
-
Constructor Details
-
GenerateRequest
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
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 aGenerateRequest
record class.- Parameters:
model
- the value for themodel
record componentprompt
- the value for theprompt
record componentformat
- the value for theformat
record componentoptions
- the value for theoptions
record componentsystem
- the value for thesystem
record componenttemplate
- the value for thetemplate
record componentcontext
- the value for thecontext
record componentstream
- the value for thestream
record componentraw
- the value for theraw
record component
-
-
Method Details
-
builder
Create a CompletionRequest builder.- Parameters:
prompt
- The prompt(s) to generate completions for.
-
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. -
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. -
equals
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 withObjects::equals(Object,Object)
. -
model
Returns the value of themodel
record component.- Returns:
- the value of the
model
record component
-
prompt
Returns the value of theprompt
record component.- Returns:
- the value of the
prompt
record component
-
format
Returns the value of theformat
record component.- Returns:
- the value of the
format
record component
-
options
Returns the value of theoptions
record component.- Returns:
- the value of the
options
record component
-
system
Returns the value of thesystem
record component.- Returns:
- the value of the
system
record component
-
template
Returns the value of thetemplate
record component.- Returns:
- the value of the
template
record component
-
context
Returns the value of thecontext
record component.- Returns:
- the value of the
context
record component
-
stream
Returns the value of thestream
record component.- Returns:
- the value of the
stream
record component
-
raw
Returns the value of theraw
record component.- Returns:
- the value of the
raw
record component
-