Class OllamaChatOptions
java.lang.Object
org.springframework.ai.ollama.api.OllamaChatOptions
- All Implemented Interfaces:
ChatOptions,ModelOptions,StructuredOutputChatOptions,ToolCallingChatOptions
public class OllamaChatOptions
extends Object
implements ToolCallingChatOptions, StructuredOutputChatOptions
Helper class for creating strongly-typed Ollama options.
- Since:
- 0.8.0
- Author:
- Christian Tzolov, Thomas Vitale, Ilayaperumal Gopinathan, Nicolas Krier
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classstatic class -
Field Summary
Fields inherited from interface org.springframework.ai.model.tool.ToolCallingChatOptions
DEFAULT_TOOL_EXECUTION_ENABLED -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedOllamaChatOptions(@Nullable Boolean useNUMA, @Nullable Integer numCtx, @Nullable Integer numBatch, @Nullable Integer numGPU, @Nullable Integer mainGPU, @Nullable Boolean lowVRAM, @Nullable Boolean f16KV, @Nullable Boolean logitsAll, @Nullable Boolean vocabOnly, @Nullable Boolean useMMap, @Nullable Boolean useMLock, @Nullable Integer numThread, @Nullable Integer numKeep, @Nullable Integer seed, @Nullable Integer numPredict, @Nullable Integer topK, @Nullable Double topP, @Nullable Double minP, @Nullable Float tfsZ, @Nullable Float typicalP, @Nullable Integer repeatLastN, @Nullable Double temperature, @Nullable Double repeatPenalty, @Nullable Double presencePenalty, @Nullable Double frequencyPenalty, @Nullable Integer mirostat, @Nullable Float mirostatTau, @Nullable Float mirostatEta, @Nullable Boolean penalizeNewline, @Nullable List<String> stop, @Nullable String model, @Nullable Object format, @Nullable String keepAlive, @Nullable Boolean truncate, @Nullable ThinkOption thinkOption, @Nullable Boolean internalToolExecutionEnabled, List<ToolCallback> toolCallbacks, Set<String> toolNames, Map<String, Object> toolContext) -
Method Summary
Modifier and TypeMethodDescriptionstatic OllamaChatOptions.Builderbuilder()copy()Returns a copy of thisChatOptions.booleanfilterNonSupportedFields(Map<String, Object> options) Filter out the non-supported fields from the options.static OllamaChatOptionsfromOptions(OllamaChatOptions fromOptions) @Nullable BooleangetF16KV()@Nullable Object@Nullable DoubleReturns the frequency penalty to use for the chat.@Nullable BooleanWhether theChatModelis responsible for executing the tools requested by the model or if the tools should be executed directly by the caller.@Nullable String@Nullable Boolean@Nullable Boolean@Nullable Integer@Nullable IntegerReturns the maximum number of tokens to use for the chat.@Nullable DoublegetMinP()@Nullable Integer@Nullable Float@Nullable Float@Nullable StringgetModel()Returns the model to use for the chat.@Nullable Integer@Nullable Integer@Nullable Integer@Nullable Integer@Nullable Integer@Nullable Integer@Nullable Boolean@Nullable DoubleReturns the presence penalty to use for the chat.@Nullable Integer@Nullable Double@Nullable IntegergetSeed()getStop()Returns the stop sequences to use for the chat.@Nullable DoubleReturns the temperature to use for the chat.@Nullable FloatgetTfsZ()@Nullable ThinkOptionToolCallbacks to be registered with the ChatModel.Get the configured tool context.Names of the tools to register with the ChatModel.@Nullable IntegergetTopK()Returns the top K to use for the chat.@Nullable DoublegetTopP()Returns the top P to use for the chat.@Nullable Boolean@Nullable Float@Nullable Boolean@Nullable Boolean@Nullable Boolean@Nullable BooleaninthashCode()mutate()Returns a newChatOptions.Builderinitialized with the values of thisChatOptions.voidvoidvoidsetFrequencyPenalty(@Nullable Double frequencyPenalty) voidsetInternalToolExecutionEnabled(@Nullable Boolean internalToolExecutionEnabled) Set whether theChatModelis responsible for executing the tools requested by the model or if the tools should be executed directly by the caller.voidsetKeepAlive(@Nullable String keepAlive) voidsetLogitsAll(@Nullable Boolean logitsAll) voidsetLowVRAM(@Nullable Boolean lowVRAM) voidsetMainGPU(@Nullable Integer mainGPU) voidsetMaxTokens(@Nullable Integer maxTokens) voidvoidsetMirostat(@Nullable Integer mirostat) voidsetMirostatEta(@Nullable Float mirostatEta) voidsetMirostatTau(@Nullable Float mirostatTau) voidvoidsetNumBatch(@Nullable Integer numBatch) voidvoidvoidsetNumKeep(@Nullable Integer numKeep) voidsetNumPredict(@Nullable Integer numPredict) voidsetNumThread(@Nullable Integer numThread) voidsetOutputSchema(String outputSchema) voidsetPenalizeNewline(@Nullable Boolean penalizeNewline) voidsetPresencePenalty(@Nullable Double presencePenalty) voidsetRepeatLastN(@Nullable Integer repeatLastN) voidsetRepeatPenalty(@Nullable Double repeatPenalty) voidvoidvoidsetStopSequences(@Nullable List<String> stopSequences) voidsetTemperature(@Nullable Double temperature) voidvoidsetThinkOption(@Nullable ThinkOption thinkOption) voidsetToolCallbacks(List<ToolCallback> toolCallbacks) Set the ToolCallbacks to be registered with the ChatModel.voidsetToolContext(Map<String, Object> toolContext) Set the tool context values as map.voidsetToolNames(Set<String> toolNames) Set the names of the tools to register with the ChatModel.voidvoidvoidsetTruncate(@Nullable Boolean truncate) voidsetTypicalP(@Nullable Float typicalP) voidsetUseMLock(@Nullable Boolean useMLock) voidsetUseMMap(@Nullable Boolean useMMap) voidsetUseNUMA(@Nullable Boolean useNUMA) voidsetVocabOnly(@Nullable Boolean vocabOnly) toMap()Convert theOllamaChatOptionsobject to aMapof key/value pairs.
-
Constructor Details
-
OllamaChatOptions
public OllamaChatOptions() -
OllamaChatOptions
protected OllamaChatOptions(@Nullable Boolean useNUMA, @Nullable Integer numCtx, @Nullable Integer numBatch, @Nullable Integer numGPU, @Nullable Integer mainGPU, @Nullable Boolean lowVRAM, @Nullable Boolean f16KV, @Nullable Boolean logitsAll, @Nullable Boolean vocabOnly, @Nullable Boolean useMMap, @Nullable Boolean useMLock, @Nullable Integer numThread, @Nullable Integer numKeep, @Nullable Integer seed, @Nullable Integer numPredict, @Nullable Integer topK, @Nullable Double topP, @Nullable Double minP, @Nullable Float tfsZ, @Nullable Float typicalP, @Nullable Integer repeatLastN, @Nullable Double temperature, @Nullable Double repeatPenalty, @Nullable Double presencePenalty, @Nullable Double frequencyPenalty, @Nullable Integer mirostat, @Nullable Float mirostatTau, @Nullable Float mirostatEta, @Nullable Boolean penalizeNewline, @Nullable List<String> stop, @Nullable String model, @Nullable Object format, @Nullable String keepAlive, @Nullable Boolean truncate, @Nullable ThinkOption thinkOption, @Nullable Boolean internalToolExecutionEnabled, List<ToolCallback> toolCallbacks, Set<String> toolNames, Map<String, Object> toolContext)
-
-
Method Details
-
builder
-
filterNonSupportedFields
Filter out the non-supported fields from the options.- Parameters:
options- The options to filter.- Returns:
- The filtered options.
-
fromOptions
-
getModel
Description copied from interface:ChatOptionsReturns the model to use for the chat.- Specified by:
getModelin interfaceChatOptions- Returns:
- the model to use for the chat
-
setModel
-
getFormat
-
setFormat
-
getKeepAlive
-
setKeepAlive
-
getUseNUMA
-
setUseNUMA
-
getNumCtx
-
setNumCtx
-
getNumBatch
-
setNumBatch
-
getNumGPU
-
setNumGPU
-
getMainGPU
-
setMainGPU
-
getLowVRAM
-
setLowVRAM
-
getF16KV
-
setF16KV
-
getLogitsAll
-
setLogitsAll
-
getVocabOnly
-
setVocabOnly
-
getUseMMap
-
setUseMMap
-
getUseMLock
-
setUseMLock
-
getNumThread
-
setNumThread
-
getNumKeep
-
setNumKeep
-
getSeed
-
setSeed
-
getMaxTokens
Description copied from interface:ChatOptionsReturns the maximum number of tokens to use for the chat.- Specified by:
getMaxTokensin interfaceChatOptions- Returns:
- the maximum number of tokens to use for the chat
-
setMaxTokens
-
getNumPredict
-
setNumPredict
-
getTopK
Description copied from interface:ChatOptionsReturns the top K to use for the chat.- Specified by:
getTopKin interfaceChatOptions- Returns:
- the top K to use for the chat
-
setTopK
-
getTopP
Description copied from interface:ChatOptionsReturns the top P to use for the chat.- Specified by:
getTopPin interfaceChatOptions- Returns:
- the top P to use for the chat
-
setTopP
-
getMinP
-
setMinP
-
getTfsZ
-
setTfsZ
-
getTypicalP
-
setTypicalP
-
getRepeatLastN
-
setRepeatLastN
-
getTemperature
Description copied from interface:ChatOptionsReturns the temperature to use for the chat.- Specified by:
getTemperaturein interfaceChatOptions- Returns:
- the temperature to use for the chat
-
setTemperature
-
getRepeatPenalty
-
setRepeatPenalty
-
getPresencePenalty
Description copied from interface:ChatOptionsReturns the presence penalty to use for the chat.- Specified by:
getPresencePenaltyin interfaceChatOptions- Returns:
- the presence penalty to use for the chat
-
setPresencePenalty
-
getFrequencyPenalty
Description copied from interface:ChatOptionsReturns the frequency penalty to use for the chat.- Specified by:
getFrequencyPenaltyin interfaceChatOptions- Returns:
- the frequency penalty to use for the chat
-
setFrequencyPenalty
-
getMirostat
-
setMirostat
-
getMirostatTau
-
setMirostatTau
-
getMirostatEta
-
setMirostatEta
-
getPenalizeNewline
-
setPenalizeNewline
-
getStopSequences
Description copied from interface:ChatOptionsReturns the stop sequences to use for the chat.- Specified by:
getStopSequencesin interfaceChatOptions- Returns:
- the stop sequences to use for the chat
-
setStopSequences
-
getStop
-
setStop
-
getTruncate
-
setTruncate
-
getThinkOption
-
setThinkOption
-
getToolCallbacks
Description copied from interface:ToolCallingChatOptionsToolCallbacks to be registered with the ChatModel.- Specified by:
getToolCallbacksin interfaceToolCallingChatOptions
-
setToolCallbacks
Description copied from interface:ToolCallingChatOptionsSet the ToolCallbacks to be registered with the ChatModel.- Specified by:
setToolCallbacksin interfaceToolCallingChatOptions
-
getToolNames
Description copied from interface:ToolCallingChatOptionsNames of the tools to register with the ChatModel.- Specified by:
getToolNamesin interfaceToolCallingChatOptions
-
setToolNames
Description copied from interface:ToolCallingChatOptionsSet the names of the tools to register with the ChatModel.- Specified by:
setToolNamesin interfaceToolCallingChatOptions
-
getInternalToolExecutionEnabled
Description copied from interface:ToolCallingChatOptionsWhether theChatModelis responsible for executing the tools requested by the model or if the tools should be executed directly by the caller.- Specified by:
getInternalToolExecutionEnabledin interfaceToolCallingChatOptions
-
setInternalToolExecutionEnabled
Description copied from interface:ToolCallingChatOptionsSet whether theChatModelis responsible for executing the tools requested by the model or if the tools should be executed directly by the caller.- Specified by:
setInternalToolExecutionEnabledin interfaceToolCallingChatOptions
-
getToolContext
Description copied from interface:ToolCallingChatOptionsGet the configured tool context.- Specified by:
getToolContextin interfaceToolCallingChatOptions- Returns:
- the tool context map.
-
setToolContext
Description copied from interface:ToolCallingChatOptionsSet the tool context values as map.- Specified by:
setToolContextin interfaceToolCallingChatOptions- Parameters:
toolContext- as map
-
getOutputSchema
- Specified by:
getOutputSchemain interfaceStructuredOutputChatOptions
-
setOutputSchema
- Specified by:
setOutputSchemain interfaceStructuredOutputChatOptions
-
toMap
Convert theOllamaChatOptionsobject to aMapof key/value pairs.- Returns:
- The
Mapof key/value pairs.
-
copy
Description copied from interface:ChatOptionsReturns a copy of thisChatOptions.- Specified by:
copyin interfaceChatOptions- Returns:
- a copy of this
ChatOptions
-
mutate
Description copied from interface:ChatOptionsReturns a newChatOptions.Builderinitialized with the values of thisChatOptions. Concrete ChatOptions classes must override this to return the most concrete builder implementation.- Specified by:
mutatein interfaceChatOptions
-
equals
-
hashCode
public int hashCode()
-