mirror of
https://github.com/vllm-project/vllm.git
synced 2025-10-20 23:03:52 +08:00
Gracefully handle edge cases in harmony utils (#23155)
Signed-off-by: Jan Kessler <jakessle@uni-mainz.de> Co-authored-by: Chen Zhang <zhangch99@outlook.com> Co-authored-by: Cyrus Leung <tlleungac@connect.ust.hk>
This commit is contained in:
@ -155,7 +155,7 @@ def parse_chat_input(chat_msg) -> Message:
|
|||||||
contents = [TextContent(text=content)]
|
contents = [TextContent(text=content)]
|
||||||
else:
|
else:
|
||||||
# TODO: Support refusal.
|
# TODO: Support refusal.
|
||||||
contents = [TextContent(text=c["text"]) for c in content]
|
contents = [TextContent(text=c.get("text", "")) for c in content]
|
||||||
msg = Message.from_role_and_contents(role, contents)
|
msg = Message.from_role_and_contents(role, contents)
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
@ -218,8 +218,8 @@ def parse_output_message(message: Message) -> list[ResponseOutputItem]:
|
|||||||
)
|
)
|
||||||
output_items.append(reasoning_item)
|
output_items.append(reasoning_item)
|
||||||
elif message.channel == "commentary":
|
elif message.channel == "commentary":
|
||||||
if message.recipient.startswith("functions."):
|
if recipient is not None and recipient.startswith("functions."):
|
||||||
function_name = message.recipient.split(".")[-1]
|
function_name = recipient.split(".")[-1]
|
||||||
for content in message.content:
|
for content in message.content:
|
||||||
random_id = random_uuid()
|
random_id = random_uuid()
|
||||||
response_item = ResponseFunctionToolCall(
|
response_item = ResponseFunctionToolCall(
|
||||||
@ -230,8 +230,8 @@ def parse_output_message(message: Message) -> list[ResponseOutputItem]:
|
|||||||
id=f"ft_{random_id}",
|
id=f"ft_{random_id}",
|
||||||
)
|
)
|
||||||
output_items.append(response_item)
|
output_items.append(response_item)
|
||||||
elif message.recipient.startswith(
|
elif recipient is not None and (recipient.startswith("python")
|
||||||
"python") or message.recipient.startswith("browser"):
|
or recipient.startswith("browser")):
|
||||||
for content in message.content:
|
for content in message.content:
|
||||||
reasoning_item = ResponseReasoningItem(
|
reasoning_item = ResponseReasoningItem(
|
||||||
id=f"rs_{random_uuid()}",
|
id=f"rs_{random_uuid()}",
|
||||||
@ -245,7 +245,7 @@ def parse_output_message(message: Message) -> list[ResponseOutputItem]:
|
|||||||
)
|
)
|
||||||
output_items.append(reasoning_item)
|
output_items.append(reasoning_item)
|
||||||
else:
|
else:
|
||||||
raise ValueError(f"Unknown recipient: {message.recipient}")
|
raise ValueError(f"Unknown recipient: {recipient}")
|
||||||
elif message.channel == "final":
|
elif message.channel == "final":
|
||||||
contents = []
|
contents = []
|
||||||
for content in message.content:
|
for content in message.content:
|
||||||
|
Reference in New Issue
Block a user