update api.py

This commit is contained in:
imClumsyPanda 2023-05-13 21:35:17 +08:00
parent 80854c4bcd
commit 3ff885d0d3
1 changed files with 24 additions and 18 deletions

12
api.py
View File

@ -181,7 +181,7 @@ async def delete_docs(
if os.path.exists(doc_path):
os.remove(doc_path)
else:
return {"code": 1, "msg": f"document {doc_name} not found"}
BaseResponse(code=1, msg=f"document {doc_name} not found")
remain_docs = await list_docs(knowledge_base_id)
if remain_docs["code"] != 0 or len(remain_docs["data"]) == 0:
@ -211,8 +211,14 @@ async def local_doc_chat(
):
vs_path = os.path.join(VS_ROOT_PATH, knowledge_base_id)
if not os.path.exists(vs_path):
raise ValueError(f"Knowledge base {knowledge_base_id} not found")
# return BaseResponse(code=1, msg=f"Knowledge base {knowledge_base_id} not found")
return ChatMessage(
question=question,
response=f"Knowledge base {knowledge_base_id} not found",
history=history,
source_documents=[],
)
else:
for resp, history in local_doc_qa.get_knowledge_based_answer(
query=question, vs_path=vs_path, chat_history=history, streaming=True
):