Skip to content

Commit 41d5af9

Browse files
committed
[Bugfix] Fix the bug in Hermes streaming parsing
Signed-off-by: zxy <zx0823y@163.com>
1 parent 6fb1624 commit 41d5af9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

vllm/entrypoints/openai/tool_parsers/hermes_tool_parser.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import partial_json_parser
99
import regex as re
1010
from partial_json_parser.core.options import Allow
11+
from json_repair import repair_json
1112

1213
from vllm.entrypoints.chat_utils import random_tool_call_id
1314
from vllm.entrypoints.openai.protocol import (ChatCompletionRequest,
@@ -237,6 +238,9 @@ def extract_tool_calls_streaming(
237238
return delta
238239

239240
try:
241+
if tool_call_portion is not None:
242+
# repair the JSON if needed
243+
tool_call_portion = repair_json(tool_call_portion)
240244

241245
current_tool_call = partial_json_parser.loads(
242246
tool_call_portion or "{}",

0 commit comments

Comments
 (0)