From 5125568ea29a45f4e148d1bb39a96269aa223aba Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Fri, 23 May 2025 16:49:08 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BA=A4=E6=8D=A2=20if/else=20?= =?UTF-8?q?=E8=A1=A8=E8=BE=BE=E5=BC=8F=E7=9A=84=E5=88=86=E6=94=AF=E4=BB=A5?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=90=A6=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com> --- astrbot/core/db/vec_db/faiss_impl/vec_db.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/astrbot/core/db/vec_db/faiss_impl/vec_db.py b/astrbot/core/db/vec_db/faiss_impl/vec_db.py index a393df46a..87edad7e7 100644 --- a/astrbot/core/db/vec_db/faiss_impl/vec_db.py +++ b/astrbot/core/db/vec_db/faiss_impl/vec_db.py @@ -76,7 +76,7 @@ class FaissVecDB(BaseVecDB): embedding = await self.embedding_provider.get_embedding(query) scores, indices = await self.embedding_storage.search( vector=np.array([embedding]).astype("float32"), - k=k if not metadata_filters else fetch_k, + k=fetch_k if metadata_filters else k, ) # TODO: rerank if len(indices[0]) == 0 or indices[0][0] == -1: