Class AskOutput

  • All Implemented Interfaces:
    TokenUsage

    public final class AskOutput
    extends BaseOutput
    implements TokenUsage
    Represents a response from the "completions" endpoint of the 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.
    Since:
    8.5.0
    • Method Detail

      • answer

        public String answer()
        Gets the text generated by the model in response to the prompt.
        Returns:
        The generated response text.
      • inputTokens

        public long inputTokens()
        Description copied from interface: TokenUsage
        Gets the number of input tokens that were used to process the prompt.
        Specified by:
        inputTokens in interface TokenUsage
        Returns:
        The number of input tokens.
      • outputTokens

        public long outputTokens()
        Description copied from interface: TokenUsage
        Gets the number of output tokens that were used to generate the response.
        Specified by:
        outputTokens in interface TokenUsage
        Returns:
        The number of output tokens.
      • totalTokens

        public long totalTokens()
        Description copied from interface: TokenUsage
        Gets the total number of tokens that were used to process the request.
        Specified by:
        totalTokens in interface TokenUsage
        Returns:
        The total number of tokens.
      • builder

        public static AskOutput.Builder builder()
        Creates a new builder for constructing an AskOutput.
        Returns:
        A new builder instance.
      • error

        public static AskOutput error​(GenericOaiErrorType type,
                                      String errorMessage,
                                      Throwable cause)
        Creates an AskOutput representing an error.
        Parameters:
        type - The type of error.
        errorMessage - A descriptive error message.
        cause - The underlying exception that caused the error.
        Returns:
        An ask response instance representing the error.