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):
51
51
for chunk in chunks :
52
52
# Extract text and tool calls
53
53
if getattr (chunk , "candidates" , None ):
54
- for candidate in chunk . candidates :
54
+ for candidate in getattr ( chunk , " candidates" , []) :
55
55
if hasattr (candidate , "content" ) and getattr (
56
56
candidate .content , "parts" , []
57
57
):
Original file line number Diff line number Diff line change @@ -394,7 +394,7 @@ def _extract_response_text(response):
394
394
# type: (GenerateContentResponse) -> Optional[List[str]]
395
395
"""Extract text from response candidates."""
396
396
397
- if not response or not hasattr (response , "candidates" ):
397
+ if not response or not getattr (response , "candidates" , [] ):
398
398
return None
399
399
400
400
texts = []
@@ -412,11 +412,11 @@ def _extract_response_text(response):
412
412
def extract_finish_reasons (response ):
413
413
# type: (GenerateContentResponse) -> Optional[List[str]]
414
414
"""Extract finish reasons from response candidates."""
415
- if not response or not hasattr (response , "candidates" ):
415
+ if not response or not getattr (response , "candidates" , [] ):
416
416
return None
417
417
418
418
finish_reasons = []
419
- for candidate in getattr ( response , " candidates" , []) :
419
+ for candidate in response . candidates :
420
420
if getattr (candidate , "finish_reason" , None ):
421
421
# Convert enum value to string if necessary
422
422
reason = str (candidate .finish_reason )
You can’t perform that action at this time.
0 commit comments