ййй
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
|
||||
from app.modules.agent_api.domain.events.client_event import ClientEventRecord
|
||||
|
||||
|
||||
class SseEncoder:
|
||||
def encode(self, event: ClientEventRecord) -> str:
|
||||
payload = {
|
||||
"event_id": event.event_id,
|
||||
"request_id": event.request_id,
|
||||
"type": event.type.value,
|
||||
"source": event.source,
|
||||
"text": event.text,
|
||||
"payload": event.payload,
|
||||
"created_at": event.created_at.isoformat(),
|
||||
}
|
||||
return f"event: {event.type.value}\ndata: {json.dumps(payload, ensure_ascii=False)}\n\n"
|
||||
Reference in New Issue
Block a user