mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-13 14:10:59 +00:00
weknora2
This commit is contained in:
@@ -114,9 +114,13 @@ class AsyncWeKnoraClient:
|
|||||||
continue
|
continue
|
||||||
if chunk.startswith('data:'):
|
if chunk.startswith('data:'):
|
||||||
try:
|
try:
|
||||||
yield json.loads(chunk[5:].strip())
|
data = json.loads(chunk[5:].strip())
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
continue
|
continue
|
||||||
|
yield data
|
||||||
|
# 收到 error 事件后主动结束流,避免上层未 raise 时持续等待
|
||||||
|
if data.get('response_type') == 'error':
|
||||||
|
return
|
||||||
|
|
||||||
async def knowledge_chat(
|
async def knowledge_chat(
|
||||||
self,
|
self,
|
||||||
@@ -167,6 +171,10 @@ class AsyncWeKnoraClient:
|
|||||||
continue
|
continue
|
||||||
if chunk.startswith('data:'):
|
if chunk.startswith('data:'):
|
||||||
try:
|
try:
|
||||||
yield json.loads(chunk[5:].strip())
|
data = json.loads(chunk[5:].strip())
|
||||||
except json.JSONDecodeError:
|
except json.JSONDecodeError:
|
||||||
continue
|
continue
|
||||||
|
yield data
|
||||||
|
# 收到 error 事件后主动结束流,避免上层未 raise 时持续等待
|
||||||
|
if data.get('response_type') == 'error':
|
||||||
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user