feat(chat): Add SSE format conversion method to StreamStart response model

- Implemented `to_sse` method in `StreamStart` class to convert response data into SSE format, excluding non-protocol fields.
- Removed redundant inputId declaration in ChatInput component for cleaner code.
This commit is contained in:
abhi1992002
2026-02-04 16:35:33 +05:30
parent 6fce1f6084
commit b45e1bc79c
2 changed files with 10 additions and 1 deletions

View File

@@ -57,6 +57,16 @@ class StreamStart(StreamBaseResponse):
description="Task ID for SSE reconnection. Clients can reconnect using GET /tasks/{taskId}/stream",
)
def to_sse(self) -> str:
"""Convert to SSE format, excluding non-protocol fields like taskId."""
import json
data: dict[str, Any] = {
"type": self.type.value,
"messageId": self.messageId,
}
return f"data: {json.dumps(data)}\n\n"
class StreamFinish(StreamBaseResponse):
"""End of message/stream."""

View File

@@ -29,7 +29,6 @@ export function ChatInput({
className,
inputId = "chat-input",
}: Props) {
const inputId = "chat-input";
const {
value,
setValue,