From 3f8ec155e7a9ba0dbfdd2bc8056aa3b65ae72f56 Mon Sep 17 00:00:00 2001 From: Yuanzhang Hu Date: Fri, 26 Apr 2024 21:42:23 -0400 Subject: [PATCH] fixed json parsing error for ping result in stream --- chatgpt/chatResponse.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chatgpt/chatResponse.py b/chatgpt/chatResponse.py index 8632045..3d1c7aa 100644 --- a/chatgpt/chatResponse.py +++ b/chatgpt/chatResponse.py @@ -5,6 +5,7 @@ import random import string import time import uuid +import traceback from api.chat_completions import model_system_fingerprint, split_tokens_from_content from utils.Logger import Logger @@ -103,7 +104,7 @@ async def stream_response(service, response, model, max_tokens): try: if chunk.startswith("data: [DONE]"): yield "data: [DONE]\n\n" - elif not chunk.startswith("data: "): + elif not chunk.startswith("data: {"): continue else: chunk_old_data = json.loads(chunk[6:])