File tree Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Expand file tree Collapse file tree 1 file changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -1321,12 +1321,7 @@ def _parse_tool_calls_from_content(
13211321 content : str | None = None ,
13221322 ) -> tuple [list [FunctionCall ] | None , str | None ]:
13231323 function_calls = list [FunctionCall ]()
1324- if request .tool_choice is None :
1325- # No tool calls.
1326- return None , content
1327- elif request .tool_choice and isinstance (
1328- request .tool_choice , ToolChoiceFunction
1329- ):
1324+ if request .tool_choice and isinstance (request .tool_choice , ToolChoiceFunction ):
13301325 assert content is not None
13311326 # Forced Function Call
13321327 function_calls .append (
@@ -1355,8 +1350,11 @@ def _parse_tool_calls_from_content(
13551350 ]
13561351 )
13571352 content = None # Clear content since tool is called.
1358- elif request .tool_choice == "auto" or request .tool_choice == "none" :
1359- assert tool_parser_cls is not None
1353+ elif (
1354+ tool_parser_cls
1355+ and enable_auto_tools
1356+ and (request .tool_choice == "auto" or request .tool_choice is None )
1357+ ):
13601358 # Automatic Tool Call Parsing
13611359 try :
13621360 tool_parser = tool_parser_cls (tokenizer )
@@ -1380,8 +1378,7 @@ def _parse_tool_calls_from_content(
13801378 else :
13811379 # No tool calls.
13821380 return None , content
1383- else :
1384- raise ValueError (f"Invalid tool_choice: { request .tool_choice } " )
1381+
13851382 return function_calls , content
13861383
13871384 @staticmethod
You can’t perform that action at this time.
0 commit comments