From cd75fa02b178d2c1e0aed8cd9f8cc40c55669651 Mon Sep 17 00:00:00 2001 From: Billy Bao Date: Tue, 21 Oct 2025 10:42:05 +0800 Subject: [PATCH] Feat: Make knowledge base renaming automatically reflected in agent discussions, solved #10597 (#10680) ### What problem does this PR solve? Feat: Make knowledge base renaming automatically reflected in agent discussions, solved #10597 ### Type of change - [x] New Feature (non-breaking change which adds functionality) --- api/apps/document_app.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/api/apps/document_app.py b/api/apps/document_app.py index a252db9ec..42856bf77 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)