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
+11
View File
@@ -44,6 +44,8 @@ class _DeferredClientToolResult:
class ClientToolPort(Protocol):
def supports(self, function_name: str) -> bool: ...
async def call(
self,
function_name: str,
@@ -65,6 +67,13 @@ class ClientToolBroker(FrameProcessor):
self._deferred_results: deque[_DeferredClientToolResult] = deque()
self._interrupt_handler: Callable[[], Awaitable[None]] | None = None
self._closed_message: str | None = None
self._capabilities: frozenset[str] | None = None
def set_capabilities(self, names: set[str] | None) -> None:
self._capabilities = None if names is None else frozenset(names)
def supports(self, function_name: str) -> bool:
return self._capabilities is None or function_name in self._capabilities
def set_interrupt_handler(
self,
@@ -85,6 +94,8 @@ class ClientToolBroker(FrameProcessor):
) -> dict[str, Any]:
if self._closed_message is not None:
raise ClientToolError(self._closed_message)
if not self.supports(function_name):
raise ClientToolError(f"客户端未注册工具: {function_name}")
tool_call_id = f"client_{uuid4().hex}"
message = {