Skip to content

Commit

Permalink
Example of attachment with type
Browse files Browse the repository at this point in the history
Need to test this before merging it.
  • Loading branch information
simonw authored Oct 29, 2024
1 parent a44ba49 commit 5b5c21c
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions docs/python-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ response = model.prompt(

### Attachments

Model that accept multi-modal input (images, audio, video etc) can be passed attachments using the `attachments=` keyword argument. This accepts a list of `llm.Attachment()` instances.
Models that accept multi-modal input (images, audio, video etc) can be passed attachments using the `attachments=` keyword argument. This accepts a list of `llm.Attachment()` instances.

This example shows two attachments - one from a file path and one from a URL:
```python
Expand All @@ -69,7 +69,18 @@ response = model.prompt(
]
)
```
Use `llm.Attachment(content=b"binary image content here")` to pass binary content directly.
Use `llm.Attachment(content=b"binary image content here")` to pass binary content directly. You may optionqlly specify a content type - if tou do not it will be detected automatically:

```python
image = llm.Attachment(
content=b"...",
type="image/png"
)
response = model.prompt(
"extract text",
attachments=[image]
)
```

### Model options

Expand Down Expand Up @@ -206,4 +217,4 @@ Here the `default=` parameter specifies the value that should be returned if the

### set_default_embedding_model(alias) and get_default_embedding_model()

These two methods work the same as `set_default_model()` and `get_default_model()` but for the default {ref}`embedding model <embeddings>` instead.
These two methods work the same as `set_default_model()` and `get_default_model()` but for the default {ref}`embedding model <embeddings>` instead.

0 comments on commit 5b5c21c

Please sign in to comment.