1. 新增ChannelStreamingProtocol协议的打字指示器、消息编辑支持和 fallback 发送方法 2. 重构SDK导入顺序,调整normalizer和retry的导入位置 3. 新增错误分类模块,实现异常类型归类逻辑 4. 新增SessionRouter抽象基类,实现基础会话路由逻辑 5. 增强重试SDK,添加总超时、熔断和指标回调支持
30 lines
990 B
Python
30 lines
990 B
Python
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING, Protocol, runtime_checkable
|
|
|
|
if TYPE_CHECKING:
|
|
from yuxi.channels.models import DeliveryResult
|
|
|
|
|
|
@runtime_checkable
|
|
class ChannelStreamingProtocol(Protocol):
|
|
@property
|
|
def streaming_modes(self) -> list[str]: ...
|
|
|
|
@property
|
|
def block_streaming(self) -> bool: ...
|
|
|
|
@property
|
|
def supports_typing_indicator(self) -> bool:
|
|
return getattr(self, "capabilities", None) is not None and getattr(self.capabilities, "typing", False)
|
|
|
|
@property
|
|
def supports_message_edit(self) -> bool:
|
|
return getattr(self, "capabilities", None) is not None and getattr(self.capabilities, "edit", False)
|
|
|
|
async def send_stream_chunk(self, chat_id: str, msg_id: str, chunk: str, finished: bool) -> DeliveryResult: ...
|
|
|
|
async def send_typing_indicator(self, chat_id: str, active: bool) -> DeliveryResult: ...
|
|
|
|
async def fallback_send(self, chat_id: str, text: str) -> DeliveryResult: ...
|