From dd10cf915d0629ea302fe5095ee252b50a576a11 Mon Sep 17 00:00:00 2001 From: dhunganapramod9 Date: Sat, 28 Feb 2026 01:07:55 -0500 Subject: [PATCH] fix(chat_web): use removeprefix for SSE chunk to avoid corrupting payload when token contains 'data: ' --- scripts/chat_web.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/chat_web.py b/scripts/chat_web.py index 4d4eacf..c0f9477 100644 --- a/scripts/chat_web.py +++ b/scripts/chat_web.py @@ -360,7 +360,7 @@ async def chat_completions(request: ChatRequest): top_k=request.top_k ): # Accumulate response for logging - chunk_data = json.loads(chunk.replace("data: ", "").strip()) + chunk_data = json.loads(chunk.removeprefix("data: ").strip()) if "token" in chunk_data: response_tokens.append(chunk_data["token"]) yield chunk