Class OpenAiTokenUsage
java.lang.Object
dev.langchain4j.model.output.TokenUsage
dev.langchain4j.model.openai.OpenAiTokenUsage
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic class -
Method Summary
Modifier and TypeMethodDescriptionadd(TokenUsage that) Adds the token usage of two responses together.static OpenAiTokenUsage.Builderbuilder()booleaninthashCode()toString()Methods inherited from class TokenUsage
inputTokenCount, outputTokenCount, sum, sum, totalTokenCount
-
Method Details
-
inputTokensDetails
-
outputTokensDetails
-
add
Description copied from class:TokenUsageAdds 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
TokenUsagesubclass, 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:
addin classTokenUsage- Parameters:
that- The token usage to add to this one.- Returns:
- a new
TokenUsageinstance with the token usage of both responses added together.
-
equals
- Overrides:
equalsin classTokenUsage
-
hashCode
public int hashCode()- Overrides:
hashCodein classTokenUsage
-
toString
- Overrides:
toStringin classTokenUsage
-
builder
-