sessionGetResponseStream method
Answers the pending turn as a stream of text deltas.
Implementation
@override
Stream<String> sessionGetResponseStream(
String sessionId, {
GenerationConfig? config,
}) async* {
final s = _session(sessionId);
s.cancelled = false;
final text = await _reply(s);
final words = text.split(RegExp(r'(?<=\s)'));
for (final w in words) {
if (s.cancelled) throw const OnDeviceAiCancelledException();
if (chunkDelay > Duration.zero) await Future<void>.delayed(chunkDelay);
yield w;
}
}