Class Core

java.lang.Object
me.neurodock.core.Core

public class Core extends Object
The Main class for the System, responsible for managing the OllamaObject, tools, and the Ollama API.
  • Constructor Details

    • Core

      public Core(@NotNull @NotNull PrintAdvanceMessageHandler printMessageHandler)
      Creates a new instance of Core with the provided PrintMessageHandler, defaulting the Ollama backend to localhost.
      Parameters:
      printMessageHandler - The PrintMessageHandler to use as the default output
  • Method Details

    • setLogDirectory

      public static void setLogDirectory(String logDirectory)
    • ensureDir

      public static void ensureDir(String path)
      Ensures that a directory exists at the given path, creating it if it does not.
      Parameters:
      path - The path of the directory to create
    • getChatObject

      public ChatObject getChatObject()
    • setModel

      public void setModel(Model model)
      Sets the model object to the provided argument, Also adds the memory base system. See setModelNoMemory(Model) if you don't want to add memory functions
      Parameters:
      model - The Model to use
    • setModelNoMemory

      public void setModelNoMemory(Model model)
      Sets the model object to the provided argument, Does not add the base system for memory. see setModel(Model) if you want to add memory function
      Parameters:
      model - The Model to use
    • addTool

      public void addTool(Tool functionTool)
      Adds a new tool to the System
      Parameters:
      functionTool - The tool to add
    • addMessage

      public void addMessage(Message message)
    • getTools

      public ArrayList<Tool> getTools()
      Gets the list of tools added to the System
      Returns:
      The list of tools added to the System compressed as Pairs of the tool and the source
    • getModel

      public Model getModel()
      Gets the Ollama Object
      Returns:
      The Ollama Object
    • removeTool

      public void removeTool(String name)
      Removes a tool with a given name
      Parameters:
      name - The tool to remove
    • flushLog

      public static void flushLog()
      Flushes the log file
    • queryModel

      public CompletableFuture<Message> queryModel()
    • queryModel

      public CompletableFuture<Message> queryModel(Consumer<org.json.JSONObject> consumer) throws OperationNotSupportedException
      Throws:
      OperationNotSupportedException
    • handleResponse

      public void handleResponse(Message response)
      Handles the response from Ollama.

      Processes tool calls, logs information, appends messages to the OllamaObject, and prints output to the user.

      Parameters:
      response - The response from Ollama
    • writeLog

      public static void writeLog(String message)
      Writes a message to the log file
      Parameters:
      message - The message to write
    • enablePlugins

      public void enablePlugins(File pluginDirectory)