diff --git a/astrbot/core/db/vec_db/faiss_impl/embedding_storage.py b/astrbot/core/db/vec_db/faiss_impl/embedding_storage.py index 985f00cc9..262a459e3 100644 --- a/astrbot/core/db/vec_db/faiss_impl/embedding_storage.py +++ b/astrbot/core/db/vec_db/faiss_impl/embedding_storage.py @@ -9,14 +9,14 @@ import numpy as np class EmbeddingStorage: - def __init__(self, dimention: int, path: str = None): - self.dimention = dimention + def __init__(self, dimension: int, path: str = None): + self.dimension = dimension self.path = path self.index = None if path and os.path.exists(path): self.index = faiss.read_index(path) else: - base_index = faiss.IndexFlatL2(dimention) + base_index = faiss.IndexFlatL2(dimension) self.index = faiss.IndexIDMap(base_index) self.storage = {} 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 87edad7e7..e4122e547 100644 --- a/astrbot/core/db/vec_db/faiss_impl/vec_db.py +++ b/astrbot/core/db/vec_db/faiss_impl/vec_db.py @@ -91,9 +91,7 @@ class FaissVecDB(BaseVecDB): return [] result_docs = [] - idx_pos = {} - for idx, fetch_doc in enumerate(fetched_docs): - idx_pos[fetch_doc["id"]] = idx + idx_pos = {fetch_doc["id"]: idx for idx, fetch_doc in enumerate(fetched_docs)} for i, indice_idx in enumerate(indices[0]): pos = idx_pos.get(indice_idx) if pos is None: