Skip to content

Commit

Permalink
Fix #10 - Fix index out of bounds when database is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Jan 9, 2024
1 parent 8ace1fe commit e5a2f4d
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 e5a2f4d

Please sign in to comment.