stream method

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

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<ChatResult> stream(
  final PromptValue input, {
  final ChatOllamaOptions? options,
}) {
  final id = _uuid.v4();
  return _client
      .generateChatCompletionStream(
        request: generateChatCompletionRequest(
          input.toChatMessages(),
          options: options,
          defaultOptions: defaultOptions,
          stream: true,
        ),
      )
      .map(
        (final completion) => completion.toChatResult(id, streaming: true),
      );
}