chatRaw method

Stream<String> chatRaw(
  1. String text, {
  2. Uint8List? imageBytes,
  3. Uint8List? audioBytes,
  4. bool enableThinking = false,
})

Same as chat but yields raw SDK JSON chunks without extractTextFromResponse mapping. Required by Gemma 4 path so callers can read the structured tool_calls field via extractToolCalls.

Implementation

Stream<String> chatRaw(
  String text, {
  Uint8List? imageBytes,
  Uint8List? audioBytes,
  bool enableThinking = false,
}) {
  final messageJson =
      buildMessageJson(text, imageBytes: imageBytes, audioBytes: audioBytes);
  final extraContext = enableThinking ? '{"enable_thinking": true}' : null;
  return sendMessageStreamRaw(messageJson, extraContext: extraContext);
}