-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat (provider/mistral): image support (#3048)
- Loading branch information
Showing
15 changed files
with
167 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@ai-sdk/mistral': patch | ||
--- | ||
|
||
feat (provider/mistral): image support |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
examples/ai-core/src/generate-text/mistral-multimodal-base64.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { mistral } from '@ai-sdk/mistral'; | ||
import { generateText } from 'ai'; | ||
import 'dotenv/config'; | ||
import fs from 'node:fs'; | ||
|
||
async function main() { | ||
const result = await generateText({ | ||
model: mistral('pixtral-12b-2409'), | ||
messages: [ | ||
{ | ||
role: 'user', | ||
content: [ | ||
{ type: 'text', text: 'Describe the image in detail.' }, | ||
{ | ||
type: 'image', | ||
image: fs.readFileSync('./data/comic-cat.png').toString('base64'), | ||
}, | ||
], | ||
}, | ||
], | ||
}); | ||
|
||
console.log(result.text); | ||
} | ||
|
||
main().catch(console.error); |
26 changes: 26 additions & 0 deletions
26
examples/ai-core/src/generate-text/mistral-multimodal-url.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { mistral } from '@ai-sdk/mistral'; | ||
import { generateText } from 'ai'; | ||
import 'dotenv/config'; | ||
|
||
async function main() { | ||
const result = await generateText({ | ||
model: mistral('pixtral-12b-2409'), | ||
messages: [ | ||
{ | ||
role: 'user', | ||
content: [ | ||
{ type: 'text', text: 'Describe the image in detail.' }, | ||
{ | ||
type: 'image', | ||
image: | ||
'https://github.com/vercel/ai/blob/main/examples/ai-core/data/comic-cat.png?raw=true', | ||
}, | ||
], | ||
}, | ||
], | ||
}); | ||
|
||
console.log(result.text); | ||
} | ||
|
||
main().catch(console.error); |
26 changes: 26 additions & 0 deletions
26
packages/mistral/src/__snapshots__/convert-to-mistral-chat-messages.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`tool calls > should stringify arguments to tool calls 1`] = ` | ||
[ | ||
{ | ||
"content": "", | ||
"role": "assistant", | ||
"tool_calls": [ | ||
{ | ||
"function": { | ||
"arguments": "{"key":"arg-value"}", | ||
"name": "tool-1", | ||
}, | ||
"id": "tool-call-id-1", | ||
"type": "function", | ||
}, | ||
], | ||
}, | ||
{ | ||
"content": "{"key":"result-value"}", | ||
"name": "tool-1", | ||
"role": "tool", | ||
"tool_call_id": "tool-call-id-1", | ||
}, | ||
] | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters