File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
vllm/entrypoints/openai/tool_parsers Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -108,10 +108,11 @@ def extract_tool_calls(
108
108
if not potential_tool_calls :
109
109
# some text should be filtered out for no function call
110
110
# this text is in a13b's chat template.
111
- cleaned_output = content .replace ("助手:" , "" , 1 )
111
+ if content :
112
+ content = content .replace ("助手:" , "" , 1 )
112
113
return ExtractedToolCallInformation (tools_called = False ,
113
114
tool_calls = [],
114
- content = cleaned_output )
115
+ content = content )
115
116
116
117
# Parse the potential tool calls as JSON
117
118
tool_calls_data = json .loads (potential_tool_calls )
@@ -145,10 +146,15 @@ def extract_tool_calls(
145
146
tool_calls .append (tool_call )
146
147
147
148
logger .debug ("exit in last position." )
149
+
150
+ if content and len (content .strip ()) == 0 :
151
+ # clear the whitespace content.
152
+ content = None
153
+
148
154
return ExtractedToolCallInformation (
149
155
tools_called = len (tool_calls ) > 0 ,
150
156
tool_calls = tool_calls ,
151
- content = content if len ( content . strip ()) > 0 else None ,
157
+ content = content ,
152
158
)
153
159
154
160
except Exception as e :
You can’t perform that action at this time.
0 commit comments