Update backend/gemini/client.py
Browse files- backend/gemini/client.py +1 -10
backend/gemini/client.py
CHANGED
|
@@ -395,24 +395,15 @@ class GeminiConnection:
|
|
| 395 |
if hasattr(sc, "model_turn") and sc.model_turn:
|
| 396 |
audio_chunks: list = []
|
| 397 |
mime_type = None
|
| 398 |
-
reasoning_parts: list = []
|
| 399 |
for part in sc.model_turn.parts:
|
| 400 |
if hasattr(part, "inline_data") and part.inline_data:
|
| 401 |
audio_chunks.append(part.inline_data.data)
|
| 402 |
mime_type = part.inline_data.mime_type
|
| 403 |
elif hasattr(part, "text") and part.text:
|
| 404 |
-
|
| 405 |
if audio_chunks:
|
| 406 |
result["audio"] = base64.b64encode(b"".join(audio_chunks)).decode("utf-8")
|
| 407 |
result["mime_type"] = mime_type
|
| 408 |
-
if reasoning_parts:
|
| 409 |
-
combined_reasoning = "".join(reasoning_parts)
|
| 410 |
-
# When output_transcription is present, model_turn text is reasoning;
|
| 411 |
-
# otherwise it is the actual text response (text-only mode fallback).
|
| 412 |
-
if "gemini_text" in result:
|
| 413 |
-
result["reasoning_text"] = combined_reasoning
|
| 414 |
-
else:
|
| 415 |
-
result["gemini_text"] = combined_reasoning
|
| 416 |
|
| 417 |
return result
|
| 418 |
|
|
|
|
| 395 |
if hasattr(sc, "model_turn") and sc.model_turn:
|
| 396 |
audio_chunks: list = []
|
| 397 |
mime_type = None
|
|
|
|
| 398 |
for part in sc.model_turn.parts:
|
| 399 |
if hasattr(part, "inline_data") and part.inline_data:
|
| 400 |
audio_chunks.append(part.inline_data.data)
|
| 401 |
mime_type = part.inline_data.mime_type
|
| 402 |
elif hasattr(part, "text") and part.text:
|
| 403 |
+
result["gemini_text"] = (result.get("gemini_text") or "") + part.text
|
| 404 |
if audio_chunks:
|
| 405 |
result["audio"] = base64.b64encode(b"".join(audio_chunks)).decode("utf-8")
|
| 406 |
result["mime_type"] = mime_type
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 407 |
|
| 408 |
return result
|
| 409 |
|