@ai-sdk/mistral 3.0.20 → 3.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/docs/20-mistral.mdx +24 -17
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -828,7 +828,7 @@ var MistralTextEmbeddingResponseSchema = import_v44.z.object({
|
|
|
828
828
|
});
|
|
829
829
|
|
|
830
830
|
// src/version.ts
|
|
831
|
-
var VERSION = true ? "3.0.
|
|
831
|
+
var VERSION = true ? "3.0.21" : "0.0.0-test";
|
|
832
832
|
|
|
833
833
|
// src/mistral-provider.ts
|
|
834
834
|
function createMistral(options = {}) {
|
package/dist/index.mjs
CHANGED
|
@@ -824,7 +824,7 @@ var MistralTextEmbeddingResponseSchema = z4.object({
|
|
|
824
824
|
});
|
|
825
825
|
|
|
826
826
|
// src/version.ts
|
|
827
|
-
var VERSION = true ? "3.0.
|
|
827
|
+
var VERSION = true ? "3.0.21" : "0.0.0-test";
|
|
828
828
|
|
|
829
829
|
// src/mistral-provider.ts
|
|
830
830
|
function createMistral(options = {}) {
|
package/docs/20-mistral.mdx
CHANGED
|
@@ -211,51 +211,58 @@ const { text } = await generateText({
|
|
|
211
211
|
});
|
|
212
212
|
```
|
|
213
213
|
|
|
214
|
-
Mistral language models can also be used in the `streamText
|
|
214
|
+
Mistral language models can also be used in the `streamText` function
|
|
215
|
+
and support structured data generation with [`Output`](/docs/reference/ai-sdk-core/output)
|
|
215
216
|
(see [AI SDK Core](/docs/ai-sdk-core)).
|
|
216
217
|
|
|
217
218
|
#### Structured Outputs
|
|
218
219
|
|
|
219
|
-
Mistral chat models support structured outputs using JSON Schema. You can use `
|
|
220
|
-
|
|
220
|
+
Mistral chat models support structured outputs using JSON Schema. You can use `generateText` or `streamText` with [`Output`](/docs/reference/ai-sdk-core/output)
|
|
221
|
+
and Zod, Valibot, or raw JSON Schema. The SDK sends your schema via Mistral's `response_format: { type: 'json_schema' }`.
|
|
221
222
|
|
|
222
223
|
```ts
|
|
223
224
|
import { mistral } from '@ai-sdk/mistral';
|
|
224
|
-
import {
|
|
225
|
+
import { generateText, Output } from 'ai';
|
|
225
226
|
import { z } from 'zod';
|
|
226
227
|
|
|
227
|
-
const result = await
|
|
228
|
+
const result = await generateText({
|
|
228
229
|
model: mistral('mistral-large-latest'),
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
230
|
+
output: Output.object({
|
|
231
|
+
schema: z.object({
|
|
232
|
+
recipe: z.object({
|
|
233
|
+
name: z.string(),
|
|
234
|
+
ingredients: z.array(z.string()),
|
|
235
|
+
instructions: z.array(z.string()),
|
|
236
|
+
}),
|
|
234
237
|
}),
|
|
235
238
|
}),
|
|
236
239
|
prompt: 'Generate a simple pasta recipe.',
|
|
237
240
|
});
|
|
238
241
|
|
|
239
|
-
console.log(JSON.stringify(result.
|
|
242
|
+
console.log(JSON.stringify(result.output, null, 2));
|
|
240
243
|
```
|
|
241
244
|
|
|
242
245
|
You can enable strict JSON Schema validation using a provider option:
|
|
243
246
|
|
|
244
247
|
```ts highlight="7-11"
|
|
245
248
|
import { mistral, type MistralLanguageModelOptions } from '@ai-sdk/mistral';
|
|
246
|
-
import {
|
|
249
|
+
import { generateText, Output } from 'ai';
|
|
247
250
|
import { z } from 'zod';
|
|
248
251
|
|
|
249
|
-
const result = await
|
|
252
|
+
const result = await generateText({
|
|
250
253
|
model: mistral('mistral-large-latest'),
|
|
251
254
|
providerOptions: {
|
|
252
255
|
mistral: {
|
|
253
|
-
strictJsonSchema: true,
|
|
256
|
+
strictJsonSchema: true,
|
|
254
257
|
} satisfies MistralLanguageModelOptions,
|
|
255
258
|
},
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
+
output: Output.object({
|
|
260
|
+
schema: z.object({
|
|
261
|
+
title: z.string(),
|
|
262
|
+
items: z.array(
|
|
263
|
+
z.object({ id: z.string(), qty: z.number().int().min(1) }),
|
|
264
|
+
),
|
|
265
|
+
}),
|
|
259
266
|
}),
|
|
260
267
|
prompt: 'Generate a small shopping list.',
|
|
261
268
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/mistral",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.21",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@ai-sdk/provider": "3.0.8",
|
|
33
|
-
"@ai-sdk/provider-utils": "4.0.
|
|
33
|
+
"@ai-sdk/provider-utils": "4.0.16"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "20.17.24",
|