[Bugfix] Fix Qwen3 tool parser for Responses API tools (#38848)
Signed-off-by: sfeng33 <4florafeng@gmail.com>
This commit is contained in:
@@ -26,6 +26,7 @@ from vllm.tool_parsers.abstract_tool_parser import (
|
||||
Tool,
|
||||
ToolParser,
|
||||
)
|
||||
from vllm.tool_parsers.utils import find_tool_properties
|
||||
|
||||
logger = init_logger(__name__)
|
||||
|
||||
@@ -1000,33 +1001,11 @@ class StreamingXMLToolCallParser:
|
||||
if not self.tools or not self.current_function_name:
|
||||
return "string"
|
||||
|
||||
for tool in self.tools:
|
||||
if not hasattr(tool, "type") or not (
|
||||
hasattr(tool, "function") and hasattr(tool.function, "name")
|
||||
):
|
||||
continue
|
||||
if (
|
||||
tool.type == "function"
|
||||
and tool.function.name == self.current_function_name
|
||||
):
|
||||
if not hasattr(tool.function, "parameters"):
|
||||
return "string"
|
||||
params = tool.function.parameters
|
||||
if isinstance(params, dict) and "properties" in params:
|
||||
properties = params["properties"]
|
||||
if param_name in properties and isinstance(
|
||||
properties[param_name], dict
|
||||
):
|
||||
return self.repair_param_type(
|
||||
str(properties[param_name].get("type", "string"))
|
||||
)
|
||||
elif isinstance(params, dict) and param_name in params:
|
||||
param_config = params[param_name]
|
||||
if isinstance(param_config, dict):
|
||||
return self.repair_param_type(
|
||||
str(param_config.get("type", "string"))
|
||||
)
|
||||
break
|
||||
properties = find_tool_properties(self.tools, self.current_function_name)
|
||||
if param_name in properties and isinstance(properties[param_name], dict):
|
||||
return self.repair_param_type(
|
||||
str(properties[param_name].get("type", "string"))
|
||||
)
|
||||
return "string"
|
||||
|
||||
def repair_param_type(self, param_type: str) -> str:
|
||||
|
||||
Reference in New Issue
Block a user