Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
support rename document (#4915)
Jyong4e3b0c5aea01
diff --git a/api/controllers/console/datasets/datasets_document.py b/api/controllers/console/datasets/datasets_document.pyindex 3e1870d1e11..5498d22e781 100644--- a/api/controllers/console/datasets/datasets_document.py+++ b/api/controllers/console/datasets/datasets_document.py@@ -930,6 +930,28 @@ class DocumentRetryApi(DocumentResource):return {'result': 'success'}, 204+class DocumentRenameApi(DocumentResource):+ @setup_required+ @login_required+ @account_initialization_required+ @marshal_with(document_fields)+ def post(self, dataset_id, document_id):+ # The role of the current user in the ta table must be admin or owner+ if not current_user.is_admin_or_owner:+ raise Forbidden()++ parser = reqparse.RequestParser()+ parser.add_argument('name', type=str, required=True, nullable=False, location='json')+ args = parser.parse_args()++ try:+ document = DocumentService.rename_document(dataset_id, document_id, args['name'])+ except services.errors.document.DocumentIndexingError:+ raise DocumentIndexingError('Cannot delete document during indexing.')++ return document++api.add_resource(GetProcessRuleApi, '/datasets/process-rule')api.add_resource(DatasetDocumentListApi,'/datasets/<uuid:dataset_id>/documents')@@ -956,3 +978,5 @@ api.add_resource(DocumentStatusApi,api.add_resource(DocumentPauseApi, '/datasets/<uuid:dataset_id>/documents/<uuid:document_id>/processing/pause')api.add_resource(DocumentRecoverApi, '/datasets/<uuid:dataset_id>/documents/<uuid:document_id>/processing/resume')api.add_resource(DocumentRetryApi, '/datasets/<uuid:dataset_id>/retry')+api.add_resource(DocumentRenameApi,+ '/datasets/<uuid:dataset_id>/documents/<uuid:document_id>/rename')diff --git a/api/fields/document_fields.py b/api/fields/document_fields.pyindex 94d905eafe0..e8215255b35 100644--- a/api/fields/document_fields.py+++ b/api/fields/document_fields.py@@ -8,6 +8,7 @@ document_fields = {'position': fields.Integer,'data_source_type': fields.String,'data_source_info': fields.Raw(attribute='data_source_info_dict'),+ 'data_source_detail_dict': fields.Raw(attribute='data_source_detail_dict'),'dataset_process_rule_id': fields.String,'name': fields.String,'created_from': fields.String,@@ -31,6 +32,7 @@ document_with_segments_fields = {'position': fields.Integer,'data_source_type': fields.String,'data_source_info': fields.Raw(attribute='data_source_info_dict'),+ 'data_source_detail_dict': fields.Raw(attribute='data_source_detail_dict'),'dataset_process_rule_id': fields.String,'name': fields.String,'created_from': fields.String,diff --git a/api/services/dataset_service.py b/api/services/dataset_service.pyindex ea0fdd8b332..267db740f8b 100644--- a/api/services/dataset_service.py+++ b/api/services/dataset_service.py@@ -451,6 +451,27 @@ class DocumentService:db.session.delete(document)db.session.commit()+ @staticmethod+ def rename_document(dataset_id: str, document_id: str, name: str) -> Document:+ dataset = DatasetService.get_dataset(dataset_id)+ if not dataset:+ raise ValueError('Dataset not found.')++ document = DocumentService.get_document(dataset_id, document_id)++ if not document:+ raise ValueError('Document not found.')++ if document.tenant_id != current_user.current_tenant_id:+ raise ValueError('No permission.')++ document.name = name++ db.session.add(document)+ db.session.commit()++ return document+@staticmethoddef pause_document(document):if document.indexing_status not in ["waiting", "parsing", "cleaning", "splitting", "indexing"]: