Interface GenerativeAIConnector

All Known Subinterfaces:
GenerativeAIAgent, GenerativeAIConnectorPlugin

@Experimental public interface GenerativeAIConnector
Agent for performing GPT completion requests.
Since:
5.2.240708
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks whether this functionality is available, which depends on a configured API key in the GPT service configuration.
    default @NotNull ResponseStream
    openStream(@NotNull Request request)
    Initiates a streamed completions request, if supported by the configured API connector.
    @NotNull Response
    request(@NotNull Request request)
    Performs a non-streamed completions request.
    default @NotNull Optional<String>
    request(@NotNull String prompt)
    Convenient method for performing a non-streamed text-based user prompt.
  • Method Details

    • isAvailable

      boolean isAvailable()
      Checks whether this functionality is available, which depends on a configured API key in the GPT service configuration.
      Returns:
      true if this functionality is available, false otherwise.
      Since:
      5.2.240708
    • request

      @NotNull @NotNull Response request(@NotNull @NotNull Request request) throws IOException
      Performs a non-streamed completions request.
      Parameters:
      request - The request descriptor.
      Returns:
      The completions response.
      Throws:
      IOException - If the request failed for some reason.
      Since:
      5.2.240708
    • request

      @NotNull default @NotNull Optional<String> request(@NotNull @NotNull String prompt) throws IOException
      Convenient method for performing a non-streamed text-based user prompt.
      Parameters:
      prompt - The user prompt to be sent.
      Returns:
      The response text, if available.
      Throws:
      IOException - If the request failed for some reason.
      Since:
      5.2.240708
    • openStream

      @NotNull default @NotNull ResponseStream openStream(@NotNull @NotNull Request request) throws IOException
      Initiates a streamed completions request, if supported by the configured API connector. Any implementation of GenerativeAIConnectorPlugin is strongly encouraged to implement this method properly in order to enhance the user experience when interacting with the generative AI. By default, this method delegates to request(String) and returns the response as singleton ResponseStream.
      Parameters:
      request - The request descriptor.
      Returns:
      The streamed response fragments as closeable iterator.
      Throws:
      IOException - If the request failed for some reason.
      Since:
      5.2.240708