Docs and test for store=True, refs #203

This commit is contained in:
Simon Willison 2023-09-01 17:52:43 -07:00
parent 212cd617f3
commit 4955a5fa6c
2 changed files with 11 additions and 0 deletions

View file

@ -47,6 +47,8 @@ collection.embed("hound", "my happy hound")
```
This stores the embedding for the string "my happy hound" in the `entries` collection under the key `hound`.
Add `store=True` to store the text content itself in the database table along with the embedding vector.
You can embed multiple ID and string pairs at once using the `embed_multi()` method:
```python

View file

@ -31,6 +31,15 @@ def test_embed_huge_list():
assert model.batch_count == 100
def test_embed_store(collection):
collection.embed("3", "hello world", store=True)
assert collection.db["embeddings"].count == 3
assert (
next(collection.db["embeddings"].rows_where("id = ?", ["3"]))["content"]
== "hello world"
)
def test_collection(collection):
assert collection.id() == 1
assert collection.count() == 2