sessionCountTokens method

  1. @override
Future<int> sessionCountTokens(
  1. String sessionId, {
  2. String? text,
})
override

Token count of the whole conversation, or of text when given.

Implementation

@override
Future<int> sessionCountTokens(String sessionId, {String? text}) async {
  final s = _session(sessionId);
  return estimateTokens(
    text ?? s.transcript.followedBy(s.pending).join('\n'),
  );
}