stream method

  1. @override
Stream<LLMResult> stream(
  1. PromptValue input, {
  2. LLMOptions? options,
})
override

Streams the output of invoking the Runnable on the given input.

  • input - the input to invoke the Runnable on.
  • options - the options to use when invoking the Runnable.

Implementation

@override
Stream<LLMResult> stream(
  final PromptValue input, {
  final LLMOptions? options,
}) {
  final promptChars = input.toString().split('');
  return Stream.fromIterable(promptChars).map(
    (final item) => LLMResult(
      id: 'fake-echo',
      output: item,
      finishReason: FinishReason.unspecified,
      metadata: const {},
      usage: const LanguageModelUsage(),
      streaming: true,
    ),
  );
}