Class UsageUtils
java.lang.Object
org.springframework.ai.chat.metadata.UsageUtils
An utility class to provide support methods handling
Usage
.- Author:
- Ilayaperumal Gopinathan
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Usage
getCumulativeUsage
(Usage currentUsage, ChatResponse previousChatResponse) Accumulate usage tokens from the previous chat response to the current usage tokens.static boolean
Check if theUsage
is empty.
-
Constructor Details
-
UsageUtils
public UsageUtils()
-
-
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 theUsage
is empty. Returns true when theUsage
is null. Returns true when theUsage
has zero tokens.- Parameters:
usage
- the usage to check against.- Returns:
- the boolean value to represent if it is empty.
-