mirror of
https://github.com/Hopiu/llm.git
synced 2026-05-01 10:24:46 +00:00
Docs and test for store=True, refs #203
This commit is contained in:
parent
212cd617f3
commit
4955a5fa6c
2 changed files with 11 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue