Skip to content

Commit

Permalink
Merge pull request #11 from trufae/fix-10
Browse files Browse the repository at this point in the history
Fix #10 - Fix index out of bounds when database is empty
  • Loading branch information
vprelovac authored Jan 9, 2024
2 parents 8ace1fe + e5a2f4d commit 8bfc71d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions vectordb/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(
self.memory = []
self.metadata_memory = []
else:
load = Storage(memory_file).load_from_disk()
load = Storage(memory_file).load_from_disk()
self.memory = [] if len(load) != 1 else load[0]["memory"]
self.metadata_memory = [] if len(load) != 1 else load[0]["metadata"]

Expand Down Expand Up @@ -150,8 +150,9 @@ def search(
else:
query_embedding = self.embedder.embed_text([query])[0]


embeddings = [entry["embedding"] for entry in self.memory]
if len(embeddings) == 0:
return []

indices = self.vector_search.search_vectors(query_embedding, embeddings, top_n, batch_results)
if unique:
Expand Down

0 comments on commit 8bfc71d

Please sign in to comment.