Add parameter schema and defaults to ToolResource model and schemas. Implement runtime tool resolution in assistants and tools routers, ensuring proper handling of tool parameters. Update tests to validate new functionality and ensure correct integration of parameter handling in the API.
This commit is contained in:
@@ -187,6 +187,17 @@ async def execute_server_tool(
|
||||
tool_name = _extract_tool_name(tool_call)
|
||||
args = _extract_tool_args(tool_call)
|
||||
resource_fetcher = tool_resource_fetcher or fetch_tool_resource
|
||||
resource: Optional[Dict[str, Any]] = None
|
||||
if tool_name and tool_name not in {"calculator", "code_interpreter", "current_time"}:
|
||||
try:
|
||||
resource = await resource_fetcher(tool_name)
|
||||
except Exception:
|
||||
resource = None
|
||||
defaults = resource.get("parameter_defaults") if isinstance(resource, dict) else None
|
||||
if isinstance(defaults, dict) and defaults:
|
||||
merged_args = dict(defaults)
|
||||
merged_args.update(args)
|
||||
args = merged_args
|
||||
|
||||
if tool_name == "calculator":
|
||||
expression = str(args.get("expression") or "").strip()
|
||||
@@ -269,7 +280,6 @@ async def execute_server_tool(
|
||||
}
|
||||
|
||||
if tool_name and tool_name not in {"calculator", "code_interpreter", "current_time"}:
|
||||
resource = await resource_fetcher(tool_name)
|
||||
if resource and str(resource.get("category") or "") == "query":
|
||||
method = str(resource.get("http_method") or "GET").strip().upper()
|
||||
if method not in {"GET", "POST", "PUT", "PATCH", "DELETE"}:
|
||||
|
||||
Reference in New Issue
Block a user