This commit is contained in:
Typer_Body
2026-06-07 01:14:02 +08:00
parent 59f20bcc73
commit af451e7006

View File

@@ -114,9 +114,13 @@ class AsyncWeKnoraClient:
continue
if chunk.startswith('data:'):
try:
yield json.loads(chunk[5:].strip())
data = json.loads(chunk[5:].strip())
except json.JSONDecodeError:
continue
yield data
# 收到 error 事件后主动结束流,避免上层未 raise 时持续等待
if data.get('response_type') == 'error':
return
async def knowledge_chat(
self,
@@ -167,6 +171,10 @@ class AsyncWeKnoraClient:
continue
if chunk.startswith('data:'):
try:
yield json.loads(chunk[5:].strip())
data = json.loads(chunk[5:].strip())
except json.JSONDecodeError:
continue
yield data
# 收到 error 事件后主动结束流,避免上层未 raise 时持续等待
if data.get('response_type') == 'error':
return