Commit d2fb064
committed
Adding util to help developers add message attachment
Summary:
Adding `MessageAttachment.base64(path)` so that sending attachment will look like this:
```
from llama_stack_client.lib.inference.utils import MessageAttachment
response = client.inference.chat_completion(
model_id="meta-llama/llama3.2-11b-vision-instruct",
messages=[
{
"role": "user",
"content": {
"type": "image",
"image": {
"data": MessageAttachment.base64("images/tennis-game.png")
}
}
},
{
"role": "user",
"content": "What's in this image?",
}
]
)
```
Test Plan:
```
pip install .
# start a new notebook and run
from llama_stack_client import LlamaStackClient
from llama_stack_client.lib.inference.utils import MessageAttachment
client = LlamaStackClient(
base_url='localhost:8321'
)
response = client.inference.chat_completion(
model_id="meta-llama/llama3.2-11b-vision-instruct",
messages=[
{
"role": "user",
"content": {
"type": "image",
"image": {
"data": MessageAttachment.base64("images/tennis-game.png")
}
}
},
{
"role": "user",
"content": "What's in this image?",
}
]
)
print(response)
```1 parent b183fb6 commit d2fb064
1 file changed
+20
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
0 commit comments