Class OllamaObject

java.lang.Object
me.neurodock.ollama.OllamaObject

public class OllamaObject extends Object
Represents an Ollama Object. This is used to represent the state of the Ollama Object. This is used by the Core to store the state of the Ollama Object. This is used by the API to send the state of the Ollama Object to the client.
See Also:
  • Method Details

    • reGenerateSystemPrompt

      public void reGenerateSystemPrompt()
      Re-generates and sets the system promp according to the LLMSystemPrompt stored as systemPrompt
    • getModel

      public String getModel()
      Gets the model of the Ollama Object.
      Returns:
      The model of the Ollama Object
    • getMessages

      public ArrayList<OllamaMessage> getMessages()
      Gets the messages
      Returns:
      The messages
    • getTools

      public ArrayList<Pair<OllamaTool, String>> getTools()
      Gets the tools
      Returns:
      The tools
    • addTool

      public void addTool(OllamaTool tool, String source)
      Adds a tool to the Ollama Object
      Parameters:
      tool - The tool to add
    • removeTool

      public void removeTool(OllamaTool tool)
    • getFormat

      public org.json.JSONObject getFormat()
      Gets the format of the Ollama Object.
      Returns:
      The format of the Ollama Object
    • getOptions

      public Map<String,Object> getOptions()
      Gets the options of the Ollama Object.
      Returns:
      The options of the Ollama Object
    • isStream

      public boolean isStream()
      Gets if the Ollama Object is streamed.
      Returns:
      If the Ollama Object is streamed
    • getKeep_alive

      public String getKeep_alive()
      Gets the keep alive of the Ollama Object.
      Returns:
      The keep alive of the Ollama Object
    • addMessage

      public void addMessage(OllamaMessage message)
      Adds a message to the Ollama Object
      Parameters:
      message - The message to add
    • dumpMessages

      public List<OllamaMessage> dumpMessages()
      Returns the current list of messages, AND clears them. You will need to re-submit the System prompt if you had one
      Returns:
      an ArrayList containing all messages stored in this OllamaObject
    • addAllMessages

      public void addAllMessages(List<OllamaMessage> messages)
      Adds all messages from a povided list to this OllamaObject
      Parameters:
      messages - the message list to add
    • setSystemMessage

      public void setSystemMessage(String message)
      Sets the system message, replacing any existing one at the start of messages, or inserting one at the start if none exists yet.
      Parameters:
      message - the system message text
    • setSystemPrompt

      public void setSystemPrompt(LLMSystemPrompt prompt)
      Replaces the current system prompt if one exists at the start of messages, or inserts one at the start if none exists yet.
    • toJSON

      public org.json.JSONObject toJSON()
    • builder

      public static OllamaObject.OllamaObjectBuilder builder()
      Creates a new instance of OllamaObjectBuilder.
      Returns:
      The OllamaObject.OllamaObjectBuilder