File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed
sentry_sdk/integrations/google_genai Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ def accumulate_streaming_response(chunks):
5151 for chunk in chunks :
5252 # Extract text and tool calls
5353 if getattr (chunk , "candidates" , None ):
54- for candidate in chunk . candidates :
54+ for candidate in getattr ( chunk , " candidates" , []) :
5555 if hasattr (candidate , "content" ) and getattr (
5656 candidate .content , "parts" , []
5757 ):
Original file line number Diff line number Diff line change @@ -394,7 +394,7 @@ def _extract_response_text(response):
394394 # type: (GenerateContentResponse) -> Optional[List[str]]
395395 """Extract text from response candidates."""
396396
397- if not response or not hasattr (response , "candidates" ):
397+ if not response or not getattr (response , "candidates" , [] ):
398398 return None
399399
400400 texts = []
@@ -412,11 +412,11 @@ def _extract_response_text(response):
412412def extract_finish_reasons (response ):
413413 # type: (GenerateContentResponse) -> Optional[List[str]]
414414 """Extract finish reasons from response candidates."""
415- if not response or not hasattr (response , "candidates" ):
415+ if not response or not getattr (response , "candidates" , [] ):
416416 return None
417417
418418 finish_reasons = []
419- for candidate in getattr ( response , " candidates" , []) :
419+ for candidate in response . candidates :
420420 if getattr (candidate , "finish_reason" , None ):
421421 # Convert enum value to string if necessary
422422 reason = str (candidate .finish_reason )
You can’t perform that action at this time.
0 commit comments