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
+24 -17
View File
@@ -5,6 +5,7 @@ from types import SimpleNamespace
from fastapi import HTTPException
from routes.assistants import _validate_startup_actions
from models import RuntimeToolBinding
from schemas import AssistantUpsert
from services.config_resolver import _runtime_tool_ids
@@ -18,25 +19,28 @@ def startup_body(
name="启动动作测试",
type="prompt",
runtimeMode="pipeline",
toolIds=["tool_message"] if bind_tool else [],
toolBindings=(
[{"toolId": "tool_message", "argumentBindings": {}}]
if bind_tool
else []
),
startup={
"executionMode": "sequential",
"actions": [
{
"id": "opening_message",
"phase": phase,
"toolId": "tool_message",
"arguments": {
"title": "重要提示",
"message": "请确认已阅读。",
"actions": [
{
"id": "confirmed",
"label": "确认",
"style": "primary",
}
],
"dismissible": False,
"toolBinding": {
"toolId": "tool_message",
"argumentBindings": {
"title": {"source": "literal", "value": "重要提示"},
"message": {"source": "literal", "value": "请确认已阅读。"},
"actions": {
"source": "literal",
"value": [{"id": "confirmed", "label": "确认", "style": "primary"}],
},
"dismissible": {"source": "literal", "value": False},
},
},
"required": True,
}
@@ -57,11 +61,14 @@ class StartupActionValidationTests(unittest.IsolatedAsyncioTestCase):
def test_runtime_pool_includes_bound_and_startup_only_tools(self):
self.assertEqual(
_runtime_tool_ids(
["conversation_tool", "shared_tool"],
[
RuntimeToolBinding(tool_id="conversation_tool"),
RuntimeToolBinding(tool_id="shared_tool"),
],
{
"actions": [
{"tool_id": "opening_tool"},
{"toolId": "shared_tool"},
{"toolBinding": {"toolId": "opening_tool"}},
{"toolBinding": {"toolId": "shared_tool"}},
]
},
),
@@ -129,7 +136,7 @@ class StartupActionValidationTests(unittest.IsolatedAsyncioTestCase):
body = startup_body(bind_tool=False)
await _validate_startup_actions(FakeSession(tool), body)
self.assertEqual(body.tool_ids, [])
self.assertEqual(body.tool_bindings, [])
async def test_show_message_requires_session_wait(self):
tool = SimpleNamespace(