startChatStream method

  1. @override
Stream<String> startChatStream(
  1. GenerativeModel generativeModel,
  2. String prompt, {
  3. List<ChatMessage>? history,
})
override

Generates a streaming response from the backend with the provided Contents.

Implementation

@override
Stream<String> startChatStream(
  GenerativeModel generativeModel,
  String prompt, {
  List<ChatMessage>? history,
}) async* {
  Map<String, dynamic> input = _getStartChatInput(
    generativeModel,
    prompt,
    history: history,
  );
  input["method"] = "startChatStream";
  yield* _eventChannel
      .receiveBroadcastStream(Map.from(input))
      .map<String>((event) {
    return event;
  });
}