Package org.springframework.ai.support
Class UsageCalculator
java.lang.Object
org.springframework.ai.support.UsageCalculator
An utility class to provide support methods handling
Usage.- Author:
- Ilayaperumal Gopinathan
-
Method Summary
Modifier and TypeMethodDescriptionstatic UsagegetCumulativeUsage(Usage currentUsage, ChatResponse previousChatResponse) Accumulate usage tokens from the previous chat response to the current usage tokens.static booleanCheck if theUsageis empty.
-
Method Details
-
getCumulativeUsage
Accumulate usage tokens from the previous chat response to the current usage tokens.- Parameters:
currentUsage- the current usage.previousChatResponse- the previous chat response.- Returns:
- accumulated usage.
-
isEmpty
Check if theUsageis empty. Returns true when theUsageis null. Returns true when theUsagehas zero tokens.- Parameters:
usage- the usage to check against.- Returns:
- the boolean value to represent if it is empty.
-