Class GenericOaiClient
- java.lang.Object
-
- de.xima.fc.prompt.ms.impl.service.generic_oai.client.GenericOaiClient
-
public final class GenericOaiClient extends Object
Client for interacting with the API of a Generic OAI service (via HTTP). UseGenericOaiClient.newClient(config)to create a new instance. UseGenericOaiClientConfig.builder()to configure the connection.- Since:
- 8.5.0
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AskOutputask(AskInput request)Sends a request to the "completions" endpoint of a Generic OAI service.ListModelsOutputlistModelIds()Fetches all available models from a generic OAI service.static GenericOaiClientnewClient(GenericOaiClientConfig config)Creates a new Generic OAI client instance with the provided configuration.TestConnectionOutputtestConnection(String model)Attempts to check whether the generic OAI like service is reachable and the provided API configuration is valid.
-
-
-
Method Detail
-
ask
public AskOutput ask(AskInput request)
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
public ListModelsOutput listModelIds()
Fetches all available models from a generic OAI service.- Returns:
- A list of model IDs.
-
testConnection
public TestConnectionOutput testConnection(String model)
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
public static GenericOaiClient newClient(GenericOaiClientConfig config)
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.
-
-