MockOpenai
Mock implementation of an OpenAI-compatible service for testing purposes.
This class provides an HTTP mock server to simulate OpenAI APIs, specifically for chat completions and response generation. It is designed to mimic the behavior of the OpenAI APIs locally and facilitate integration testing and development.
Extends AbstractMockLlm to provide OpenAI-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.
See also
Functions
Java-friendly overload that accepts a Consumer for configuring the chat request.
Configures and constructs a mock handler for the OpenAI /v1/chat/completions endpoint.
Java-friendly overload that accepts a Consumer for configuring the embedding request.
Sets up a mock handler for the OpenAI /v1/embeddings endpoint, allowing configuration of request matching for embedding requests.
Java-friendly overload that accepts a Consumer for configuring the moderation request.
Sets up a mock handler for the OpenAI /v1/moderations endpoint, allowing configuration of request matching for moderation requests.
Sets up a mock handler for the OpenAI /v1/responses endpoint, allowing configuration of request matching for response generation requests.