fix(chat_web): use removeprefix for SSE chunk to avoid corrupting payload when token contains 'data: '

This commit is contained in:
dhunganapramod9 2026-02-28 01:07:55 -05:00
parent 24a74c4b7f
commit dd10cf915d

View File

@ -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