Skip to content

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

Feat: Make knowledge base renaming automatically reflected in agent discussions, solved #10597 (#10680)

Billy Baocd75fa02b178
diff --git a/api/apps/document_app.py b/api/apps/document_app.py
index a252db9ec2..42856bf771 100644
--- a/api/apps/document_app.py
+++ b/api/apps/document_app.py
@@ -45,7 +45,7 @@ from api.utils.api_utils import (
from api.utils.file_utils import filename_type, get_project_base_directory, thumbnail
from api.utils.web_utils import CONTENT_TYPE_MAP, html2pdf, is_valid_url
from deepdoc.parser.html_parser import RAGFlowHtmlParser
-from rag.nlp import search
+from rag.nlp import search, rag_tokenizer
from rag.utils.storage_factory import STORAGE_IMPL
@@ -524,6 +524,21 @@ def rename():
e, file = FileService.get_by_id(informs[0].file_id)
FileService.update_by_id(file.id, {"name": req["name"]})
+ tenant_id = DocumentService.get_tenant_id(req["doc_id"])
+ title_tks = rag_tokenizer.tokenize(req["name"])
+ es_body = {
+ "docnm_kwd": req["name"],
+ "title_tks": title_tks,
+ "title_sm_tks": rag_tokenizer.fine_grained_tokenize(title_tks),
+ }
+ if settings.docStoreConn.indexExist(search.index_name(tenant_id), doc.kb_id):
+ settings.docStoreConn.update(
+ {"doc_id": req["doc_id"]},
+ es_body,
+ search.index_name(tenant_id),
+ doc.kb_id,
+ )
+
return get_json_result(data=True)
except Exception as e:
return server_error_response(e)