mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-04 20:05:16 +02:00
feat(gateway): add gateway domain primitives
This commit is contained in:
parent
ae3ce91465
commit
c9b7d7b572
13 changed files with 481 additions and 0 deletions
28
surfsense_backend/app/gateway/base/translator.py
Normal file
28
surfsense_backend/app/gateway/base/translator.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
"""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."""
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue