RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Fix (api): fix the document parsing status check logic (#12504)
天海蒼灆983150b936c1
diff --git a/api/apps/sdk/doc.py b/api/apps/sdk/doc.pyindex a52c415a58..3f0295e569 100644--- a/api/apps/sdk/doc.py+++ b/api/apps/sdk/doc.py@@ -866,7 +866,7 @@ async def parse(tenant_id, dataset_id):continueif not doc:return get_error_data_result(message=f"You don't own the document {id}.")- if 0.0 < doc[0].progress < 1.0:+ if doc[0].run == TaskStatus.RUNNING.value:return get_error_data_result("Can't parse document that is currently being processed")info = {"run": "1", "progress": 0, "progress_msg": "", "chunk_num": 0, "token_num": 0}DocumentService.update_by_id(id, info)@@ -946,8 +946,8 @@ async def stop_parsing(tenant_id, dataset_id):doc = DocumentService.query(id=id, kb_id=dataset_id)if not doc:return get_error_data_result(message=f"You don't own the document {id}.")- if int(doc[0].progress) == 1 or doc[0].progress == 0:- return get_error_data_result("Can't stop parsing document with progress at 0 or 1")+ if doc[0].run != TaskStatus.RUNNING.value :+ return get_error_data_result("Can't stop parsing document that has not started or already completed")# Send cancellation signal via Redis to stop background taskcancel_all_task_of(id)info = {"run": "2", "progress": 0, "chunk_num": 0}diff --git a/sdk/python/test/test_http_api/test_file_management_within_dataset/test_stop_parse_documents.py b/sdk/python/test/test_http_api/test_file_management_within_dataset/test_stop_parse_documents.pynew file mode 100644index 0000000000..e69de29bb2diff --git a/test/testcases/test_http_api/test_file_management_within_dataset/test_stop_parse_documents.py b/test/testcases/test_http_api/test_file_management_within_dataset/test_stop_parse_documents.pyindex 67d89c8153..a79e1c6d18 100644--- a/test/testcases/test_http_api/test_file_management_within_dataset/test_stop_parse_documents.py+++ b/test/testcases/test_http_api/test_file_management_within_dataset/test_stop_parse_documents.py@@ -157,7 +157,7 @@ class TestDocumentsParseStop:res = stop_parse_documents(HttpApiAuth, dataset_id, {"document_ids": document_ids})assert res["code"] == 102- assert res["message"] == "Can't stop parsing document with progress at 0 or 1"+ assert res["message"] == "Can't stop parsing document that has not started or already completed"@pytest.mark.p3def test_duplicate_stop_parse(self, HttpApiAuth, add_documents_func):