sessionGetResponse method

  1. @override
Future<AiResponse> sessionGetResponse(
  1. String sessionId, {
  2. GenerationConfig? config,
})
override

Answers the pending turn.

Implementation

@override
Future<AiResponse> sessionGetResponse(
  String sessionId, {
  GenerationConfig? config,
}) async {
  final s = _session(sessionId);
  s.cancelled = false;
  final text = await _reply(s);
  if (s.cancelled) throw const OnDeviceAiCancelledException();
  return AiResponse(
    text: text,
    tokenCount: estimateTokens(text),
    generationTimeMs: 1,
  );
}