Class AzureOpenAiUsage

java.lang.Object
org.springframework.ai.azure.openai.metadata.AzureOpenAiUsage
All Implemented Interfaces:
Usage

public class AzureOpenAiUsage extends Object implements Usage
Usage implementation for Microsoft Azure OpenAI Service.
Since:
0.7.0
Author:
John Blum
See Also:
  • CompletionsUsage
  • Constructor Details

    • AzureOpenAiUsage

      public AzureOpenAiUsage(com.azure.ai.openai.models.CompletionsUsage usage)
  • Method Details

    • from

      public static AzureOpenAiUsage from(com.azure.ai.openai.models.ChatCompletions chatCompletions)
    • from

      public static AzureOpenAiUsage from(com.azure.ai.openai.models.CompletionsUsage usage)
    • getUsage

      protected com.azure.ai.openai.models.CompletionsUsage getUsage()
    • getPromptTokens

      public Long getPromptTokens()
      Description copied from interface: Usage
      Returns the number of tokens used in the prompt of the AI request.
      Specified by:
      getPromptTokens in interface Usage
      Returns:
      an Long with the number of tokens used in the prompt of the AI request.
      See Also:
    • getGenerationTokens

      public Long getGenerationTokens()
      Description copied from interface: Usage
      Returns the number of tokens returned in the generation (aka completion) of the AI's response.
      Specified by:
      getGenerationTokens in interface Usage
      Returns:
      an Long with the number of tokens returned in the generation (aka completion) of the AI's response.
      See Also:
    • getTotalTokens

      public Long getTotalTokens()
      Description copied from interface: Usage
      Return the total number of tokens from both the prompt of an AI request and generation of the AI's response.
      Specified by:
      getTotalTokens in interface Usage
      Returns:
      the total number of tokens from both the prompt of an AI request and generation of the AI's response.
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object