Skip to content
Open
Show file tree
Hide file tree
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
88 changes: 79 additions & 9 deletions samples-mistral/python/mistral-large3-basics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"source": [
"import requests\n",
"import re\n",
"from IPython.display import Markdown, display"
"from IPython.display import Markdown, display\n",
"import base64"
]
},
{
Expand Down Expand Up @@ -168,6 +169,83 @@
"display(Markdown(compoundQuestion2Response.json()[\"choices\"][0][\"message\"][\"content\"]))"
]
},
{
"cell_type": "markdown",
"id": "6d01e485",
"metadata": {},
"source": [
"## Multimodal"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bc9f39d5",
"metadata": {},
"outputs": [],
"source": [
"!wget -O fred.png \"https://fred.stlouisfed.org/graph/fredgraph.png?g=1On5p&height=490\""
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "327a5ce9",
"metadata": {},
"outputs": [],
"source": [
"with open(\"fred.png\", \"rb\") as image_file:\n",
" encoded_string = base64.b64encode(image_file.read()).decode(\"utf-8\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8c82f0fc",
"metadata": {},
"outputs": [],
"source": [
"multimodal = {\n",
" \"model\": f\"{AZURE_AI_FOUNDRY_MODEL_DEPLOYMENT_NAME}\",\n",
" \"messages\": [\n",
" {\n",
" \"role\": \"user\",\n",
" \"content\": [\n",
" {\"type\": \"text\", \"text\": \"Describe this image and any trends.\"},\n",
" {\n",
" \"type\": \"image_url\",\n",
" \"image_url\": {\"url\": f\"data:image/jpeg;base64,{encoded_string}\"},\n",
" },\n",
" ],\n",
" }\n",
" ],\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1994f786",
"metadata": {},
"outputs": [],
"source": [
"multimodalResponse = requests.post(\n",
" url=AZURE_AI_FOUNDRY_PROJECT_ENDPOINT,\n",
" json=multimodal,\n",
" headers=REQUEST_HEADERS,\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "700f37f8",
"metadata": {},
"outputs": [],
"source": [
"display(Markdown(multimodalResponse.json()[\"choices\"][0][\"message\"][\"content\"]))"
]
},
{
"cell_type": "markdown",
"id": "c704cdad",
Expand Down Expand Up @@ -589,14 +667,6 @@
"source": [
"display(Markdown(finance2Response.json()[\"choices\"][0][\"message\"][\"content\"]))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f77cdb78",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
Loading