ForcePilot/backend/package/yuxi/channels/protocols/streaming.py

30 lines
990 B
Python
Raw Normal View History

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: ...