Skip to content

Commit

Permalink
fix: add unique id for vector embedding
Browse files Browse the repository at this point in the history
for consistent upserts with no duplicated events
  • Loading branch information
marcus-ny committed Sep 24, 2024
1 parent ff19b31 commit 2f8d5ca
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions backend/src/embeddings/vector_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,15 @@ def store_documents():
)
documents.append(document)

uuids = [str(uuid4()) for _ in range(len(documents))]
vector_store.add_documents(documents=documents, ids=uuids)
ids = [
str(document.metadata["id"])
+ "-"
+ str(document.metadata["event_id"])
+ "-"
+ str(document.metadata["category_id"])
for document in documents
]
vector_store.add_documents(documents=documents, ids=ids)

print(f"Stored {len(documents)} documents")

Expand Down

0 comments on commit 2f8d5ca

Please sign in to comment.