@@ -143,7 +143,7 @@ def _format_request_content_part(self, content: ContentBlock) -> genai.types.Par
143143
144144 if "toolUse" in content :
145145 thought_signature_b64 = content ["toolUse" ].get ("thoughtSignature" )
146-
146+
147147 tool_use_thought_signature : Optional [bytes ] = None
148148 if thought_signature_b64 :
149149 try :
@@ -237,7 +237,7 @@ def _format_request_config(
237237 thinking_config = None
238238 if tool_specs :
239239 thinking_config = genai .types .ThinkingConfig (include_thoughts = False )
240-
240+
241241 return genai .types .GenerateContentConfig (
242242 system_instruction = system_prompt ,
243243 tools = self ._format_request_tools (tool_specs ),
@@ -299,17 +299,17 @@ def _format_chunk(self, event: dict[str, Any]) -> StreamEvent:
299299 "name" : event ["data" ].function_call .name ,
300300 "toolUseId" : event ["data" ].function_call .name ,
301301 }
302-
302+
303303 # Get thought_signature from the event dict (passed from stream method)
304304 thought_sig = event .get ("thought_signature" )
305-
305+
306306 if thought_sig :
307307 # Ensure it's bytes for encoding
308308 if isinstance (thought_sig , str ):
309309 thought_sig = thought_sig .encode ("utf-8" )
310310 # Use base64 encoding for storage
311311 tool_use ["thoughtSignature" ] = base64 .b64encode (thought_sig ).decode ("utf-8" )
312-
312+
313313 return {
314314 "contentBlockStart" : {
315315 "start" : {"toolUse" : cast (Any , tool_use )},
@@ -413,7 +413,7 @@ async def stream(
413413 # Track thought_signature to associate with function calls
414414 # According to Gemini docs, thought_signature can be on any part
415415 last_thought_signature : Optional [bytes ] = None
416-
416+
417417 async for event in response :
418418 candidates = event .candidates
419419 candidate = candidates [0 ] if candidates else None
@@ -424,11 +424,11 @@ async def stream(
424424 # Check ALL parts for thought_signature (Gemini may still include it even with thinking disabled)
425425 if hasattr (part , "thought_signature" ) and part .thought_signature :
426426 last_thought_signature = part .thought_signature
427-
427+
428428 if part .function_call :
429429 # Use the last thought_signature captured
430430 effective_thought_signature = last_thought_signature
431-
431+
432432 yield self ._format_chunk (
433433 {
434434 "chunk_type" : "content_start" ,
0 commit comments