mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Fix: Add Knowledge Base Document Parsing Status Check (#5966)
When creating and updating chats, add a check for the parsing status of knowledge base documents. Ensure that all documents have been parsed before allowing chat creation to improve user experience and system stability. **Main Changes:** - Add document parsing status check logic in `chat.py`. - Implement the `is_parsed_done` method in `knowledgebase_service.py`. - Prevent chat creation when documents are being parsed or parsing has failed. ### What problem does this PR solve? fix this bug:https://github.com/infiniflow/ragflow/issues/5960 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) Co-authored-by: wenju.li <wenju.li@deepctr.cn>
This commit is contained in:
@ -40,6 +40,12 @@ def create(tenant_id):
|
||||
kb = kbs[0]
|
||||
if kb.chunk_num == 0:
|
||||
return get_error_data_result(f"The dataset {kb_id} doesn't own parsed file")
|
||||
|
||||
# Check if all documents in the knowledge base have been parsed
|
||||
is_done, error_msg = KnowledgebaseService.is_parsed_done(kb_id)
|
||||
if not is_done:
|
||||
return get_error_data_result(error_msg)
|
||||
|
||||
kbs = KnowledgebaseService.get_by_ids(ids) if ids else []
|
||||
embd_ids = [TenantLLMService.split_model_name_and_factory(kb.embd_id)[0] for kb in kbs] # remove vendor suffix for comparison
|
||||
embd_count = list(set(embd_ids))
|
||||
@ -176,6 +182,12 @@ def update(tenant_id, chat_id):
|
||||
kb = kbs[0]
|
||||
if kb.chunk_num == 0:
|
||||
return get_error_data_result(f"The dataset {kb_id} doesn't own parsed file")
|
||||
|
||||
# Check if all documents in the knowledge base have been parsed
|
||||
is_done, error_msg = KnowledgebaseService.is_parsed_done(kb_id)
|
||||
if not is_done:
|
||||
return get_error_data_result(error_msg)
|
||||
|
||||
kbs = KnowledgebaseService.get_by_ids(ids)
|
||||
embd_ids = [TenantLLMService.split_model_name_and_factory(kb.embd_id)[0] for kb in kbs] # remove vendor suffix for comparison
|
||||
embd_count = list(set(embd_ids))
|
||||
|
||||
Reference in New Issue
Block a user