mirror of
https://github.com/open-webui/computer.git
synced 2026-11-24 14:30:22 -05:00
refac
This commit is contained in:
1 parent
33180fd4a7
commit
c9e191fea9
1 file changed
+17
-12
+17
-12
@@ -15,6 +15,7 @@ Usage::
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from copy import deepcopy
|
||||
import logging
|
||||
from contextlib import AsyncExitStack
|
||||
|
||||
@@ -118,22 +119,26 @@ class MCPClient:
|
||||
specs = []
|
||||
|
||||
for tool in result.tools:
|
||||
spec = {
|
||||
"name": tool.name,
|
||||
"description": tool.description or "",
|
||||
"parameters": {
|
||||
if tool.inputSchema is not None:
|
||||
parameters = deepcopy(tool.inputSchema)
|
||||
if not isinstance(parameters, dict):
|
||||
parameters = dict(parameters)
|
||||
parameters.setdefault("type", "object")
|
||||
parameters.setdefault("properties", {})
|
||||
else:
|
||||
parameters = {
|
||||
"type": "object",
|
||||
"properties": {},
|
||||
"required": [],
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
if tool.inputSchema:
|
||||
schema = tool.inputSchema
|
||||
spec["parameters"]["properties"] = schema.get("properties", {})
|
||||
spec["parameters"]["required"] = schema.get("required", [])
|
||||
|
||||
specs.append(spec)
|
||||
specs.append(
|
||||
{
|
||||
"name": tool.name,
|
||||
"description": tool.description or "",
|
||||
"parameters": parameters,
|
||||
}
|
||||
)
|
||||
|
||||
return specs
|
||||
|
||||
|
||||
Reference in new issue
Block a user