diff --git a/dspy/clients/base_lm.py b/dspy/clients/base_lm.py index e8b893a09d..6f58fe5fad 100644 --- a/dspy/clients/base_lm.py +++ b/dspy/clients/base_lm.py @@ -258,10 +258,13 @@ def _process_response(self, response): reasoning_contents = [] for output_item in response.output: - output_item_type = output_item.type + output_item_type = output_item.type if hasattr(output_item, "type") else output_item.get("type") if output_item_type == "message": - for content_item in output_item.content: - text_outputs.append(content_item.text) + content = output_item.content if hasattr(output_item, "content") else output_item.get("content", []) + for content_item in content: + text_outputs.append( + content_item.text if hasattr(content_item, "text") else content_item.get("text") + ) elif output_item_type == "function_call": tool_calls.append(output_item.model_dump()) elif output_item_type == "reasoning":