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). Use GenericOaiClient.newClient(config) to create a new instance. Use GenericOaiClientConfig.builder() to configure the connection.
Since:
8.5.0
  • Method Details

    • 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.