totalTokens property
int
get
totalTokens
Returns the total tokens used in the conversation
final totalTokens = chat.totalTokens;
print(totalTokens); //prints the total tokens used in the conversation
Implementation
int get totalTokens {
if (_chatItems.isEmpty) return 0;
return _chatItems.fold(0, (previousValue, element) {
if (element is RequestChatEvent) {
return previousValue;
}
return previousValue + ((element as ResponseChatEvent).usage.totalTokens);
});
}