Interface Response

All Superinterfaces:
AttributeProvider

@Experimental public interface Response extends AttributeProvider
Response descriptor of a generative AI request.
Since:
5.2.240708
  • Method Details

    • builder

      @NotNull static @NotNull Response.Builder builder()
      Creates a new builder to create a request instance with.
      Returns:
      The builder instance.
      Since:
      5.2.240708
    • getVariants

      @NotNull @NotNull List<Message> getVariants()
      Returns the list of variants returned by the generative AI. Keep in mind, that the response text may only be a fragment, if the response is part of a ResponseStream.
      Returns:
      The list of response texts.
      Since:
      5.2.240708
    • getText

      @NotNull default @NotNull Optional<String> getText()
      Convenience method for retrieving the response text of the first variant. Any additional variant (as requested using Request.getVariantCount()) will be ignored.
      Returns:
      The response text of the first variant, or empty.
      Since:
      5.2.240708
      See Also:
    • getTokenUsage

      @NotNull @NotNull Optional<TokenUsage> getTokenUsage()
      Returns information about the token usage associated with the operation.
      Returns:
      The token usage information.
      Since:
      5.2.240708