feat: organize tools and enable qwen realtime calls

This commit is contained in:
Xin Wang
2026-08-14 00:15:00 +08:00
parent eb111a3890
commit 5be21f5ccc
71 changed files with 5771 additions and 2026 deletions
+25 -7
View File
@@ -1,6 +1,6 @@
import unittest
from models import RuntimeMcpServer, RuntimeTool
from models import RuntimeMcpServer, RuntimeTool, RuntimeToolBinding
from services.runtime_variables import DynamicVariableStore
from services.tool_executor import ToolExecutionError, ToolExecutor
from services.tools import McpClientError
@@ -28,16 +28,13 @@ def mcp_tool() -> RuntimeTool:
},
"required": ["order_id"],
},
"dynamic_variable_assignments": {
"order_status": "structuredContent.status"
},
},
},
mcp_server=RuntimeMcpServer(
id="mcp_orders",
name="订单服务",
url="https://mcp.example.com/{{tenant}}",
headers={"X-Tenant": "{{tenant}}"},
url="https://mcp.example.com/{{input__tenant}}",
headers={"X-Tenant": "{{input__tenant}}"},
secret_headers={"Authorization": "Bearer secret"},
),
)
@@ -77,6 +74,14 @@ class ToolExecutorMcpTests(unittest.IsolatedAsyncioTestCase):
result = await executor.execute(
mcp_tool(),
{"order_id": "A-100"},
binding=RuntimeToolBinding(
toolId="tool_mcp_order",
argumentBindings={"order_id": {"source": "model"}},
templateBindings={
"tenant": {"source": "variable", "variableName": "tenant"}
},
resultAssignments={"order_status": "structuredContent.status"},
),
)
self.assertEqual(result["status"], "ok")
@@ -98,7 +103,20 @@ class ToolExecutorMcpTests(unittest.IsolatedAsyncioTestCase):
)
with self.assertRaisesRegex(ToolExecutionError, "远端不可用"):
await executor.execute(mcp_tool(), {"order_id": "A-100"})
await executor.execute(
mcp_tool(),
{"order_id": "A-100"},
binding=RuntimeToolBinding(
toolId="tool_mcp_order",
argumentBindings={"order_id": {"source": "model"}},
templateBindings={
"tenant": {
"source": "variable",
"variableName": "tenant",
}
},
),
)
if __name__ == "__main__":