feat: organize tools and enable qwen realtime calls
This commit is contained in:
@@ -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__":
|
||||
|
||||
Reference in New Issue
Block a user