Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

fix(examples): wait for the DONE status the API actually returns (#18827)

MarMar Labsa6fdf26c37ce
diff --git a/example/sdk/chunk_example.py b/example/sdk/chunk_example.py
index 9aac7e745f..71acb5bee3 100644
--- a/example/sdk/chunk_example.py
+++ b/example/sdk/chunk_example.py
@@ -50,8 +50,8 @@ try:
elapsed = 0
while elapsed < MAX_WAIT:
doc_status = dataset.list_documents(id=doc.id)[0]
- if doc_status.run == "1" and doc_status.progress >= 1.0:
- print("Parsing completed.")
+ if doc_status.run == "DONE" and doc_status.progress >= 1.0:
+ print(f"Parsing completed for {doc.id} after {elapsed}s.")
break
print(f"Parsing progress: {doc_status.progress:.2f}")
time.sleep(2)
diff --git a/example/sdk/retrieval_example.py b/example/sdk/retrieval_example.py
index f48885ef2b..cb6de4a6e0 100644
--- a/example/sdk/retrieval_example.py
+++ b/example/sdk/retrieval_example.py
@@ -47,7 +47,7 @@ try:
elapsed = 0
while elapsed < MAX_WAIT:
doc_status = dataset.list_documents(id=doc.id)[0]
- if doc_status.run == "1" and doc_status.progress >= 1.0:
+ if doc_status.run == "DONE" and doc_status.progress >= 1.0:
break
print(f"Parsing progress: {doc_status.progress:.2f}")
time.sleep(2)
@@ -55,7 +55,7 @@ try:
else:
print("Parsing timed out.")
sys.exit(-1)
- print("Document parsed and ready for retrieval.")
+ print(f"Document {doc.id} parsed after {elapsed}s and ready for retrieval.")
# 3. Perform retrieval (Semantic Search)
print("\n--- Performing Retrieval ---")