fix: 过滤 sse_starlette 返回的 ping 包,避免 `JSON Decoder error : ping -...` (#2585)
This commit is contained in:
parent
6f85119f03
commit
448c99f969
|
|
@ -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}",
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue