Class OpenAiTokenUsage

java.lang.Object
dev.langchain4j.model.output.TokenUsage
dev.langchain4j.model.openai.OpenAiTokenUsage

public class OpenAiTokenUsage extends TokenUsage
  • Method Details

    • inputTokensDetails

      public OpenAiTokenUsage.InputTokensDetails inputTokensDetails()
    • outputTokensDetails

      public OpenAiTokenUsage.OutputTokensDetails outputTokensDetails()
    • add

      public OpenAiTokenUsage add(TokenUsage that)
      Description copied from class: TokenUsage
      Adds the token usage of two responses together.

      Fields which are null in both responses will be null in the result.

      When one of the two is an instance of a TokenUsage subclass, that subclass performs the addition, so that the extra fields it carries are preserved. The result then has the type of that subclass, no matter which of the two sides it was on.

      A subclass carrying extra fields should therefore override this method and sum those fields as well. When neither side overrides it, there is nothing that knows how to sum the extra fields and the result is a plain TokenUsage.

      Overrides:
      add in class TokenUsage
      Parameters:
      that - The token usage to add to this one.
      Returns:
      a new TokenUsage instance with the token usage of both responses added together.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class TokenUsage
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class TokenUsage
    • toString

      public String toString()
      Overrides:
      toString in class TokenUsage
    • builder

      public static OpenAiTokenUsage.Builder builder()