mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
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)
This commit is contained in:
@ -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.file_utils import filename_type, get_project_base_directory, thumbnail
|
||||||
from api.utils.web_utils import CONTENT_TYPE_MAP, html2pdf, is_valid_url
|
from api.utils.web_utils import CONTENT_TYPE_MAP, html2pdf, is_valid_url
|
||||||
from deepdoc.parser.html_parser import RAGFlowHtmlParser
|
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
|
from rag.utils.storage_factory import STORAGE_IMPL
|
||||||
|
|
||||||
|
|
||||||
@ -524,6 +524,21 @@ def rename():
|
|||||||
e, file = FileService.get_by_id(informs[0].file_id)
|
e, file = FileService.get_by_id(informs[0].file_id)
|
||||||
FileService.update_by_id(file.id, {"name": req["name"]})
|
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)
|
return get_json_result(data=True)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return server_error_response(e)
|
return server_error_response(e)
|
||||||
|
|||||||
Reference in New Issue
Block a user