[Frontend] Support OpenAI Responses API namespace tools (#47024)
Signed-off-by: zhongjing123 <jimzhong5193@gmail.com> Co-authored-by: zhongjing123 <jimzhong5193@gmail.com>
This commit is contained in:
@@ -592,10 +592,19 @@ class ResponsesRequest(OpenAIBaseModel):
|
||||
)
|
||||
elif is_named_tool_choice and tools is not None:
|
||||
tool_name = tool_choice.get("name")
|
||||
tool_names = {
|
||||
t.get("name") if isinstance(t, dict) else getattr(t, "name", None)
|
||||
for t in tools
|
||||
}
|
||||
tool_names = set()
|
||||
for tool in tools:
|
||||
if isinstance(tool, dict):
|
||||
if tool.get("type") == "namespace":
|
||||
namespace = tool.get("name")
|
||||
for namespaced_tool in tool.get("tools", []):
|
||||
namespaced_name = namespaced_tool.get("name")
|
||||
tool_names.add(namespaced_name)
|
||||
tool_names.add(f"{namespace}__{namespaced_name}")
|
||||
else:
|
||||
tool_names.add(tool.get("name"))
|
||||
else:
|
||||
tool_names.add(getattr(tool, "name", None))
|
||||
if not tool_name or tool_name not in tool_names:
|
||||
raise VLLMValidationError(
|
||||
"Tool choice 'function' not found in 'tools' parameter.",
|
||||
|
||||
Reference in New Issue
Block a user