stream method
Implementation
Stream<SseEvent> stream({required TuulOptions tuulOptions}) async* {
tuulOptions.validate();
final rawStream = client.sseStream(
"/generate",
method: 'POST',
headers: _headers(),
body: tuulOptions.toJson(),
);
await for (final chunk in rawStream) {
try {
final decoded = jsonDecode(chunk);
if (decoded is Map<String, dynamic>) {
yield SseEvent.fromJson(decoded);
}
} catch (_) {
// Ignore non-JSON chunks
}
}
}