mirror of
https://github.com/karpathy/nanochat.git
synced 2026-03-07 18:00:30 +00:00
fix(chat_web): use removeprefix for SSE chunk to avoid corrupting payload when token contains 'data: '
This commit is contained in:
parent
24a74c4b7f
commit
dd10cf915d
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user