@@ -58,18 +58,14 @@ def __init__(self, tokenizer):
58
58
self .tool_call_start_token_id = self .vocab .get (self .tool_call_start_token )
59
59
self .tool_call_end_token_id = self .vocab .get (self .tool_call_end_token )
60
60
if self .tool_call_start_token_id is None or self .tool_call_end_token_id is None :
61
- raise RuntimeError (
62
- "Hermes 2 Pro Tool parser could not locate tool call start/end " "tokens in the tokenizer!"
63
- )
61
+ raise RuntimeError ("Ernie x1 Tool parser could not locate tool call start/end " "tokens in the tokenizer!" )
64
62
65
63
if not self .model_tokenizer :
66
64
raise ValueError (
67
65
"The model tokenizer must be passed to the ToolCallParser constructor during construction."
68
66
)
69
67
70
- def extract_tool_calls (
71
- self , model_output : str , request : ChatCompletionRequest , model_status : str
72
- ) -> ExtractedToolCallInformation :
68
+ def extract_tool_calls (self , model_output : str , request : ChatCompletionRequest ) -> ExtractedToolCallInformation :
73
69
"""
74
70
Extract the tool calls from a complete model response.
75
71
Supports XML-style formats with newlines:
@@ -81,13 +77,10 @@ def extract_tool_calls(
81
77
3. Only name and arguments field without content: {"name": "get_weather", "argume
82
78
"""
83
79
84
- extract_content = model_output
85
- if model_status == "tool_call_start" :
86
- extract_content = "<tool_call>" + model_output
87
80
try :
88
- if self .tool_call_start_token not in extract_content :
81
+ if self .tool_call_start_token not in model_output :
89
82
return ExtractedToolCallInformation (tools_called = False , tool_calls = [], content = model_output )
90
- function_call_tuples = self .tool_call_regex .findall (extract_content )
83
+ function_call_tuples = self .tool_call_regex .findall (model_output )
91
84
92
85
raw_function_calls = [json .loads (match [0 ] if match [0 ] else match [1 ]) for match in function_call_tuples ]
93
86
@@ -116,7 +109,6 @@ def extract_tool_calls_streaming(
116
109
current_token_ids : Sequence [int ],
117
110
delta_token_ids : Sequence [int ],
118
111
request : dict ,
119
- model_status : str ,
120
112
) -> Union [DeltaMessage , None ]:
121
113
122
114
if self .tool_call_start_token_id not in current_token_ids :
0 commit comments