update knowledge_base_chat and search_engine_chat: yield chinese correctly

This commit is contained in:
liunux4odoo 2023-08-09 22:54:37 +08:00
parent ba3335efb8
commit db29a2fea7
2 changed files with 2 additions and 2 deletions

View File

@ -69,7 +69,7 @@ def knowledge_base_chat(query: str = Body(..., description="用户输入", examp
async for token in callback.aiter(): async for token in callback.aiter():
# Use server-sent-events to stream the response # Use server-sent-events to stream the response
yield json.dumps({"answer": token, yield json.dumps({"answer": token,
"docs": source_documents}) "docs": source_documents}, ensure_ascii=False)
await task await task
return StreamingResponse(knowledge_base_chat_iterator(query, kb, top_k, history), return StreamingResponse(knowledge_base_chat_iterator(query, kb, top_k, history),

View File

@ -109,7 +109,7 @@ def search_engine_chat(query: str = Body(..., description="用户输入", exampl
async for token in callback.aiter(): async for token in callback.aiter():
# Use server-sent-events to stream the response # Use server-sent-events to stream the response
yield json.dumps({"answer": token, yield json.dumps({"answer": token,
"docs": source_documents}) "docs": source_documents}, ensure_ascii=False)
await task await task
return StreamingResponse(search_engine_chat_iterator(query, search_engine_name, top_k, history), return StreamingResponse(search_engine_chat_iterator(query, search_engine_name, top_k, history),