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:
  • Constructor Details

  • Method Details

    • builder

      public static OllamaChatOptions.Builder builder()
    • filterNonSupportedFields

      public static Map<String,Object> filterNonSupportedFields(Map<String,Object> options)
      Filter out the non-supported fields from the options.
      Parameters:
      options - The options to filter.
      Returns:
      The filtered options.
    • fromOptions

      public static OllamaChatOptions fromOptions(OllamaChatOptions fromOptions)
    • getModel

      public @Nullable String getModel()
      Description copied from interface: ChatOptions
      Returns the model to use for the chat.
      Specified by:
      getModel in interface ChatOptions
      Returns:
      the model to use for the chat
    • setModel

      public void setModel(@Nullable String model)
    • getFormat

      public @Nullable Object getFormat()
    • setFormat

      public void setFormat(@Nullable Object format)
    • getKeepAlive

      public @Nullable String getKeepAlive()
    • setKeepAlive

      public void setKeepAlive(@Nullable String keepAlive)
    • getUseNUMA

      public @Nullable Boolean getUseNUMA()
    • setUseNUMA

      public void setUseNUMA(@Nullable Boolean useNUMA)
    • getNumCtx

      public @Nullable Integer getNumCtx()
    • setNumCtx

      public void setNumCtx(@Nullable Integer numCtx)
    • getNumBatch

      public @Nullable Integer getNumBatch()
    • setNumBatch

      public void setNumBatch(@Nullable Integer numBatch)
    • getNumGPU

      public @Nullable Integer getNumGPU()
    • setNumGPU

      public void setNumGPU(@Nullable Integer numGPU)
    • getMainGPU

      public @Nullable Integer getMainGPU()
    • setMainGPU

      public void setMainGPU(@Nullable Integer mainGPU)
    • getLowVRAM

      public @Nullable Boolean getLowVRAM()
    • setLowVRAM

      public void setLowVRAM(@Nullable Boolean lowVRAM)
    • getF16KV

      public @Nullable Boolean getF16KV()
    • setF16KV

      public void setF16KV(@Nullable Boolean f16KV)
    • getLogitsAll

      public @Nullable Boolean getLogitsAll()
    • setLogitsAll

      public void setLogitsAll(@Nullable Boolean logitsAll)
    • getVocabOnly

      public @Nullable Boolean getVocabOnly()
    • setVocabOnly

      public void setVocabOnly(@Nullable Boolean vocabOnly)
    • getUseMMap

      public @Nullable Boolean getUseMMap()
    • setUseMMap

      public void setUseMMap(@Nullable Boolean useMMap)
    • getUseMLock

      public @Nullable Boolean getUseMLock()
    • setUseMLock

      public void setUseMLock(@Nullable Boolean useMLock)
    • getNumThread

      public @Nullable Integer getNumThread()
    • setNumThread

      public void setNumThread(@Nullable Integer numThread)
    • getNumKeep

      public @Nullable Integer getNumKeep()
    • setNumKeep

      public void setNumKeep(@Nullable Integer numKeep)
    • getSeed

      public @Nullable Integer getSeed()
    • setSeed

      public void setSeed(@Nullable Integer seed)
    • getMaxTokens

      public @Nullable Integer getMaxTokens()
      Description copied from interface: ChatOptions
      Returns the maximum number of tokens to use for the chat.
      Specified by:
      getMaxTokens in interface ChatOptions
      Returns:
      the maximum number of tokens to use for the chat
    • setMaxTokens

      public void setMaxTokens(@Nullable Integer maxTokens)
    • getNumPredict

      public @Nullable Integer getNumPredict()
    • setNumPredict

      public void setNumPredict(@Nullable Integer numPredict)
    • getTopK

      public @Nullable Integer getTopK()
      Description copied from interface: ChatOptions
      Returns the top K to use for the chat.
      Specified by:
      getTopK in interface ChatOptions
      Returns:
      the top K to use for the chat
    • setTopK

      public void setTopK(@Nullable Integer topK)
    • getTopP

      public @Nullable Double getTopP()
      Description copied from interface: ChatOptions
      Returns the top P to use for the chat.
      Specified by:
      getTopP in interface ChatOptions
      Returns:
      the top P to use for the chat
    • setTopP

      public void setTopP(@Nullable Double topP)
    • getMinP

      public @Nullable Double getMinP()
    • setMinP

      public void setMinP(@Nullable Double minP)
    • getTfsZ

      public @Nullable Float getTfsZ()
    • setTfsZ

      public void setTfsZ(@Nullable Float tfsZ)
    • getTypicalP

      public @Nullable Float getTypicalP()
    • setTypicalP

      public void setTypicalP(@Nullable Float typicalP)
    • getRepeatLastN

      public @Nullable Integer getRepeatLastN()
    • setRepeatLastN

      public void setRepeatLastN(@Nullable Integer repeatLastN)
    • getTemperature

      public @Nullable Double getTemperature()
      Description copied from interface: ChatOptions
      Returns the temperature to use for the chat.
      Specified by:
      getTemperature in interface ChatOptions
      Returns:
      the temperature to use for the chat
    • setTemperature

      public void setTemperature(@Nullable Double temperature)
    • getRepeatPenalty

      public @Nullable Double getRepeatPenalty()
    • setRepeatPenalty

      public void setRepeatPenalty(@Nullable Double repeatPenalty)
    • getPresencePenalty

      public @Nullable Double getPresencePenalty()
      Description copied from interface: ChatOptions
      Returns the presence penalty to use for the chat.
      Specified by:
      getPresencePenalty in interface ChatOptions
      Returns:
      the presence penalty to use for the chat
    • setPresencePenalty

      public void setPresencePenalty(@Nullable Double presencePenalty)
    • getFrequencyPenalty

      public @Nullable Double getFrequencyPenalty()
      Description copied from interface: ChatOptions
      Returns the frequency penalty to use for the chat.
      Specified by:
      getFrequencyPenalty in interface ChatOptions
      Returns:
      the frequency penalty to use for the chat
    • setFrequencyPenalty

      public void setFrequencyPenalty(@Nullable Double frequencyPenalty)
    • getMirostat

      public @Nullable Integer getMirostat()
    • setMirostat

      public void setMirostat(@Nullable Integer mirostat)
    • getMirostatTau

      public @Nullable Float getMirostatTau()
    • setMirostatTau

      public void setMirostatTau(@Nullable Float mirostatTau)
    • getMirostatEta

      public @Nullable Float getMirostatEta()
    • setMirostatEta

      public void setMirostatEta(@Nullable Float mirostatEta)
    • getPenalizeNewline

      public @Nullable Boolean getPenalizeNewline()
    • setPenalizeNewline

      public void setPenalizeNewline(@Nullable Boolean penalizeNewline)
    • getStopSequences

      public @Nullable List<String> getStopSequences()
      Description copied from interface: ChatOptions
      Returns the stop sequences to use for the chat.
      Specified by:
      getStopSequences in interface ChatOptions
      Returns:
      the stop sequences to use for the chat
    • setStopSequences

      public void setStopSequences(@Nullable List<String> stopSequences)
    • getStop

      public @Nullable List<String> getStop()
    • setStop

      public void setStop(@Nullable List<String> stop)
    • getTruncate

      public @Nullable Boolean getTruncate()
    • setTruncate

      public void setTruncate(@Nullable Boolean truncate)
    • getThinkOption

      public @Nullable ThinkOption getThinkOption()
    • setThinkOption

      public void setThinkOption(@Nullable ThinkOption thinkOption)
    • getToolCallbacks

      public List<ToolCallback> getToolCallbacks()
      Description copied from interface: ToolCallingChatOptions
      ToolCallbacks to be registered with the ChatModel.
      Specified by:
      getToolCallbacks in interface ToolCallingChatOptions
    • setToolCallbacks

      public void setToolCallbacks(List<ToolCallback> toolCallbacks)
      Description copied from interface: ToolCallingChatOptions
      Set the ToolCallbacks to be registered with the ChatModel.
      Specified by:
      setToolCallbacks in interface ToolCallingChatOptions
    • getToolNames

      public Set<String> getToolNames()
      Description copied from interface: ToolCallingChatOptions
      Names of the tools to register with the ChatModel.
      Specified by:
      getToolNames in interface ToolCallingChatOptions
    • setToolNames

      public void setToolNames(Set<String> toolNames)
      Description copied from interface: ToolCallingChatOptions
      Set the names of the tools to register with the ChatModel.
      Specified by:
      setToolNames in interface ToolCallingChatOptions
    • getInternalToolExecutionEnabled

      public @Nullable Boolean getInternalToolExecutionEnabled()
      Description copied from interface: ToolCallingChatOptions
      Whether the ChatModel is responsible for executing the tools requested by the model or if the tools should be executed directly by the caller.
      Specified by:
      getInternalToolExecutionEnabled in interface ToolCallingChatOptions
    • setInternalToolExecutionEnabled

      public void setInternalToolExecutionEnabled(@Nullable Boolean internalToolExecutionEnabled)
      Description copied from interface: ToolCallingChatOptions
      Set whether the ChatModel is responsible for executing the tools requested by the model or if the tools should be executed directly by the caller.
      Specified by:
      setInternalToolExecutionEnabled in interface ToolCallingChatOptions
    • getToolContext

      public Map<String,Object> getToolContext()
      Description copied from interface: ToolCallingChatOptions
      Get the configured tool context.
      Specified by:
      getToolContext in interface ToolCallingChatOptions
      Returns:
      the tool context map.
    • setToolContext

      public void setToolContext(Map<String,Object> toolContext)
      Description copied from interface: ToolCallingChatOptions
      Set the tool context values as map.
      Specified by:
      setToolContext in interface ToolCallingChatOptions
      Parameters:
      toolContext - as map
    • getOutputSchema

      public String getOutputSchema()
      Specified by:
      getOutputSchema in interface StructuredOutputChatOptions
    • setOutputSchema

      public void setOutputSchema(String outputSchema)
      Specified by:
      setOutputSchema in interface StructuredOutputChatOptions
    • toMap

      public Map<String,Object> toMap()
      Convert the OllamaChatOptions object to a Map of key/value pairs.
      Returns:
      The Map of key/value pairs.
    • copy

      public OllamaChatOptions copy()
      Description copied from interface: ChatOptions
      Returns a copy of this ChatOptions.
      Specified by:
      copy in interface ChatOptions
      Returns:
      a copy of this ChatOptions
    • mutate

      public OllamaChatOptions.Builder mutate()
      Description copied from interface: ChatOptions
      Returns a new ChatOptions.Builder initialized with the values of this ChatOptions. Concrete ChatOptions classes must override this to return the most concrete builder implementation.
      Specified by:
      mutate in interface ChatOptions
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object