stream method
Streams the output of invoking the Runnable on the given input
.
Implementation
@override
Stream<ChatResult> stream(
final PromptValue input, {
final FakeChatModelOptions? options,
}) {
final res = responses[_i++ % responses.length].split('');
return Stream.fromIterable(res).map(
(final char) => ChatResult(
id: 'fake-chat-model',
output: AIChatMessage(content: char),
finishReason: FinishReason.stop,
metadata: {
'model': options?.model ?? defaultOptions.model,
...?options?.metadata ?? defaultOptions.metadata,
},
usage: const LanguageModelUsage(),
streaming: true,
),
);
}