Interface GenerativeAIFunctionRequest


@Experimental public interface GenerativeAIFunctionRequest
An object performing a generative AI request with a list of pre-registered functions.
Since:
5.2.250908
  • Method Details

    • addFunction

      void addFunction(@NotNull @NotNull Function function, @NotNull @NotNull GenerativeAIFunction callback)
      Registers a new function to be used for this generative AI request operation.
      Parameters:
      function - The definition of the function.
      callback - The callback for any invocation during a request.
      Since:
      5.2.250908
    • request

      @NotNull @NotNull Response request(@NotNull @NotNull Request request) throws IOException
      Performs a non-streamed request using the configured functions. This method will automatically perform any FunctionCall and send back the results to the generative AI. The return value of this method is the final response after the AI received the functions results.
      Parameters:
      request - The request descriptor.
      Returns:
      The final response of the AI request.
      Throws:
      IOException - If the request failed for some reason.
      Since:
      5.2.250908
    • request

      @NotNull default @NotNull Optional<String> request(@NotNull @NotNull String prompt) throws IOException
      Convenient method for performing a non-streamed text-based user prompt. Behaves the same as request(Request) regarding function evaluation.
      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.250908
    • evaluate

      @NotNull @NotNull GenerativeAIFunctionRequest.EvaluatedResponse evaluate(@NotNull @NotNull Request request) throws IOException
      Performs a non-streamed request using the configured functions. This method only performs a single AI request using the given prompt. It's the callers responsibility to process the evaluated response accordingly.
      Parameters:
      request - The request descriptor.
      Returns:
      The completions response for the 1st AI request.
      Throws:
      IOException - If the request failed for some reason.
      Since:
      5.2.250908
    • openStream

      @NotNull @NotNull ResponseStream openStream(@NotNull @NotNull Request request) throws IOException
      Performs a streamed request using the configured functions. This method will automatically perform any FunctionCall and send back the results to the generative AI. The return value of this method is the final ResponseStream after the AI received the functions results.
      Parameters:
      request - The request descriptor.
      Returns:
      The final response of the AI request.
      Throws:
      IOException - If the request failed for some reason.
      Since:
      5.2.250908
    • evaluateStream

      @NotNull @NotNull GenerativeAIFunctionRequest.EvaluatedResponseStream evaluateStream(@NotNull @NotNull Request request) throws IOException
      Performs a streamed request using the configured functions. This method only performs a single AI request using the given prompt. It's the callers responsibility to process the evaluated response accordingly.
      Parameters:
      request - The request descriptor.
      Returns:
      The completions response for the 1st AI request.
      Throws:
      IOException - If the request failed for some reason.
      Since:
      5.2.250908