Skip to content

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

Fix: Resolve JSON download errors in Document.download() (#8084)

Liu Anf007c1c77278
diff --git a/sdk/python/ragflow_sdk/modules/document.py b/sdk/python/ragflow_sdk/modules/document.py
index 240138aa9e..6cb0e3b5e3 100644
--- a/sdk/python/ragflow_sdk/modules/document.py
+++ b/sdk/python/ragflow_sdk/modules/document.py
@@ -63,9 +63,14 @@ class Document(Base):
def download(self):
res = self.get(f"/datasets/{self.dataset_id}/documents/{self.id}")
+ error_keys = set(["code", "message"])
try:
- res = res.json()
- raise Exception(res.get("message"))
+ response = res.json()
+ actual_keys = set(response.keys())
+ if actual_keys == error_keys:
+ raise Exception(res.get("message"))
+ else:
+ return res.content
except json.JSONDecodeError:
return res.content