@ai-sdk/mistral 4.0.76 → 4.0.77
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 +6 -0
- package/dist/index.js +212 -59
- package/dist/index.js.map +1 -1
- package/docs/20-mistral.mdx +20 -3
- package/package.json +1 -1
- package/src/mistral-chat-language-model.ts +7 -39
- package/src/mistral-conversation-language-model.ts +8 -26
- package/src/mistral-model-catalog.ts +401 -0
- package/src/mistral-speech-model.ts +4 -2
- package/src/mistral-transcription-model.ts +3 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @ai-sdk/mistral
|
|
2
2
|
|
|
3
|
+
## 4.0.77
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 19cb252: Centralize Mistral model capabilities and provider option support in a model catalog shared by request preparation and generated documentation, preserving Chat and Conversations reasoning policies and legacy transcription restrictions.
|
|
8
|
+
|
|
3
9
|
## 4.0.76
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -292,7 +292,49 @@ function prepareTools({ tools, toolChoice }) {
|
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
294
|
//#endregion
|
|
295
|
-
//#region src/mistral-
|
|
295
|
+
//#region src/mistral-model-catalog.ts
|
|
296
|
+
const mistralProviderOptions = {
|
|
297
|
+
language: {
|
|
298
|
+
safePrompt: { description: "Inject a safety prompt. Chat API only." },
|
|
299
|
+
documentImageLimit: { description: "Maximum document images. Chat API only." },
|
|
300
|
+
documentPageLimit: { description: "Maximum document pages. Chat API only." },
|
|
301
|
+
structuredOutputs: { description: "Whether to send a JSON response schema." },
|
|
302
|
+
strictJsonSchema: { description: "Whether to use strict JSON schema validation." },
|
|
303
|
+
parallelToolCalls: { description: "Allow parallel function calls. Chat API only." },
|
|
304
|
+
promptCacheKey: { description: "Cache affinity key. Chat API only." },
|
|
305
|
+
reasoningEffort: { description: "Reasoning effort for configurable reasoning models." }
|
|
306
|
+
},
|
|
307
|
+
embedding: {
|
|
308
|
+
metadata: { description: "Metadata attached to the embedding request." },
|
|
309
|
+
outputDimension: { description: "Output embedding dimensions." },
|
|
310
|
+
outputDtype: { description: "Output embedding data type." }
|
|
311
|
+
},
|
|
312
|
+
transcription: {
|
|
313
|
+
language: { description: "Language of the audio." },
|
|
314
|
+
returnLanguage: { description: "Return the detected language." },
|
|
315
|
+
temperature: { description: "Sampling temperature." },
|
|
316
|
+
timestampGranularities: { description: "Timestamp granularities to return." },
|
|
317
|
+
diarize: { description: "Identify speakers in the transcription." },
|
|
318
|
+
contextBias: { description: "Vocabulary and context to guide transcription." }
|
|
319
|
+
},
|
|
320
|
+
speech: {
|
|
321
|
+
refAudio: { description: "Reference audio for voice cloning, overriding voice." },
|
|
322
|
+
expressiveness: { description: "Speech expressiveness, from 1 to 5." },
|
|
323
|
+
phonemeHints: { description: "Pronunciation hints as IPA phonemes." }
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
const documentedLanguageModels = {
|
|
327
|
+
"labs-leanstral-1-5": true,
|
|
328
|
+
"magistral-medium-latest": true,
|
|
329
|
+
"magistral-small-latest": true,
|
|
330
|
+
"ministral-14b-latest": true,
|
|
331
|
+
"ministral-8b-latest": true,
|
|
332
|
+
"mistral-large-latest": true,
|
|
333
|
+
"mistral-medium-latest": true,
|
|
334
|
+
"mistral-small-latest": true,
|
|
335
|
+
"voxtral-small-latest": false,
|
|
336
|
+
"zai-glm-5-2": false
|
|
337
|
+
};
|
|
296
338
|
const modelsWithoutReasoningEffort = /* @__PURE__ */ new Set([
|
|
297
339
|
"codestral-2508",
|
|
298
340
|
"codestral-latest",
|
|
@@ -315,6 +357,159 @@ const modelsWithLowHighMaxReasoningEffort = /* @__PURE__ */ new Set([
|
|
|
315
357
|
"zai-glm-5-3-flash",
|
|
316
358
|
"zai-glm-latest"
|
|
317
359
|
]);
|
|
360
|
+
const reasoningEffortModelIds = /* @__PURE__ */ new Set([
|
|
361
|
+
"glm-5-2",
|
|
362
|
+
"labs-leanstral-1-5",
|
|
363
|
+
"labs-leanstral-1-5-1",
|
|
364
|
+
"magistral-medium-latest",
|
|
365
|
+
"magistral-small-latest",
|
|
366
|
+
"mistral-large-4",
|
|
367
|
+
"mistral-large-4-0",
|
|
368
|
+
"mistral-medium",
|
|
369
|
+
"mistral-medium-2604",
|
|
370
|
+
"mistral-medium-3",
|
|
371
|
+
"mistral-medium-3-5",
|
|
372
|
+
"mistral-medium-3.5",
|
|
373
|
+
"mistral-medium-latest",
|
|
374
|
+
"mistral-small-2603",
|
|
375
|
+
"mistral-small-latest",
|
|
376
|
+
"mistral-vibe-cli-fast",
|
|
377
|
+
"mistral-vibe-cli-latest",
|
|
378
|
+
"mistral-vibe-cli-with-tools",
|
|
379
|
+
"zai-glm-5-2"
|
|
380
|
+
]);
|
|
381
|
+
function reasoningCapabilities(efforts) {
|
|
382
|
+
return {
|
|
383
|
+
support: efforts.length > 0,
|
|
384
|
+
efforts
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
function createLanguageModelEntry(modelId, image) {
|
|
388
|
+
const reasoning = reasoningCapabilities(modelsWithoutReasoningEffort.has(modelId) ? [] : modelsWithLowHighMaxReasoningEffort.has(modelId) ? [
|
|
389
|
+
"low",
|
|
390
|
+
"high",
|
|
391
|
+
"max"
|
|
392
|
+
] : ["none", "high"]);
|
|
393
|
+
const conversationReasoning = reasoningCapabilities(reasoningEffortModelIds.has(modelId) ? ["none", "high"] : []);
|
|
394
|
+
const chatOnly = { condition: "Only supported on the Chat API." };
|
|
395
|
+
return {
|
|
396
|
+
capabilities: { language: {
|
|
397
|
+
inputs: {
|
|
398
|
+
image: image ?? "unknown",
|
|
399
|
+
audio: "unknown"
|
|
400
|
+
},
|
|
401
|
+
objectGeneration: image != null ? true : "unknown",
|
|
402
|
+
tools: {
|
|
403
|
+
usage: image != null ? true : "unknown",
|
|
404
|
+
streaming: image != null ? true : "unknown"
|
|
405
|
+
},
|
|
406
|
+
reasoning,
|
|
407
|
+
sampling: {
|
|
408
|
+
temperature: "unknown",
|
|
409
|
+
topP: "unknown",
|
|
410
|
+
logprobs: false
|
|
411
|
+
},
|
|
412
|
+
endpoints: { conversation: { reasoning: conversationReasoning } }
|
|
413
|
+
} },
|
|
414
|
+
providerOptions: { language: declareProviderOptions(mistralProviderOptions.language, image != null ? true : "unknown", {
|
|
415
|
+
safePrompt: chatOnly,
|
|
416
|
+
documentImageLimit: chatOnly,
|
|
417
|
+
documentPageLimit: chatOnly,
|
|
418
|
+
parallelToolCalls: chatOnly,
|
|
419
|
+
promptCacheKey: chatOnly,
|
|
420
|
+
reasoningEffort: reasoning.support && !conversationReasoning.support ? chatOnly : reasoning.support
|
|
421
|
+
}) }
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
function createTranscriptionModelEntry(modelId, declared) {
|
|
425
|
+
const languageWithTimestamps = ![
|
|
426
|
+
"voxtral-mini-2507",
|
|
427
|
+
"voxtral-mini-2602",
|
|
428
|
+
"voxtral-mini-latest"
|
|
429
|
+
].includes(modelId);
|
|
430
|
+
const support = declared ? true : "unknown";
|
|
431
|
+
return {
|
|
432
|
+
capabilities: { transcription: {
|
|
433
|
+
transcription: support,
|
|
434
|
+
streaming: false,
|
|
435
|
+
duration: support,
|
|
436
|
+
segments: support,
|
|
437
|
+
language: support,
|
|
438
|
+
languageWithTimestamps,
|
|
439
|
+
timestamps: support,
|
|
440
|
+
diarization: support,
|
|
441
|
+
contextBias: support
|
|
442
|
+
} },
|
|
443
|
+
providerOptions: { transcription: declareProviderOptions(mistralProviderOptions.transcription, support, {
|
|
444
|
+
returnLanguage: { condition: "Only supported when language is not pinned." },
|
|
445
|
+
timestampGranularities: languageWithTimestamps ? support : { condition: "Only supported when language is not pinned." }
|
|
446
|
+
}) }
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
function createSpeechModelEntry(declared) {
|
|
450
|
+
const support = declared ? true : "unknown";
|
|
451
|
+
return {
|
|
452
|
+
capabilities: { speech: {
|
|
453
|
+
instructions: false,
|
|
454
|
+
savedVoices: support,
|
|
455
|
+
referenceAudio: support,
|
|
456
|
+
nonStreaming: true,
|
|
457
|
+
outputFormats: [
|
|
458
|
+
"pcm",
|
|
459
|
+
"wav",
|
|
460
|
+
"mp3",
|
|
461
|
+
"flac",
|
|
462
|
+
"opus"
|
|
463
|
+
]
|
|
464
|
+
} },
|
|
465
|
+
providerOptions: { speech: declareProviderOptions(mistralProviderOptions.speech, support, {}) }
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
function createEmbeddingModelEntry(defaultDimensions, customDimensions) {
|
|
469
|
+
return {
|
|
470
|
+
capabilities: { embedding: {
|
|
471
|
+
defaultDimensions,
|
|
472
|
+
customDimensions
|
|
473
|
+
} },
|
|
474
|
+
providerOptions: { embedding: declareProviderOptions(mistralProviderOptions.embedding, true, {
|
|
475
|
+
outputDimension: customDimensions,
|
|
476
|
+
outputDtype: customDimensions
|
|
477
|
+
}) }
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
const mistralModelCatalog = {
|
|
481
|
+
...Object.fromEntries(Object.entries(documentedLanguageModels).map(([modelId, image]) => [modelId, createLanguageModelEntry(modelId, image)])),
|
|
482
|
+
"voxtral-mini-transcribe-3-0": createTranscriptionModelEntry("voxtral-mini-transcribe-3-0", true),
|
|
483
|
+
"voxtral-small-transcribe-3-0": createTranscriptionModelEntry("voxtral-small-transcribe-3-0", true),
|
|
484
|
+
"voxtral-mini-latest": createTranscriptionModelEntry("voxtral-mini-latest", true),
|
|
485
|
+
"voxtral-mini-tts-3-0": createSpeechModelEntry(true),
|
|
486
|
+
"voxtral-mini-tts-2603": createSpeechModelEntry(true),
|
|
487
|
+
"mistral-embed": createEmbeddingModelEntry(1024, false),
|
|
488
|
+
"codestral-embed": createEmbeddingModelEntry(1536, true)
|
|
489
|
+
};
|
|
490
|
+
function findModelEntry(modelId) {
|
|
491
|
+
return Object.prototype.hasOwnProperty.call(mistralModelCatalog, modelId) ? mistralModelCatalog[modelId] : void 0;
|
|
492
|
+
}
|
|
493
|
+
function getMistralLanguageModelEntry(modelId) {
|
|
494
|
+
const entry = findModelEntry(modelId);
|
|
495
|
+
return entry?.capabilities.language != null && entry.providerOptions?.language != null ? {
|
|
496
|
+
capabilities: { language: entry.capabilities.language },
|
|
497
|
+
providerOptions: { language: entry.providerOptions.language }
|
|
498
|
+
} : createLanguageModelEntry(modelId);
|
|
499
|
+
}
|
|
500
|
+
function getMistralTranscriptionModelEntry(modelId) {
|
|
501
|
+
const capabilities = findModelEntry(modelId)?.capabilities.transcription;
|
|
502
|
+
return capabilities != null ? { capabilities: { transcription: capabilities } } : createTranscriptionModelEntry(modelId, false);
|
|
503
|
+
}
|
|
504
|
+
function getMistralSpeechModelEntry(modelId) {
|
|
505
|
+
const capabilities = findModelEntry(modelId)?.capabilities.speech;
|
|
506
|
+
return capabilities != null ? { capabilities: { speech: capabilities } } : createSpeechModelEntry(false);
|
|
507
|
+
}
|
|
508
|
+
function declareProviderOptions(definitions, support, exceptions) {
|
|
509
|
+
return Object.fromEntries(Object.keys(definitions).map((option) => [option, exceptions[option] ?? support]));
|
|
510
|
+
}
|
|
511
|
+
//#endregion
|
|
512
|
+
//#region src/mistral-chat-language-model.ts
|
|
318
513
|
var MistralChatLanguageModel = class MistralChatLanguageModel {
|
|
319
514
|
static [WORKFLOW_SERIALIZE](model) {
|
|
320
515
|
return serializeModelOptions({
|
|
@@ -346,24 +541,15 @@ var MistralChatLanguageModel = class MistralChatLanguageModel {
|
|
|
346
541
|
type: "unsupported",
|
|
347
542
|
feature: "topK"
|
|
348
543
|
});
|
|
349
|
-
const
|
|
544
|
+
const { reasoning: reasoningCapabilities } = getMistralLanguageModelEntry(this.modelId).capabilities.language;
|
|
350
545
|
let resolvedReasoningEffort;
|
|
351
|
-
if (
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
high: "high",
|
|
359
|
-
max: "max"
|
|
360
|
-
} : {
|
|
361
|
-
none: "none",
|
|
362
|
-
high: "high"
|
|
363
|
-
},
|
|
364
|
-
warnings
|
|
365
|
-
});
|
|
366
|
-
} else if (isCustomReasoning(reasoning)) warnings.push({
|
|
546
|
+
if (reasoningCapabilities.support) resolvedReasoningEffort = mapReasoningToProviderEffort({
|
|
547
|
+
reasoning,
|
|
548
|
+
providerOptionsEffort: options.reasoningEffort,
|
|
549
|
+
effortMap: Object.fromEntries(reasoningCapabilities.efforts.map((effort) => [effort, effort])),
|
|
550
|
+
warnings
|
|
551
|
+
});
|
|
552
|
+
else if (isCustomReasoning(reasoning)) warnings.push({
|
|
367
553
|
type: "unsupported",
|
|
368
554
|
feature: "reasoning",
|
|
369
555
|
details: "This model does not support reasoning configuration."
|
|
@@ -875,27 +1061,6 @@ function prepareConversationTools({ tools, toolChoice }) {
|
|
|
875
1061
|
}
|
|
876
1062
|
//#endregion
|
|
877
1063
|
//#region src/mistral-conversation-language-model.ts
|
|
878
|
-
const reasoningEffortModelIds = /* @__PURE__ */ new Set([
|
|
879
|
-
"glm-5-2",
|
|
880
|
-
"labs-leanstral-1-5",
|
|
881
|
-
"labs-leanstral-1-5-1",
|
|
882
|
-
"magistral-medium-latest",
|
|
883
|
-
"magistral-small-latest",
|
|
884
|
-
"mistral-large-4",
|
|
885
|
-
"mistral-large-4-0",
|
|
886
|
-
"mistral-medium",
|
|
887
|
-
"mistral-medium-2604",
|
|
888
|
-
"mistral-medium-3",
|
|
889
|
-
"mistral-medium-3-5",
|
|
890
|
-
"mistral-medium-3.5",
|
|
891
|
-
"mistral-medium-latest",
|
|
892
|
-
"mistral-small-2603",
|
|
893
|
-
"mistral-small-latest",
|
|
894
|
-
"mistral-vibe-cli-fast",
|
|
895
|
-
"mistral-vibe-cli-latest",
|
|
896
|
-
"mistral-vibe-cli-with-tools",
|
|
897
|
-
"zai-glm-5-2"
|
|
898
|
-
]);
|
|
899
1064
|
var MistralConversationLanguageModel = class MistralConversationLanguageModel {
|
|
900
1065
|
static [WORKFLOW_SERIALIZE](model) {
|
|
901
1066
|
return serializeModelOptions({
|
|
@@ -927,15 +1092,12 @@ var MistralConversationLanguageModel = class MistralConversationLanguageModel {
|
|
|
927
1092
|
type: "unsupported",
|
|
928
1093
|
feature: "topK"
|
|
929
1094
|
});
|
|
930
|
-
const
|
|
1095
|
+
const { reasoning: reasoningCapabilities } = getMistralLanguageModelEntry(this.modelId).capabilities.language.endpoints.conversation;
|
|
931
1096
|
let resolvedReasoningEffort;
|
|
932
|
-
if (
|
|
1097
|
+
if (reasoningCapabilities.support) resolvedReasoningEffort = mapReasoningToProviderEffort({
|
|
933
1098
|
reasoning,
|
|
934
1099
|
providerOptionsEffort: options.reasoningEffort,
|
|
935
|
-
effortMap:
|
|
936
|
-
none: "none",
|
|
937
|
-
high: "high"
|
|
938
|
-
},
|
|
1100
|
+
effortMap: Object.fromEntries(reasoningCapabilities.efforts.map((effort) => [effort, effort])),
|
|
939
1101
|
warnings
|
|
940
1102
|
});
|
|
941
1103
|
else if (isCustomReasoning(reasoning)) warnings.push({
|
|
@@ -1532,20 +1694,15 @@ var MistralSpeechModel = class MistralSpeechModel {
|
|
|
1532
1694
|
providerOptions,
|
|
1533
1695
|
schema: mistralSpeechModelOptions
|
|
1534
1696
|
});
|
|
1697
|
+
const { speech } = getMistralSpeechModelEntry(this.modelId).capabilities;
|
|
1535
1698
|
let responseFormat = "mp3";
|
|
1536
|
-
if (
|
|
1537
|
-
"pcm",
|
|
1538
|
-
"wav",
|
|
1539
|
-
"mp3",
|
|
1540
|
-
"flac",
|
|
1541
|
-
"opus"
|
|
1542
|
-
].includes(outputFormat)) responseFormat = outputFormat;
|
|
1699
|
+
if (speech.outputFormats.includes(outputFormat)) responseFormat = outputFormat;
|
|
1543
1700
|
else warnings.push({
|
|
1544
1701
|
type: "unsupported",
|
|
1545
1702
|
feature: "outputFormat",
|
|
1546
1703
|
details: `Unsupported output format: ${outputFormat}. Using mp3 instead.`
|
|
1547
1704
|
});
|
|
1548
|
-
if (instructions != null) warnings.push({
|
|
1705
|
+
if (speech.instructions === false && instructions != null) warnings.push({
|
|
1549
1706
|
type: "unsupported",
|
|
1550
1707
|
feature: "instructions",
|
|
1551
1708
|
details: "Mistral speech models do not support the `instructions` option. Use a reference audio clip to guide delivery."
|
|
@@ -1672,11 +1829,7 @@ var MistralTranscriptionModel = class MistralTranscriptionModel {
|
|
|
1672
1829
|
providerOptions,
|
|
1673
1830
|
schema: mistralTranscriptionModelOptions
|
|
1674
1831
|
});
|
|
1675
|
-
if (
|
|
1676
|
-
"voxtral-mini-2507",
|
|
1677
|
-
"voxtral-mini-2602",
|
|
1678
|
-
"voxtral-mini-latest"
|
|
1679
|
-
].includes(this.modelId) && mistralOptions?.language != null && mistralOptions.timestampGranularities != null) throw new InvalidArgumentError({
|
|
1832
|
+
if (!getMistralTranscriptionModelEntry(this.modelId).capabilities.transcription.languageWithTimestamps && mistralOptions?.language != null && mistralOptions.timestampGranularities != null) throw new InvalidArgumentError({
|
|
1680
1833
|
argument: "providerOptions",
|
|
1681
1834
|
message: "providerOptions.mistral.language cannot be combined with providerOptions.mistral.timestampGranularities"
|
|
1682
1835
|
});
|
|
@@ -1782,7 +1935,7 @@ const mistralTranscriptionResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
|
1782
1935
|
})));
|
|
1783
1936
|
//#endregion
|
|
1784
1937
|
//#region src/version.ts
|
|
1785
|
-
const VERSION = "4.0.
|
|
1938
|
+
const VERSION = "4.0.77";
|
|
1786
1939
|
//#endregion
|
|
1787
1940
|
//#region src/tool/web-search.ts
|
|
1788
1941
|
const inputSchema = lazySchema(() => zodSchema(z.object({ arguments: z.string() })));
|