[Bugfix] Responses API assistant EasyInputMessageParam input (#44361)
Signed-off-by: Yifan Zong <yzong@redhat.com> Co-authored-by: Ben Browning <bbrownin@redhat.com>
This commit is contained in:
@@ -306,6 +306,20 @@ def _construct_message_from_response_item(
|
||||
content=item.get("output"),
|
||||
tool_call_id=item.get("call_id"),
|
||||
)
|
||||
elif isinstance(item, dict) and item.get("role") == "assistant":
|
||||
content = item.get("content")
|
||||
text: str | None = None
|
||||
if isinstance(content, str):
|
||||
text = content
|
||||
elif isinstance(content, list) and content:
|
||||
text = content[0].get("text")
|
||||
if text is not None:
|
||||
if prev_assistant_msg:
|
||||
previous_content = prev_assistant_msg.get("content")
|
||||
if previous_content is None:
|
||||
prev_assistant_msg["content"] = text
|
||||
return None
|
||||
return {"role": "assistant", "content": text}
|
||||
return item # type: ignore[arg-type]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user