From 55c0468ac94a7f8616815cacec1ae36aa85e1a42 Mon Sep 17 00:00:00 2001 From: wenjuhao <1028854614@qq.com> Date: Fri, 19 Dec 2025 19:32:24 +0800 Subject: [PATCH] Include document_id in knowledgebase info retrieval (#12041) ### What problem does this PR solve? After a file in the file list is associated with a knowledge base, the knowledge base document ID is returned ### Type of change - [x] New Feature (non-breaking change which adds functionality) --- api/db/services/file_service.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/db/services/file_service.py b/api/db/services/file_service.py index 8cc5aa37a..d6a157b2d 100644 --- a/api/db/services/file_service.py +++ b/api/db/services/file_service.py @@ -100,7 +100,7 @@ class FileService(CommonService): # Returns: # List of dictionaries containing dataset IDs and names kbs = ( - cls.model.select(*[Knowledgebase.id, Knowledgebase.name]) + cls.model.select(*[Knowledgebase.id, Knowledgebase.name, File2Document.document_id]) .join(File2Document, on=(File2Document.file_id == file_id)) .join(Document, on=(File2Document.document_id == Document.id)) .join(Knowledgebase, on=(Knowledgebase.id == Document.kb_id)) @@ -110,7 +110,7 @@ class FileService(CommonService): return [] kbs_info_list = [] for kb in list(kbs.dicts()): - kbs_info_list.append({"kb_id": kb["id"], "kb_name": kb["name"]}) + kbs_info_list.append({"kb_id": kb["id"], "kb_name": kb["name"], "document_id": kb["document_id"]}) return kbs_info_list @classmethod