File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
pydantic_ai_slim/pydantic_ai/models Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -578,7 +578,9 @@ async def _get_event_iterator(self) -> AsyncIterator[ModelResponseStreamEvent]:
578
578
async for chunk in self ._response :
579
579
self ._usage = _metadata_as_usage (chunk )
580
580
581
- assert chunk .candidates is not None
581
+ if not chunk .candidates :
582
+ continue # pragma: no cover
583
+
582
584
candidate = chunk .candidates [0 ]
583
585
584
586
if chunk .response_id : # pragma: no branch
@@ -610,7 +612,10 @@ async def _get_event_iterator(self) -> AsyncIterator[ModelResponseStreamEvent]:
610
612
else : # pragma: no cover
611
613
raise UnexpectedModelBehavior ('Content field missing from streaming Gemini response' , str (chunk ))
612
614
613
- parts = candidate .content .parts or []
615
+ parts = candidate .content .parts
616
+ if not parts :
617
+ continue # pragma: no cover
618
+
614
619
for part in parts :
615
620
if part .thought_signature :
616
621
signature = base64 .b64encode (part .thought_signature ).decode ('utf-8' )
You can’t perform that action at this time.
0 commit comments