mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-02 19:55:18 +02:00
28 lines
826 B
Python
28 lines
826 B
Python
"""Base stream translator for platform-specific outbound UX."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from abc import ABC, abstractmethod
|
|
from collections.abc import AsyncIterator
|
|
from dataclasses import dataclass, field
|
|
from typing import Any
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class GatewayStreamEvent:
|
|
"""Small provider-neutral event shape consumed by translators.
|
|
|
|
The existing chat stack emits Vercel/assistant-ui events. Gateway code
|
|
normalizes the subset it needs into this shape before handing it to the
|
|
platform translator.
|
|
"""
|
|
|
|
type: str
|
|
data: dict[str, Any] = field(default_factory=dict)
|
|
|
|
|
|
class BaseStreamTranslator(ABC):
|
|
@abstractmethod
|
|
async def translate(self, events: AsyncIterator[GatewayStreamEvent]) -> None:
|
|
"""Consume agent stream events and emit platform messages."""
|
|
|