Class OllamaProvider

java.lang.Object
net.thevpc.naru.model.OllamaProvider
All Implemented Interfaces:
ModelProvider

public class OllamaProvider extends Object implements ModelProvider
Ollama provider — talks to a local (or remote) Ollama server via REST.

Endpoint: POST {baseUrl}/api/chat

Compatible with Ollama 0.2.8+ tool-calling format.

  • Constructor Details

    • OllamaProvider

      public OllamaProvider(String baseUrl)
  • Method Details

    • getName

      public String getName()
      Description copied from interface: ModelProvider
      Provider name for display purposes.
      Specified by:
      getName in interface ModelProvider
    • listModels

      public List<String> listModels()
      Description copied from interface: ModelProvider
      Fetch the list of available models from this provider.
      Specified by:
      listModels in interface ModelProvider
      Returns:
      a list of model names
    • chat

      public ChatResponse chat(String model, List<ChatMessage> messages, List<ToolDefinition> tools)
      Description copied from interface: ModelProvider
      Send a chat request with optional tool definitions.
      Specified by:
      chat in interface ModelProvider
      Parameters:
      model - provider-specific model name (e.g. "qwen2.5-coder:7b")
      messages - conversation history (must include the new user message)
      tools - tool definitions available to the model (may be empty)
      Returns:
      the model's response