Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Frontend] improve hermes_tool_parser.py #11444

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion vllm/entrypoints/openai/tool_parsers/hermes_tool_parser.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import re
from typing import Dict, List, Sequence, Union
from json_repair import json_repair

import partial_json_parser
from partial_json_parser.core.options import Allow
Expand Down Expand Up @@ -82,7 +83,8 @@ def extract_tool_calls(
# load the JSON, and then use it to build the Function and
# Tool Call
raw_function_calls = [
json.loads(match[0] if match[0] else match[1])
# To improve the robustness of parsing the JSON output
json_repair.loads(match[0] if match[0] else match[1])
for match in function_call_tuples
]
tool_calls = [
Expand Down
Loading