From 05d313a0a2dd7f88ab8bd7ce84239352bd1794a5 Mon Sep 17 00:00:00 2001 From: Ninja3047 <1284324+Ninja3047@users.noreply.github.com> Date: Tue, 25 Nov 2025 15:51:44 -0500 Subject: [PATCH] fix(dspy): fix responses api handling --- dspy/clients/base_lm.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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":