Skip to content

Commit

Permalink
Populate content_hash with embed_multi, refs #217
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Sep 3, 2023
1 parent 53fc9cb commit 156bed7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions llm/embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ def embed_multi_with_metadata(
"id": id,
"embedding": llm.encode(embedding),
"content": text if store else None,
"content_hash": self.content_hash(text),
"metadata": json.dumps(metadata) if metadata else None,
"updated": int(time.time()),
}
Expand Down
2 changes: 2 additions & 0 deletions tests/test_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ def test_embed_multi(with_metadata):
else:
assert len(rows_with_metadata) == 0
assert len(rows_with_content) == 1000
# Every row should have content_hash set
assert all(row["content_hash"] is not None for row in rows)


def test_collection_delete(collection):
Expand Down

0 comments on commit 156bed7

Please sign in to comment.