@ai-sdk/mistral 4.0.68 → 4.0.69
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 +9 -0
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -35
- package/dist/index.js.map +1 -1
- package/docs/20-mistral.mdx +48 -4
- package/package.json +2 -2
- package/src/mistral-chat-language-model-options.ts +47 -42
- package/src/mistral-chat-language-model.ts +104 -87
- package/src/mistral-conversation-language-model-options.ts +4 -2
- package/src/mistral-conversation-language-model.ts +107 -90
- package/src/mistral-embedding-model.ts +10 -4
- package/src/mistral-error.ts +18 -9
- package/src/mistral-speech-model-options.ts +18 -9
- package/src/mistral-speech-model.ts +9 -3
- package/src/mistral-transcription-model.ts +32 -26
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @ai-sdk/mistral
|
|
2
2
|
|
|
3
|
+
## 4.0.69
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 77b925f: Defer construction of provider validation schemas until first use to reduce package import time.
|
|
8
|
+
- Updated dependencies [b089ce8]
|
|
9
|
+
- Updated dependencies [39a776b]
|
|
10
|
+
- @ai-sdk/provider-utils@5.0.65
|
|
11
|
+
|
|
3
12
|
## 4.0.68
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { FetchFunction, InferSchema } from "@ai-sdk/provider-utils";
|
|
|
3
3
|
import { z } from "zod/v4";
|
|
4
4
|
//#region src/mistral-chat-language-model-options.d.ts
|
|
5
5
|
type MistralChatModelId = 'codestral-2508' | 'codestral-latest' | 'glm-5-2' | 'labs-leanstral-1-5' | 'labs-leanstral-1-5-1' | 'magistral-medium-latest' | 'magistral-small-latest' | 'ministral-14b-2512' | 'ministral-14b-latest' | 'ministral-3b-2512' | 'ministral-3b-latest' | 'ministral-8b-2512' | 'ministral-8b-latest' | 'mistral-code-fim-latest' | 'mistral-code-latest' | 'mistral-large-4' | 'mistral-large-4-0' | 'mistral-large-latest' | 'mistral-large-2512' | 'mistral-medium' | 'mistral-medium-latest' | 'mistral-medium-2604' | 'mistral-medium-3' | 'mistral-medium-3-5' | 'mistral-medium-3.5' | 'mistral-small-2603' | 'mistral-small-latest' | 'mistral-vibe-cli-fast' | 'mistral-vibe-cli-latest' | 'mistral-vibe-cli-with-tools' | 'voxtral-small-2507' | 'voxtral-small-latest' | 'zai-glm-5-2' | (string & {});
|
|
6
|
-
declare const mistralLanguageModelChatOptions: z.ZodObject<{
|
|
6
|
+
declare const mistralLanguageModelChatOptions: () => z.ZodObject<{
|
|
7
7
|
safePrompt: z.ZodOptional<z.ZodBoolean>;
|
|
8
8
|
documentImageLimit: z.ZodOptional<z.ZodNumber>;
|
|
9
9
|
documentPageLimit: z.ZodOptional<z.ZodNumber>;
|
|
@@ -16,7 +16,7 @@ declare const mistralLanguageModelChatOptions: z.ZodObject<{
|
|
|
16
16
|
none: "none";
|
|
17
17
|
}>>;
|
|
18
18
|
}, z.core.$strip>;
|
|
19
|
-
type MistralLanguageModelChatOptions = z.infer<typeof mistralLanguageModelChatOptions
|
|
19
|
+
type MistralLanguageModelChatOptions = z.infer<ReturnType<typeof mistralLanguageModelChatOptions>>;
|
|
20
20
|
//#endregion
|
|
21
21
|
//#region src/mistral-embedding-model-options.d.ts
|
|
22
22
|
type MistralEmbeddingModelId = 'mistral-embed' | 'mistral-embed-2312' | 'codestral-embed' | 'codestral-embed-2505' | (string & {});
|
|
@@ -35,10 +35,10 @@ type MistralEmbeddingModelOptions = z.infer<typeof mistralEmbeddingModelOptions>
|
|
|
35
35
|
//#endregion
|
|
36
36
|
//#region src/mistral-speech-model-options.d.ts
|
|
37
37
|
type MistralSpeechModelId = 'voxtral-mini-tts-2603' | 'voxtral-mini-tts-latest' | (string & {});
|
|
38
|
-
declare const mistralSpeechModelOptions:
|
|
39
|
-
refAudio
|
|
40
|
-
}
|
|
41
|
-
type MistralSpeechModelOptions =
|
|
38
|
+
declare const mistralSpeechModelOptions: import("@ai-sdk/provider-utils").LazySchema<{
|
|
39
|
+
refAudio?: string | undefined;
|
|
40
|
+
}>;
|
|
41
|
+
type MistralSpeechModelOptions = InferSchema<typeof mistralSpeechModelOptions>;
|
|
42
42
|
//#endregion
|
|
43
43
|
//#region src/mistral-transcription-model-options.d.ts
|
|
44
44
|
type MistralTranscriptionModelId = 'voxtral-mini-2602' | 'voxtral-mini-latest' | (string & {});
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/mistral-chat-language-model-options.ts","../src/mistral-embedding-model-options.ts","../src/mistral-speech-model-options.ts","../src/mistral-transcription-model-options.ts","../src/tool/index.ts","../src/mistral-provider.ts","../src/mistral-conversation-language-model-options.ts","../src/version.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/mistral-chat-language-model-options.ts","../src/mistral-embedding-model-options.ts","../src/mistral-speech-model-options.ts","../src/mistral-transcription-model-options.ts","../src/tool/index.ts","../src/mistral-provider.ts","../src/mistral-conversation-language-model-options.ts","../src/version.ts"],"mappings":";;;;KAIY;cAoCC,uCAA+B,EAAA;;;;;;;;;;;;GA+CxC,EAAA,KAAA;KAKQ,kCAAkC,EAAE,MAC9C,kBAAkB;;;KC3FR;cAOC,8BAA4B,EAAA;;;;;;;;;;GAiBvC,EAAA,KAAA;KAEU,+BAA+B,EAAE,aACpC;;;KCtBG;cAKC,4DAAyB;EAAA;;KAa1B,4BAA4B,mBAC/B;;;KCnBG;cAMC,mEAAgC;;;;;;;KAkDjC,mCAAmC,mBACtC;;;cC9DI;;;;;;;;;;;;;;;;;;;;;;UCwBI,wBAAwB;EACvC,cAAc;GACb,SAAS,qBAAqB;;;;EAK/B,cAAc,SAAS,qBAAqB;;;;EAK5C,KAAK,SAAS,qBAAqB;;;;EAKnC,aAAa,SAAS,qBAAqB;;;;EAK3C,UAAU,SAAS,0BAA0B;;;;EAK7C,iBAAiB,SAAS,4BAA4B;;;;EAKtD,OAAO,SAAS,uBAAuB;;;;EAKvC,YAAY,SAAS,uBAAuB;;;;EAK5C,cAAc,SAAS,8BAA8B;;;;EAKrD,mBACE,SAAS,8BACR;;;;EAKH,cAAc,SAAS,0BAA0B;;;;EAKjD,mBAAmB,SAAS,0BAA0B;;UAGvC;;;;;EAKf;;;;;EAMA;;;;EAKA,UAAU;;;;;EAMV,QAAQ;EAER;;;;;wBAMc,cACd,UAAS,0BACR;;;;qBA6FU,SAAO;;;KCxMR,0CACV;;;qBCZW"}
|
package/dist/index.js
CHANGED
|
@@ -178,7 +178,7 @@ function mapMistralFinishReason(finishReason) {
|
|
|
178
178
|
}
|
|
179
179
|
//#endregion
|
|
180
180
|
//#region src/mistral-chat-language-model-options.ts
|
|
181
|
-
const mistralLanguageModelChatOptions = z.object({
|
|
181
|
+
const mistralLanguageModelChatOptions = () => z.object({
|
|
182
182
|
/**
|
|
183
183
|
* Whether to inject a safety prompt before all conversations.
|
|
184
184
|
*
|
|
@@ -219,15 +219,16 @@ const mistralLanguageModelChatOptions = z.object({
|
|
|
219
219
|
*/
|
|
220
220
|
reasoningEffort: z.enum(["high", "none"]).optional()
|
|
221
221
|
});
|
|
222
|
+
const mistralLanguageModelChatOptionsValidator = lazySchema(() => zodSchema(mistralLanguageModelChatOptions()));
|
|
222
223
|
//#endregion
|
|
223
224
|
//#region src/mistral-error.ts
|
|
224
|
-
const mistralErrorDataSchema = z.object({
|
|
225
|
+
const mistralErrorDataSchema = lazySchema(() => zodSchema(z.object({
|
|
225
226
|
object: z.literal("error"),
|
|
226
227
|
message: z.string(),
|
|
227
228
|
type: z.string(),
|
|
228
229
|
param: z.string().nullable(),
|
|
229
230
|
code: z.string().nullable()
|
|
230
|
-
});
|
|
231
|
+
})));
|
|
231
232
|
const mistralFailedResponseHandler = createJsonErrorResponseHandler({
|
|
232
233
|
errorSchema: mistralErrorDataSchema,
|
|
233
234
|
errorToMessage: (data) => data.message
|
|
@@ -325,7 +326,7 @@ var MistralChatLanguageModel = class MistralChatLanguageModel {
|
|
|
325
326
|
const options = await parseProviderOptions({
|
|
326
327
|
provider: "mistral",
|
|
327
328
|
providerOptions,
|
|
328
|
-
schema:
|
|
329
|
+
schema: mistralLanguageModelChatOptionsValidator
|
|
329
330
|
}) ?? {};
|
|
330
331
|
if (topK != null) warnings.push({
|
|
331
332
|
type: "unsupported",
|
|
@@ -604,7 +605,7 @@ function extractTextContent(content) {
|
|
|
604
605
|
}
|
|
605
606
|
return textContent.length ? textContent.join("") : void 0;
|
|
606
607
|
}
|
|
607
|
-
const mistralContentSchema = z.union([z.string(), z.array(z.discriminatedUnion("type", [
|
|
608
|
+
const mistralContentSchema = () => z.union([z.string(), z.array(z.discriminatedUnion("type", [
|
|
608
609
|
z.object({
|
|
609
610
|
type: z.literal("text"),
|
|
610
611
|
text: z.string()
|
|
@@ -628,14 +629,14 @@ const mistralContentSchema = z.union([z.string(), z.array(z.discriminatedUnion("
|
|
|
628
629
|
}))
|
|
629
630
|
})
|
|
630
631
|
]))]).nullish();
|
|
631
|
-
const mistralChatResponseSchema = z.object({
|
|
632
|
+
const mistralChatResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
632
633
|
id: z.string().nullish(),
|
|
633
634
|
created: z.number().nullish(),
|
|
634
635
|
model: z.string().nullish(),
|
|
635
636
|
choices: z.array(z.object({
|
|
636
637
|
message: z.object({
|
|
637
638
|
role: z.literal("assistant"),
|
|
638
|
-
content: mistralContentSchema,
|
|
639
|
+
content: mistralContentSchema(),
|
|
639
640
|
tool_calls: z.array(z.object({
|
|
640
641
|
id: z.string(),
|
|
641
642
|
function: z.object({
|
|
@@ -649,15 +650,15 @@ const mistralChatResponseSchema = z.object({
|
|
|
649
650
|
})),
|
|
650
651
|
object: z.literal("chat.completion"),
|
|
651
652
|
usage: mistralUsageSchema
|
|
652
|
-
});
|
|
653
|
-
const mistralChatChunkSchema = z.object({
|
|
653
|
+
})));
|
|
654
|
+
const mistralChatChunkSchema = lazySchema(() => zodSchema(z.object({
|
|
654
655
|
id: z.string().nullish(),
|
|
655
656
|
created: z.number().nullish(),
|
|
656
657
|
model: z.string().nullish(),
|
|
657
658
|
choices: z.array(z.object({
|
|
658
659
|
delta: z.object({
|
|
659
660
|
role: z.enum(["assistant"]).optional(),
|
|
660
|
-
content: mistralContentSchema,
|
|
661
|
+
content: mistralContentSchema(),
|
|
661
662
|
tool_calls: z.array(z.object({
|
|
662
663
|
index: z.number().nullish(),
|
|
663
664
|
id: z.string().nullish(),
|
|
@@ -671,7 +672,7 @@ const mistralChatChunkSchema = z.object({
|
|
|
671
672
|
index: z.number()
|
|
672
673
|
})),
|
|
673
674
|
usage: mistralUsageSchema.nullish()
|
|
674
|
-
});
|
|
675
|
+
})));
|
|
675
676
|
//#endregion
|
|
676
677
|
//#region src/convert-to-mistral-conversation-inputs.ts
|
|
677
678
|
function convertToMistralConversationInputs(prompt, toolNameMapping) {
|
|
@@ -785,7 +786,7 @@ function convertToMistralConversationInputs(prompt, toolNameMapping) {
|
|
|
785
786
|
}
|
|
786
787
|
//#endregion
|
|
787
788
|
//#region src/mistral-conversation-language-model-options.ts
|
|
788
|
-
const mistralLanguageModelConversationOptions = mistralLanguageModelChatOptions;
|
|
789
|
+
const mistralLanguageModelConversationOptions = lazySchema(() => zodSchema(mistralLanguageModelChatOptions()));
|
|
789
790
|
//#endregion
|
|
790
791
|
//#region src/mistral-conversation-prepare-tools.ts
|
|
791
792
|
const mistralProviderToolNames = {
|
|
@@ -1283,7 +1284,7 @@ function createContentConverter({ tools, generateId }) {
|
|
|
1283
1284
|
}
|
|
1284
1285
|
};
|
|
1285
1286
|
}
|
|
1286
|
-
const mistralConversationContentSchema = z.discriminatedUnion("type", [
|
|
1287
|
+
const mistralConversationContentSchema = () => z.discriminatedUnion("type", [
|
|
1287
1288
|
z.object({
|
|
1288
1289
|
type: z.literal("text"),
|
|
1289
1290
|
text: z.string()
|
|
@@ -1302,8 +1303,8 @@ const mistralConversationContentSchema = z.discriminatedUnion("type", [
|
|
|
1302
1303
|
url: z.string().nullish()
|
|
1303
1304
|
})
|
|
1304
1305
|
]);
|
|
1305
|
-
const mistralConversationMessageContentSchema = z.union([z.string(), z.array(mistralConversationContentSchema)]);
|
|
1306
|
-
const mistralConversationToolExecutionSchema = z.object({
|
|
1306
|
+
const mistralConversationMessageContentSchema = () => z.union([z.string(), z.array(mistralConversationContentSchema())]);
|
|
1307
|
+
const mistralConversationToolExecutionSchema = () => z.object({
|
|
1307
1308
|
type: z.literal("tool.execution"),
|
|
1308
1309
|
id: z.string(),
|
|
1309
1310
|
name: z.string(),
|
|
@@ -1311,31 +1312,31 @@ const mistralConversationToolExecutionSchema = z.object({
|
|
|
1311
1312
|
function: z.string().nullish(),
|
|
1312
1313
|
info: z.record(z.string(), z.json()).nullish()
|
|
1313
1314
|
});
|
|
1314
|
-
const mistralConversationFunctionCallSchema = z.object({
|
|
1315
|
+
const mistralConversationFunctionCallSchema = () => z.object({
|
|
1315
1316
|
type: z.literal("function.call"),
|
|
1316
1317
|
tool_call_id: z.string(),
|
|
1317
1318
|
name: z.string(),
|
|
1318
1319
|
arguments: z.union([z.string(), z.record(z.string(), z.json())])
|
|
1319
1320
|
});
|
|
1320
|
-
const mistralConversationUsageSchema = mistralUsageSchema.extend({
|
|
1321
|
+
const mistralConversationUsageSchema = () => mistralUsageSchema.extend({
|
|
1321
1322
|
prompt_tokens: z.number().default(0),
|
|
1322
1323
|
completion_tokens: z.number().default(0),
|
|
1323
1324
|
total_tokens: z.number().default(0)
|
|
1324
1325
|
});
|
|
1325
|
-
const mistralConversationResponseSchema = z.object({
|
|
1326
|
+
const mistralConversationResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
1326
1327
|
conversation_id: z.string(),
|
|
1327
1328
|
outputs: z.array(z.discriminatedUnion("type", [
|
|
1328
|
-
mistralConversationToolExecutionSchema,
|
|
1329
|
-
mistralConversationFunctionCallSchema,
|
|
1329
|
+
mistralConversationToolExecutionSchema(),
|
|
1330
|
+
mistralConversationFunctionCallSchema(),
|
|
1330
1331
|
z.object({
|
|
1331
1332
|
type: z.literal("message.output"),
|
|
1332
|
-
content: mistralConversationMessageContentSchema,
|
|
1333
|
+
content: mistralConversationMessageContentSchema(),
|
|
1333
1334
|
model: z.string().nullish()
|
|
1334
1335
|
})
|
|
1335
1336
|
])),
|
|
1336
|
-
usage: mistralConversationUsageSchema.nullish()
|
|
1337
|
-
});
|
|
1338
|
-
const mistralConversationChunkSchema = z.discriminatedUnion("type", [
|
|
1337
|
+
usage: mistralConversationUsageSchema().nullish()
|
|
1338
|
+
})));
|
|
1339
|
+
const mistralConversationChunkSchema = lazySchema(() => zodSchema(z.discriminatedUnion("type", [
|
|
1339
1340
|
z.object({
|
|
1340
1341
|
type: z.literal("conversation.response.started"),
|
|
1341
1342
|
conversation_id: z.string(),
|
|
@@ -1343,7 +1344,7 @@ const mistralConversationChunkSchema = z.discriminatedUnion("type", [
|
|
|
1343
1344
|
}),
|
|
1344
1345
|
z.object({
|
|
1345
1346
|
type: z.literal("conversation.response.done"),
|
|
1346
|
-
usage: mistralConversationUsageSchema.nullish()
|
|
1347
|
+
usage: mistralConversationUsageSchema().nullish()
|
|
1347
1348
|
}),
|
|
1348
1349
|
z.object({
|
|
1349
1350
|
type: z.literal("conversation.response.error"),
|
|
@@ -1354,7 +1355,7 @@ const mistralConversationChunkSchema = z.discriminatedUnion("type", [
|
|
|
1354
1355
|
type: z.literal("message.output.delta"),
|
|
1355
1356
|
id: z.string(),
|
|
1356
1357
|
content_index: z.number().nullish(),
|
|
1357
|
-
content: z.union([z.string(), mistralConversationContentSchema]),
|
|
1358
|
+
content: z.union([z.string(), mistralConversationContentSchema()]),
|
|
1358
1359
|
model: z.string().nullish()
|
|
1359
1360
|
}),
|
|
1360
1361
|
z.object({
|
|
@@ -1378,7 +1379,7 @@ const mistralConversationChunkSchema = z.discriminatedUnion("type", [
|
|
|
1378
1379
|
function: z.string().nullish(),
|
|
1379
1380
|
info: z.record(z.string(), z.json()).nullish()
|
|
1380
1381
|
})
|
|
1381
|
-
]);
|
|
1382
|
+
])));
|
|
1382
1383
|
//#endregion
|
|
1383
1384
|
//#region src/mistral-embedding-model-options.ts
|
|
1384
1385
|
const mistralEmbeddingModelOptions = z.object({
|
|
@@ -1462,19 +1463,19 @@ var MistralEmbeddingModel = class MistralEmbeddingModel {
|
|
|
1462
1463
|
};
|
|
1463
1464
|
}
|
|
1464
1465
|
};
|
|
1465
|
-
const MistralTextEmbeddingResponseSchema = z.object({
|
|
1466
|
+
const MistralTextEmbeddingResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
1466
1467
|
data: z.array(z.object({ embedding: z.array(z.number()) })),
|
|
1467
1468
|
usage: z.object({ prompt_tokens: z.number() }).nullish()
|
|
1468
|
-
});
|
|
1469
|
+
})));
|
|
1469
1470
|
//#endregion
|
|
1470
1471
|
//#region src/mistral-speech-model-options.ts
|
|
1471
|
-
const mistralSpeechModelOptions = z.object({
|
|
1472
|
+
const mistralSpeechModelOptions = lazySchema(() => zodSchema(z.object({
|
|
1472
1473
|
/**
|
|
1473
1474
|
* Base64-encoded reference audio for one-off voice cloning.
|
|
1474
1475
|
*
|
|
1475
1476
|
* When provided, this takes precedence over the standard `voice` option.
|
|
1476
1477
|
*/
|
|
1477
|
-
refAudio: z.string().min(1).optional() });
|
|
1478
|
+
refAudio: z.string().min(1).optional() })));
|
|
1478
1479
|
//#endregion
|
|
1479
1480
|
//#region src/mistral-speech-model.ts
|
|
1480
1481
|
var MistralSpeechModel = class MistralSpeechModel {
|
|
@@ -1576,7 +1577,7 @@ var MistralSpeechModel = class MistralSpeechModel {
|
|
|
1576
1577
|
};
|
|
1577
1578
|
}
|
|
1578
1579
|
};
|
|
1579
|
-
const mistralSpeechResponseSchema = z.object({ audio_data: z.string() });
|
|
1580
|
+
const mistralSpeechResponseSchema = lazySchema(() => zodSchema(z.object({ audio_data: z.string() })));
|
|
1580
1581
|
//#endregion
|
|
1581
1582
|
//#region src/mistral-transcription-model-options.ts
|
|
1582
1583
|
const mistralTranscriptionModelOptions = lazySchema(() => zodSchema(z.object({
|
|
@@ -1712,7 +1713,7 @@ function appendFormValue(formData, key, value) {
|
|
|
1712
1713
|
}
|
|
1713
1714
|
formData.append(key, String(value));
|
|
1714
1715
|
}
|
|
1715
|
-
const mistralTranscriptionResponseSchema = z.object({
|
|
1716
|
+
const mistralTranscriptionResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
1716
1717
|
model: z.string(),
|
|
1717
1718
|
text: z.string(),
|
|
1718
1719
|
language: z.string().nullish(),
|
|
@@ -1731,10 +1732,10 @@ const mistralTranscriptionResponseSchema = z.object({
|
|
|
1731
1732
|
prompt_audio_seconds: z.number().nullish(),
|
|
1732
1733
|
request_count: z.number().nullish()
|
|
1733
1734
|
}).nullish()
|
|
1734
|
-
});
|
|
1735
|
+
})));
|
|
1735
1736
|
//#endregion
|
|
1736
1737
|
//#region src/version.ts
|
|
1737
|
-
const VERSION = "4.0.
|
|
1738
|
+
const VERSION = "4.0.69";
|
|
1738
1739
|
//#endregion
|
|
1739
1740
|
//#region src/tool/web-search.ts
|
|
1740
1741
|
const inputSchema = lazySchema(() => zodSchema(z.object({ arguments: z.string() })));
|