MockOllama
Mock implementation of an Ollama-compatible service for testing purposes.
This class provides an HTTP mock server to simulate Ollama APIs, specifically for generate completions, chat completions, and other Ollama endpoints. It is designed to mimic the behavior of the Ollama APIs locally and facilitate integration testing and development.
Extends AbstractMockLlm to provide Ollama-specific functionality.
Author
Konstantin Pavlov
Parameters
The port on which the mock server will run. Defaults to 0, which allows the server to select an available port.
Controls whether the mock server's operations are logged in detail. Defaults to true.
Functions
Sets up a mock handler for the Ollama chat completion (/api/chat) endpoint.
Provides a Java-compatible overload for configuring a mock Ollama chat request using a Consumer.
Sets up a mock handler for the Ollama /api/embed endpoint, allowing configuration of request matching for embedding requests.
Provides a Java-compatible overload for configuring a mock /api/embed endpoint using a Consumer.
Sets up a mock handler for the Ollama /api/generate completion endpoint.
Configures a mock /api/generate endpoint using a Java Consumer to specify the request criteria.