Client 模块¶
核心文件¶
src/by_framework/client/client.py- GatewayClientsrc/by_framework/client/byai_client.py- ByaiGatewayClient
client/GatewayClient.java- GatewayClientclient/ByaiGatewayClient.java- ByaiGatewayClient
src/client.ts- GatewayClientsrc/byai_client.ts- ByaiGatewayClient
GatewayClient¶
向 Redis Streams 发送命令的客户端。
构造方法¶
sendMessage¶
async def send_message(
self,
target_agent_type: str,
session_id: str,
content: Any,
user_code: str = "",
action_type: str = "ASK_AGENT",
metadata: Optional[dict] = None,
target_worker_id: Optional[str] = None,
route_policy: str = RoutePolicy.FAIL_FAST, # 取代旧版 require_online_worker: bool
) -> SendMessageResponse:
route_policy 取代了 require_online_worker
旧版 require_online_worker: bool 参数已经被 route_policy 枚举取代(FAIL_FAST 大致对应旧版
True,SEND_ANYWAY 对应 False,另外还新增了 WAKE_AND_WAIT/WAKE_AND_QUEUE/QUEUE_ONLY
三种配合唤醒控制器使用的策略)。TypeScript 目前公开的 API 还是 requireOnlineWorker: boolean,
内部会转换成同样的 route_policy 协议字段;Java 两种参数都支持(requireOnlineWorker 作为向后
兼容重载)。
cancelTask¶
ByaiGatewayClient¶
GatewayClient 的封装,增加了 ByaiMessageInterceptor,支持更高级的消息协议。所有语言的 ByaiGatewayClient 都自动包含消息拦截器。