ollama4j Documentation

website·Indexed 30 days ago

https://ollama4j.github.io/ollama4j

A Java client for Ollama that provides APIs for model management, generating responses (synchronously and asynchronously), creating chat conversations with history, and generating embeddings. It includes features for prompt engineering, custom roles, tool registry, and integration with SLF4J and Logback.

Tokens
99.9K
Snippets
639
Records
941
Agent score
66%

What's inside ollama4j

  1. Overview of response models in io.github.ollama4j.models.response

    The io.github.ollama4j.models.response package contains the data models used for handling responses from the Ollama API. Key response classes include:

    • OllamaResult: Standard result object.
    • OllamaResultStream: A streaming result implementation that extends java.util.LinkedList and implements java.util.Queue.
    • OllamaStructuredResult: Result for structured output.
    • OllamaImageResult: Result for image-related requests.
    • OllamaErrorResponse: Model for API error responses.
    • Model, ModelDetail, ModelMeta: Models representing model information and metadata.
    • ListModelsResponse: Response for listing available models.
    • ModelPullResponse: Response for model pull operations.
    • OllamaVersion: Model for API version information.
    • OllamaAsyncResultStreamer: An asynchronous streamer that extends java.lang.Thread.
  2. Overview of Ollama4j for tool-calling workflows

    Ollama4j is a Java SDK used to interact with Ollama-hosted AI models via a REST API. It supports tool-calling capabilities, allowing developers to automate tasks and query external data sources (such as Couchbase) using natural language. To use tool-calling, a model that supports this feature (e.g., Mistral) must be used.
  3. Overview of Ollama4j Java Library

    Ollama4j is an open-source Java library designed to integrate Java applications with Ollama, a local LLM manager and runner. It allows developers to execute large language models (LLMs) locally using both CPU and GPU modes. Key capabilities include:

    • Model Management: APIs for listing, pulling, deleting, and creating custom models.
    • LLM Interaction: Synchronous and asynchronous APIs for generating completions (asking questions).
    • Multimodal Support: Ability to send questions accompanied by image files or image URLs.
  4. Overview of io.github.ollama4j.models.embed package classes

    The io.github.ollama4j.models.embed package provides the data models required for embedding requests and results in the ollama4j library. It contains the following primary classes:

    • OllamaEmbedRequest: Represents the request payload for generating embeddings.
    • OllamaEmbedRequestBuilder: A builder class used to construct OllamaEmbedRequest instances.
    • OllamaEmbedResult: Represents the response received from the Ollama embedding API.
  5. Overview of Tool/Function Calling in ollama4j

    The ollama4j API allows for synchronous tool/function calling using LLMs. This implementation corresponds to the Ollama generate API in raw mode. Note that this is currently an experimental implementation and has been primarily built and tested for Mistral's latest models.