Skip to content

Commit 05d313a

Browse files
committed
fix(dspy): fix responses api handling
1 parent 02b148e commit 05d313a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

dspy/clients/base_lm.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,13 @@ def _process_response(self, response):
258258
reasoning_contents = []
259259

260260
for output_item in response.output:
261-
output_item_type = output_item.type
261+
output_item_type = output_item.type if hasattr(output_item, "type") else output_item.get("type")
262262
if output_item_type == "message":
263-
for content_item in output_item.content:
264-
text_outputs.append(content_item.text)
263+
content = output_item.content if hasattr(output_item, "content") else output_item.get("content", [])
264+
for content_item in content:
265+
text_outputs.append(
266+
content_item.text if hasattr(content_item, "text") else content_item.get("text")
267+
)
265268
elif output_item_type == "function_call":
266269
tool_calls.append(output_item.model_dump())
267270
elif output_item_type == "reasoning":

0 commit comments

Comments
 (0)