Skip to content

Commit

Permalink
add image example
Browse files Browse the repository at this point in the history
  • Loading branch information
GaspardBT committed Sep 13, 2024
1 parent 541a2b4 commit c737886
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions examples/async_chat_with_image_no_streaming.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env python

import asyncio
import os

import httpx

from mistralai import Mistral
from mistralai.models import ImageURLChunk, TextChunk, UserMessage


async def main():
api_key = os.environ["MISTRAL_API_KEY"]
model = "pixtral-12b"
client = Mistral(api_key=api_key)

chat_response = await client.chat.complete_async(
model=model,
messages=[
UserMessage(
content=[
{"type": "text", "text": "What's in this image?"},
{
"type": "image_url",
"image_url": "https://mistral.ai/images/news/codestral/FIM_table.png",
},
]
)
],
)

print(chat_response.choices[0].message.content)


if __name__ == "__main__":
asyncio.run(main())

0 comments on commit c737886

Please sign in to comment.