mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-13 05:58:59 +08:00
Feat: add document enabled (#7549)
### What problem does this PR solve? _Briefly describe what this PR aims to solve. Include background context that will help reviewers understand the purpose of the PR._ ### Type of change - [ ] Bug Fix (non-breaking change which fixes an issue) - [ ] New Feature (non-breaking change which adds functionality) - [ ] Documentation Update - [ ] Refactoring - [ ] Performance Improvement - [ ] Other (please describe):
This commit is contained in:
parent
b781207752
commit
d66c17ab5c
@ -222,6 +222,9 @@ def update_doc(tenant_id, dataset_id, document_id):
|
|||||||
chunk_method:
|
chunk_method:
|
||||||
type: string
|
type: string
|
||||||
description: Chunking method.
|
description: Chunking method.
|
||||||
|
enabled:
|
||||||
|
type: boolean
|
||||||
|
description: Document status.
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: Document updated successfully.
|
description: Document updated successfully.
|
||||||
@ -231,6 +234,10 @@ def update_doc(tenant_id, dataset_id, document_id):
|
|||||||
req = request.json
|
req = request.json
|
||||||
if not KnowledgebaseService.query(id=dataset_id, tenant_id=tenant_id):
|
if not KnowledgebaseService.query(id=dataset_id, tenant_id=tenant_id):
|
||||||
return get_error_data_result(message="You don't own the dataset.")
|
return get_error_data_result(message="You don't own the dataset.")
|
||||||
|
e, kb = KnowledgebaseService.get_by_id(dataset_id)
|
||||||
|
if not e:
|
||||||
|
return get_error_data_result(
|
||||||
|
message="Can't find this knowledgebase!")
|
||||||
doc = DocumentService.query(kb_id=dataset_id, id=document_id)
|
doc = DocumentService.query(kb_id=dataset_id, id=document_id)
|
||||||
if not doc:
|
if not doc:
|
||||||
return get_error_data_result(message="The dataset doesn't own the document.")
|
return get_error_data_result(message="The dataset doesn't own the document.")
|
||||||
@ -332,9 +339,25 @@ def update_doc(tenant_id, dataset_id, document_id):
|
|||||||
return get_error_data_result(message="Document not found!")
|
return get_error_data_result(message="Document not found!")
|
||||||
settings.docStoreConn.delete({"doc_id": doc.id}, search.index_name(tenant_id), dataset_id)
|
settings.docStoreConn.delete({"doc_id": doc.id}, search.index_name(tenant_id), dataset_id)
|
||||||
|
|
||||||
|
if "enabled" in req:
|
||||||
|
status = int(req["enabled"])
|
||||||
|
if doc.status != req["enabled"]:
|
||||||
|
try:
|
||||||
|
if not DocumentService.update_by_id(
|
||||||
|
doc.id, {"status": str(status)}):
|
||||||
|
return get_error_data_result(
|
||||||
|
message="Database error (Document update)!")
|
||||||
|
|
||||||
|
settings.docStoreConn.update({"doc_id": doc.id}, {"available_int": status},
|
||||||
|
search.index_name(kb.tenant_id), doc.kb_id)
|
||||||
|
return get_result(data=True)
|
||||||
|
except Exception as e:
|
||||||
|
return server_error_response(e)
|
||||||
|
|
||||||
return get_result()
|
return get_result()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@manager.route("/datasets/<dataset_id>/documents/<document_id>", methods=["GET"]) # noqa: F821
|
@manager.route("/datasets/<dataset_id>/documents/<document_id>", methods=["GET"]) # noqa: F821
|
||||||
@token_required
|
@token_required
|
||||||
def download(tenant_id, dataset_id, document_id):
|
def download(tenant_id, dataset_id, document_id):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user