From 448c99f969f22c23abcf3ec1b8646dad73d15960 Mon Sep 17 00:00:00 2001 From: liunux4odoo <41217877+liunux4odoo@users.noreply.github.com> Date: Tue, 9 Jan 2024 09:14:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=BF=87=E6=BB=A4=20sse=5Fstarlette=20?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E7=9A=84=20ping=20=E5=8C=85=EF=BC=8C?= =?UTF-8?q?=E9=81=BF=E5=85=8D=20`JSON=20Decoder=20error=20:=20ping=20-...`?= =?UTF-8?q?=20(#2585)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/model_workers/minimax.py | 2 +- webui_pages/utils.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/server/model_workers/minimax.py b/server/model_workers/minimax.py index 947782a..deae07e 100644 --- a/server/model_workers/minimax.py +++ b/server/model_workers/minimax.py @@ -73,7 +73,7 @@ class MiniMaxWorker(ApiModelWorker): with response as r: text = "" for e in r.iter_text(): - if not e.startswith("data: "): # 真是优秀的返回 + if not e.startswith("data: "): data = { "error_code": 500, "text": f"minimax返回错误的结果:{e}", diff --git a/webui_pages/utils.py b/webui_pages/utils.py index 2f642d8..4426d7d 100644 --- a/webui_pages/utils.py +++ b/webui_pages/utils.py @@ -135,6 +135,8 @@ class ApiRequest: try: if chunk.startswith("data: "): data = json.loads(chunk[6:-2]) + elif chunk.startswith(":"): # skip sse comment line + continue else: data = json.loads(chunk) yield data @@ -169,6 +171,8 @@ class ApiRequest: try: if chunk.startswith("data: "): data = json.loads(chunk[6:-2]) + elif chunk.startswith(":"): # skip sse comment line + continue else: data = json.loads(chunk) yield data