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
Feat: Add support for document meta fields update through api (#5120)
liwenju03ced290eb547
diff --git a/api/apps/sdk/doc.py b/api/apps/sdk/doc.pyindex aa3323cf18..b879263356 100644--- a/api/apps/sdk/doc.py+++ b/api/apps/sdk/doc.py@@ -255,6 +255,10 @@ def update_doc(tenant_id, dataset_id, document_id):)if not DocumentService.update_by_id(document_id, {"name": req["name"]}):return get_error_data_result(message="Database error (Document rename)!")+ if "meta_fields" in req:+ if not isinstance(req["meta_fields"], dict):+ return get_error_data_result(message="meta_fields must be a dictionary")+ DocumentService.update_meta_fields(document_id, req["meta_fields"])informs = File2DocumentService.get_by_document_id(document_id)if informs:diff --git a/api/db/services/document_service.py b/api/db/services/document_service.pyindex 58cb351248..4e94f92842 100644--- a/api/db/services/document_service.py+++ b/api/db/services/document_service.py@@ -372,6 +372,10 @@ class DocumentService(CommonService):"progress_msg": "Task is queued...","process_begin_at": get_format_time()})+ @classmethod+ @DB.connection_context()+ def update_meta_fields(cls, doc_id, meta_fields):+ return cls.update_by_id(doc_id, {"meta_fields": meta_fields})@classmethod@DB.connection_context()diff --git a/docs/references/python_api_reference.md b/docs/references/python_api_reference.mdindex f28b39a96c..b95c644e55 100644--- a/docs/references/python_api_reference.md+++ b/docs/references/python_api_reference.md@@ -262,6 +262,7 @@ A dictionary representing the attributes to update, with the following keys:- `"email"`: Email- `"knowledge_graph"`: Knowledge GraphEnsure your LLM is properly configured on the **Settings** page before selecting this. Please also note that Knowledge Graph consumes a large number of Tokens!+ - `"meta_fields"`: `dict[str, Any]` The meta fields of the dataset.#### Returnsdiff --git a/sdk/python/ragflow_sdk/modules/document.py b/sdk/python/ragflow_sdk/modules/document.pyindex bb3211d242..60a6e064bb 100644--- a/sdk/python/ragflow_sdk/modules/document.py+++ b/sdk/python/ragflow_sdk/modules/document.py@@ -49,6 +49,9 @@ class Document(Base):super().__init__(rag, res_dict)def update(self, update_message: dict):+ if "meta_fields" in update_message:+ if not isinstance(update_message["meta_fields"], dict):+ raise Exception("meta_fields must be a dictionary")res = self.put(f'/datasets/{self.dataset_id}/documents/{self.id}',update_message)res = res.json()