File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -605,6 +605,15 @@ def _build_request_log(req: LlmRequest) -> str:
605605"""
606606
607607
608+ def _safe_response_text (resp : types .GenerateContentResponse ) -> str :
609+ """Extracts text from a response without triggering UserWarning on tool-call responses."""
610+ try :
611+ parts = resp .candidates [0 ].content .parts
612+ except (AttributeError , IndexError , TypeError ):
613+ return ''
614+ return '' .join (part .text for part in parts if part .text is not None )
615+
616+
608617def _build_response_log (resp : types .GenerateContentResponse ) -> str :
609618 function_calls_text = []
610619 if function_calls := resp .function_calls :
@@ -616,7 +625,7 @@ def _build_response_log(resp: types.GenerateContentResponse) -> str:
616625LLM Response:
617626-----------------------------------------------------------
618627Text:
619- { resp . text }
628+ { _safe_response_text ( resp ) }
620629-----------------------------------------------------------
621630Function calls:
622631{ _NEW_LINE .join (function_calls_text )}
You can’t perform that action at this time.
0 commit comments