File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -375,7 +375,7 @@ def is_input_shield(shield: Shield) -> bool:
375375 return _is_inout_shield (shield ) or not is_output_shield (shield )
376376
377377
378- async def retrieve_response ( # pylint: disable=too-many-locals
378+ async def retrieve_response ( # pylint: disable=too-many-locals,too-many-branches
379379 client : AsyncLlamaStackClient ,
380380 model_id : str ,
381381 query_request : QueryRequest ,
@@ -493,7 +493,18 @@ async def retrieve_response( # pylint: disable=too-many-locals
493493 metrics .llm_calls_validation_errors_total .inc ()
494494 break
495495
496- return str (response .output_message .content ), conversation_id # type: ignore[union-attr]
496+ output_message = getattr (response , "output_message" , None )
497+ if output_message is not None :
498+ content = getattr (output_message , "content" , None )
499+ if content is not None :
500+ return str (content ), conversation_id
501+
502+ # fallback
503+ logger .warning (
504+ "Response lacks output_message.content (conversation_id=%s)" ,
505+ conversation_id ,
506+ )
507+ return "" , conversation_id
497508
498509
499510def validate_attachments_metadata (attachments : list [Attachment ]) -> None :
You can’t perform that action at this time.
0 commit comments