perf: code quality

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
This commit is contained in:
Soulter
2025-05-23 16:56:09 +08:00
committed by GitHub
parent 5125568ea2
commit a36e11973d
2 changed files with 4 additions and 6 deletions
@@ -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 = {}
+1 -3
View File
@@ -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: