Fix rendering thoughts of Gemini reasoning models

Previously there was duplication of thought in message to user and in
the train of thought. This should be resolved now
This commit is contained in:
Debanjum
2025-06-11 13:09:38 -07:00
parent 4946ea1668
commit eaae1cf74e

View File

@@ -239,12 +239,11 @@ async def gemini_chat_completion_with_backoff(
# emit thought vs response parts
for part in chunk.candidates[0].content.parts:
if part.text:
aggregated_response += part.text
yield ResponseWithThought(response=part.text)
if part.thought:
yield ResponseWithThought(thought=part.text)
elif part.text:
aggregated_response += part.text
yield ResponseWithThought(response=part.text)
# Calculate cost of chat
input_tokens = final_chunk.usage_metadata.prompt_token_count or 0 if final_chunk else 0
output_tokens = final_chunk.usage_metadata.candidates_token_count or 0 if final_chunk else 0