Class GenericOaiClient
java.lang.Object
de.xima.fc.prompt.ms.impl.service.generic_oai.client.GenericOaiClient
Client for interacting with the API of a Generic OAI service (via HTTP). Use
GenericOaiClient.newClient(config) to create a new instance. Use
GenericOaiClientConfig.builder() to configure the connection.- Since:
- 8.5.0
-
Method Summary
Modifier and TypeMethodDescriptionSends a request to the "completions" endpoint of a Generic OAI service.Fetches all available models from a generic OAI service.static GenericOaiClientnewClient(GenericOaiClientConfig config) Creates a new Generic OAI client instance with the provided configuration.testConnection(String model) Attempts to check whether the generic OAI like service is reachable and the provided API configuration is valid.
-
Method Details
-
ask
Sends a request to the "completions" endpoint of a Generic OAI service. This endpoint takes a prompt and an optional file; and responds with a generated text based on the prompt and the file's content.- Parameters:
request- The request parameters including the prompt and optional file.- Returns:
- The response containing the generated text.
-
listModelIds
Fetches all available models from a generic OAI service.- Returns:
- A list of model IDs.
-
testConnection
Attempts to check whether the generic OAI like service is reachable and the provided API configuration is valid. Currently, we make a simple request to the "chat/completions" endpoint with a test prompt. -
newClient
Creates a new Generic OAI client instance with the provided configuration.- Parameters:
config- The configuration for the Generic OAI connection, with the API key and other parameters.- Returns:
- A new Generic OAI client instance if the configuration is valid, or null if the configuration is invalid or incomplete.
-