From b45e1bc79c51d546f90954bddc5064f652e26bfe Mon Sep 17 00:00:00 2001 From: abhi1992002 Date: Wed, 4 Feb 2026 16:35:33 +0530 Subject: [PATCH] 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. --- .../backend/api/features/chat/response_model.py | 10 ++++++++++ .../contextual/Chat/components/ChatInput/ChatInput.tsx | 1 - 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/autogpt_platform/backend/backend/api/features/chat/response_model.py b/autogpt_platform/backend/backend/api/features/chat/response_model.py index e93795fbd5..e04218ea87 100644 --- a/autogpt_platform/backend/backend/api/features/chat/response_model.py +++ b/autogpt_platform/backend/backend/api/features/chat/response_model.py @@ -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.""" diff --git a/autogpt_platform/frontend/src/components/contextual/Chat/components/ChatInput/ChatInput.tsx b/autogpt_platform/frontend/src/components/contextual/Chat/components/ChatInput/ChatInput.tsx index 430a3bd507..dd4adc46fa 100644 --- a/autogpt_platform/frontend/src/components/contextual/Chat/components/ChatInput/ChatInput.tsx +++ b/autogpt_platform/frontend/src/components/contextual/Chat/components/ChatInput/ChatInput.tsx @@ -29,7 +29,6 @@ export function ChatInput({ className, inputId = "chat-input", }: Props) { - const inputId = "chat-input"; const { value, setValue,