cv / vector_store.py
saherPervaiz's picture
Update vector_store.py
1b0b844 verified
raw
history blame contribute delete
658 Bytes
# vector_store.py
import faiss
import numpy as np
def create_faiss_index(vectors):
try:
dim = vectors[0].shape[0]
index = faiss.IndexFlatL2(dim)
index.add(np.array(vectors).astype("float32"))
return index
except Exception as e:
print(f"❌ Error creating FAISS index: {e}")
return None
def search_similar_cvs(query_vector, index, k=3):
try:
query_vector = np.array([query_vector]).astype("float32")
distances, indices = index.search(query_vector, k)
return indices[0].tolist()
except Exception as e:
print(f"❌ Error searching index: {e}")
return []