Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example of attachment with type #594

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
Copy link

@erikdw erikdw Oct 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:
Use `llm.Attachment(content=b"binary image content here")` to pass binary content directly. You may optionally specify a content type - if you 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.