ask method
Runs one user turn and streams orchestration and answer events.
Implementation
@override
Stream<OmnixAgentEvent> ask(String prompt, {Uint8List? imageBytes}) async* {
if (_closed) throw StateError('Agent session is closed.');
if (_running) throw StateError('An agent turn is already in progress.');
final text = prompt.trim();
if (text.isEmpty) throw ArgumentError.value(prompt, 'prompt', 'is empty');
_running = true;
_cancelled = false;
try {
await for (final event in _session.ask(
text,
imageBytes: imageBytes,
isCancelled: () => _cancelled,
)) {
yield mapFlutterGemmaAgentEvent(event);
}
} finally {
_running = false;
}
}