Interface Usage

All Known Implementing Classes:
DefaultUsage, EmptyUsage, MessageAggregator.DefaultUsage

public interface Usage
Abstract Data Type (ADT) encapsulating metadata on the usage of an AI provider's API per AI request.
Since:
0.7.0
Author:
John Blum, Ilayaperumal Gopinathan
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the number of tokens returned in the generation (aka completion) of the AI's response.
    default Long
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the usage data from the underlying model API response.
    Returns the number of tokens used in the prompt of the AI request.
    default Integer
    Return the total number of tokens from both the prompt of an AI request and generation of the AI's response.
  • Method Details

    • getPromptTokens

      Integer getPromptTokens()
      Returns the number of tokens used in the prompt of the AI request.
      Returns:
      an Integer with the number of tokens used in the prompt of the AI request.
      See Also:
    • getGenerationTokens

      @Deprecated(forRemoval=true, since="1.0.0-M6") default Long getGenerationTokens()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getCompletionTokens

      Integer getCompletionTokens()
      Returns the number of tokens returned in the generation (aka completion) of the AI's response.
      Returns:
      an Integer with the number of tokens returned in the generation (aka completion) of the AI's response.
      See Also:
    • getTotalTokens

      default Integer getTotalTokens()
      Return the total number of tokens from both the prompt of an AI request and generation of the AI's response.
      Returns:
      the total number of tokens from both the prompt of an AI request and generation of the AI's response.
      See Also:
    • getNativeUsage

      Object getNativeUsage()
      Return the usage data from the underlying model API response.
      Returns:
      the object of type inferred by the API response.