Fix broken example in docs (#223)

This commit is contained in:
Simon Willison 2023-09-03 20:53:51 -07:00 committed by GitHub
parent 2cc9b6087f
commit a44e23876e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -135,14 +135,14 @@ The `entry` object returned is an object with the following properties:
This defaults to returning the 10 most similar items. You can change this by passing a different `number=` argument:
```python
for id, score in collection.similar("hound", number=5):
print(id, score)
for entry in collection.similar("hound", number=5):
print(entry.id, entry.score)
```
The `similar_by_id()` method takes the ID of another item in the collection and returns the most similar items to that one, based on the embedding that has already been stored for it:
```python
for id, score in collection.similar_by_id("cat"):
print(id, score)
for entry in collection.similar_by_id("cat"):
print(entry.id, entry.score)
```
The item itself is excluded from the results.
@ -183,4 +183,4 @@ CREATE TABLE "embeddings" (
PRIMARY KEY ([collection_id], [id])
)
```
<!-- [[[end]]] -->
<!-- [[[end]]] -->