Skip to content

Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)

Python

print out thought summaries on server

Abi Rajad538a6309acd
diff --git a/backend/models/gemini.py b/backend/models/gemini.py
index 840b6676..7ecd06fb 100644
--- a/backend/models/gemini.py
+++ b/backend/models/gemini.py
@@ -55,12 +55,15 @@ async def stream_gemini_response(
config = types.GenerateContentConfig(
temperature=0,
max_output_tokens=20000,
- thinking_config=types.ThinkingConfig(thinking_budget=10),
+ thinking_config=types.ThinkingConfig(
+ thinking_budget=5000, include_thoughts=True
+ ),
)
elif model_name == Llm.GEMINI_2_5_PRO_PREVIEW_05_06.value:
config = types.GenerateContentConfig(
temperature=0,
max_output_tokens=20000,
+ thinking_config=types.ThinkingConfig(include_thoughts=True),
)
else:
# TODO: Fix output tokens here
@@ -82,8 +85,16 @@ async def stream_gemini_response(
},
config=config,
):
- if chunk.text:
- full_response += chunk.text
- await callback(chunk.text)
+ if chunk.candidates and len(chunk.candidates) > 0:
+ for part in chunk.candidates[0].content.parts:
+ if not part.text:
+ continue
+ elif part.thought:
+ print("Thought summary:")
+ print(part.text)
+ else:
+ full_response += part.text
+ await callback(part.text)
+
completion_time = time.time() - start_time
return {"duration": completion_time, "code": full_response}