Class OllamaOptions

java.lang.Object
org.springframework.ai.ollama.api.OllamaOptions
All Implemented Interfaces:
ChatOptions, EmbeddingOptions, ModelOptions, ToolCallingChatOptions

public class OllamaOptions extends Object implements ToolCallingChatOptions, EmbeddingOptions
Helper class for creating strongly-typed Ollama options.
Since:
0.8.0
Author:
Christian Tzolov, Thomas Vitale, Ilayaperumal Gopinathan
See Also:
  • Constructor Details

    • OllamaOptions

      public OllamaOptions()
  • Method Details

    • builder

      public static OllamaOptions.Builder builder()
      Description copied from interface: ToolCallingChatOptions
      A builder to create a new ToolCallingChatOptions instance.
      Returns:
      Returns a new ChatOptions.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 OllamaOptions fromOptions(OllamaOptions fromOptions)
    • getModel

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

      public void setModel(String model)
    • getFormat

      public Object getFormat()
    • setFormat

      public void setFormat(Object format)
    • getKeepAlive

      public String getKeepAlive()
    • setKeepAlive

      public void setKeepAlive(String keepAlive)
    • getUseNUMA

      public Boolean getUseNUMA()
    • setUseNUMA

      public void setUseNUMA(Boolean useNUMA)
    • getNumCtx

      public Integer getNumCtx()
    • setNumCtx

      public void setNumCtx(Integer numCtx)
    • getNumBatch

      public Integer getNumBatch()
    • setNumBatch

      public void setNumBatch(Integer numBatch)
    • getNumGPU

      public Integer getNumGPU()
    • setNumGPU

      public void setNumGPU(Integer numGPU)
    • getMainGPU

      public Integer getMainGPU()
    • setMainGPU

      public void setMainGPU(Integer mainGPU)
    • getLowVRAM

      public Boolean getLowVRAM()
    • setLowVRAM

      public void setLowVRAM(Boolean lowVRAM)
    • getF16KV

      public Boolean getF16KV()
    • setF16KV

      public void setF16KV(Boolean f16kv)
    • getLogitsAll

      public Boolean getLogitsAll()
    • setLogitsAll

      public void setLogitsAll(Boolean logitsAll)
    • getVocabOnly

      public Boolean getVocabOnly()
    • setVocabOnly

      public void setVocabOnly(Boolean vocabOnly)
    • getUseMMap

      public Boolean getUseMMap()
    • setUseMMap

      public void setUseMMap(Boolean useMMap)
    • getUseMLock

      public Boolean getUseMLock()
    • setUseMLock

      public void setUseMLock(Boolean useMLock)
    • getNumThread

      public Integer getNumThread()
    • setNumThread

      public void setNumThread(Integer numThread)
    • getNumKeep

      public Integer getNumKeep()
    • setNumKeep

      public void setNumKeep(Integer numKeep)
    • getSeed

      public Integer getSeed()
    • setSeed

      public void setSeed(Integer seed)
    • getMaxTokens

      public 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(Integer maxTokens)
    • getNumPredict

      public Integer getNumPredict()
    • setNumPredict

      public void setNumPredict(Integer numPredict)
    • getTopK

      public 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(Integer topK)
    • getTopP

      public 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(Double topP)
    • getMinP

      public Double getMinP()
    • setMinP

      public void setMinP(Double minP)
    • getTfsZ

      public Float getTfsZ()
    • setTfsZ

      public void setTfsZ(Float tfsZ)
    • getTypicalP

      public Float getTypicalP()
    • setTypicalP

      public void setTypicalP(Float typicalP)
    • getRepeatLastN

      public Integer getRepeatLastN()
    • setRepeatLastN

      public void setRepeatLastN(Integer repeatLastN)
    • getTemperature

      public 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(Double temperature)
    • getRepeatPenalty

      public Double getRepeatPenalty()
    • setRepeatPenalty

      public void setRepeatPenalty(Double repeatPenalty)
    • getPresencePenalty

      public 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(Double presencePenalty)
    • getFrequencyPenalty

      public 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(Double frequencyPenalty)
    • getMirostat

      public Integer getMirostat()
    • setMirostat

      public void setMirostat(Integer mirostat)
    • getMirostatTau

      public Float getMirostatTau()
    • setMirostatTau

      public void setMirostatTau(Float mirostatTau)
    • getMirostatEta

      public Float getMirostatEta()
    • setMirostatEta

      public void setMirostatEta(Float mirostatEta)
    • getPenalizeNewline

      public Boolean getPenalizeNewline()
    • setPenalizeNewline

      public void setPenalizeNewline(Boolean penalizeNewline)
    • getStopSequences

      public 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(List<String> stopSequences)
    • getStop

      public List<String> getStop()
    • setStop

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

      public Boolean getTruncate()
    • setTruncate

      public void setTruncate(Boolean truncate)
    • 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

      @Nullable public 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
    • getDimensions

      public Integer getDimensions()
      Specified by:
      getDimensions in interface EmbeddingOptions
    • 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
    • toMap

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

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

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

      public int hashCode()
      Overrides:
      hashCode in class Object