@ai-sdk/mistral 4.0.68 → 4.0.70
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 +26 -0
- package/dist/index.d.ts +11 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +79 -45
- package/dist/index.js.map +1 -1
- package/docs/20-mistral.mdx +113 -23
- package/package.json +3 -3
- package/src/mistral-chat-language-model-options.ts +47 -42
- package/src/mistral-chat-language-model.ts +107 -88
- 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 +34 -9
- package/src/mistral-speech-model.ts +11 -3
- package/src/mistral-transcription-model-options.ts +17 -14
- package/src/mistral-transcription-model.ts +52 -28
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @ai-sdk/mistral
|
|
2
2
|
|
|
3
|
+
## 4.0.70
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e104368: Add Voxtral 3 offline transcription and speech model IDs. Support transcription context phrases and detected language, update timestamp validation for Voxtral 3, and expose speech expressiveness and pronunciation hints.
|
|
8
|
+
- 43ad966: Report `interrupted` when a stream ends cleanly without its provider completion signal, preserving partial output without emitting an error solely for the interruption.
|
|
9
|
+
|
|
10
|
+
This applies to OpenAI (Chat, Responses, and Completions), Anthropic, Google (Generate Content and Interactions), Alibaba, Amazon Bedrock Converse, Cohere, DeepSeek, Groq, Hugging Face Responses, Mistral Chat, Moonshot AI, Open Responses, Perplexity, and xAI Responses. It also covers cutoffs in later Anthropic messages and Google automatic continuations.
|
|
11
|
+
|
|
12
|
+
**Compatibility notice:** These streams previously fell back to `other` or omitted the finish part. Applications must now handle `interrupted` in finish-reason switches, mappings, and custom validation. Check `finishReason === 'interrupted'` to detect incomplete responses; interruption alone does not trigger error handling.
|
|
13
|
+
|
|
14
|
+
Explicit unknown completion reasons still map to `other`. Actual provider, parsing, and transport errors retain their error paths; affected error paths that previously left the finish reason as `other` now report `error`. OpenAI-compatible remains unchanged.
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [10026d1]
|
|
17
|
+
- @ai-sdk/provider@4.0.32
|
|
18
|
+
- @ai-sdk/provider-utils@5.0.66
|
|
19
|
+
|
|
20
|
+
## 4.0.69
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- 77b925f: Defer construction of provider validation schemas until first use to reduce package import time.
|
|
25
|
+
- Updated dependencies [b089ce8]
|
|
26
|
+
- Updated dependencies [39a776b]
|
|
27
|
+
- @ai-sdk/provider-utils@5.0.65
|
|
28
|
+
|
|
3
29
|
## 4.0.68
|
|
4
30
|
|
|
5
31
|
### 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 & {});
|
|
@@ -34,16 +34,19 @@ declare const mistralEmbeddingModelOptions: z.ZodObject<{
|
|
|
34
34
|
type MistralEmbeddingModelOptions = z.infer<typeof mistralEmbeddingModelOptions>;
|
|
35
35
|
//#endregion
|
|
36
36
|
//#region src/mistral-speech-model-options.d.ts
|
|
37
|
-
type MistralSpeechModelId = 'voxtral-mini-tts-2603' | 'voxtral-mini-tts-latest' | (string & {});
|
|
38
|
-
declare const mistralSpeechModelOptions:
|
|
39
|
-
refAudio
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
type MistralSpeechModelId = 'voxtral-mini-tts-2603' | 'voxtral-mini-tts-3-0' | 'voxtral-mini-tts-3' | 'voxtral-mini-tts-latest' | (string & {});
|
|
38
|
+
declare const mistralSpeechModelOptions: import("@ai-sdk/provider-utils").LazySchema<{
|
|
39
|
+
refAudio?: string | undefined;
|
|
40
|
+
expressiveness?: number | undefined;
|
|
41
|
+
phonemeHints?: Record<string, string[]> | undefined;
|
|
42
|
+
}>;
|
|
43
|
+
type MistralSpeechModelOptions = InferSchema<typeof mistralSpeechModelOptions>;
|
|
42
44
|
//#endregion
|
|
43
45
|
//#region src/mistral-transcription-model-options.d.ts
|
|
44
|
-
type MistralTranscriptionModelId = 'voxtral-mini-2602' | 'voxtral-mini-latest' | (string & {});
|
|
46
|
+
type MistralTranscriptionModelId = 'voxtral-mini-2602' | 'voxtral-mini-latest' | 'voxtral-mini-transcribe-3-0' | 'voxtral-mini-transcribe-3' | 'voxtral-mini-transcribe-latest' | 'voxtral-small-transcribe-3-0' | 'voxtral-small-transcribe-3' | 'voxtral-small-transcribe-latest' | (string & {});
|
|
45
47
|
declare const mistralTranscriptionModelOptions: import("@ai-sdk/provider-utils").LazySchema<{
|
|
46
48
|
language?: string | undefined;
|
|
49
|
+
returnLanguage?: boolean | undefined;
|
|
47
50
|
temperature?: number | undefined;
|
|
48
51
|
timestampGranularities?: ("segment" | "word")[] | undefined;
|
|
49
52
|
diarize?: boolean | undefined;
|
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;cAOC,4DAAyB;;;iBAAzB;;KA2BD,4BAA4B,mBAC/B;;;KCnCG;cAYC,mEAAgC;;;;;;;;KA+CjC,mCAAmC,mBACtC;;;cCjEI;;;;;;;;;;;;;;;;;;;;;;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",
|
|
@@ -466,7 +467,7 @@ var MistralChatLanguageModel = class MistralChatLanguageModel {
|
|
|
466
467
|
fetch: this.config.fetch
|
|
467
468
|
});
|
|
468
469
|
let finishReason = {
|
|
469
|
-
unified: "
|
|
470
|
+
unified: "interrupted",
|
|
470
471
|
raw: void 0
|
|
471
472
|
};
|
|
472
473
|
let usage = void 0;
|
|
@@ -490,6 +491,10 @@ var MistralChatLanguageModel = class MistralChatLanguageModel {
|
|
|
490
491
|
rawValue: chunk.rawValue
|
|
491
492
|
});
|
|
492
493
|
if (!chunk.success) {
|
|
494
|
+
finishReason = {
|
|
495
|
+
unified: "error",
|
|
496
|
+
raw: void 0
|
|
497
|
+
};
|
|
493
498
|
controller.enqueue({
|
|
494
499
|
type: "error",
|
|
495
500
|
error: chunk.error
|
|
@@ -604,7 +609,7 @@ function extractTextContent(content) {
|
|
|
604
609
|
}
|
|
605
610
|
return textContent.length ? textContent.join("") : void 0;
|
|
606
611
|
}
|
|
607
|
-
const mistralContentSchema = z.union([z.string(), z.array(z.discriminatedUnion("type", [
|
|
612
|
+
const mistralContentSchema = () => z.union([z.string(), z.array(z.discriminatedUnion("type", [
|
|
608
613
|
z.object({
|
|
609
614
|
type: z.literal("text"),
|
|
610
615
|
text: z.string()
|
|
@@ -628,14 +633,14 @@ const mistralContentSchema = z.union([z.string(), z.array(z.discriminatedUnion("
|
|
|
628
633
|
}))
|
|
629
634
|
})
|
|
630
635
|
]))]).nullish();
|
|
631
|
-
const mistralChatResponseSchema = z.object({
|
|
636
|
+
const mistralChatResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
632
637
|
id: z.string().nullish(),
|
|
633
638
|
created: z.number().nullish(),
|
|
634
639
|
model: z.string().nullish(),
|
|
635
640
|
choices: z.array(z.object({
|
|
636
641
|
message: z.object({
|
|
637
642
|
role: z.literal("assistant"),
|
|
638
|
-
content: mistralContentSchema,
|
|
643
|
+
content: mistralContentSchema(),
|
|
639
644
|
tool_calls: z.array(z.object({
|
|
640
645
|
id: z.string(),
|
|
641
646
|
function: z.object({
|
|
@@ -649,15 +654,15 @@ const mistralChatResponseSchema = z.object({
|
|
|
649
654
|
})),
|
|
650
655
|
object: z.literal("chat.completion"),
|
|
651
656
|
usage: mistralUsageSchema
|
|
652
|
-
});
|
|
653
|
-
const mistralChatChunkSchema = z.object({
|
|
657
|
+
})));
|
|
658
|
+
const mistralChatChunkSchema = lazySchema(() => zodSchema(z.object({
|
|
654
659
|
id: z.string().nullish(),
|
|
655
660
|
created: z.number().nullish(),
|
|
656
661
|
model: z.string().nullish(),
|
|
657
662
|
choices: z.array(z.object({
|
|
658
663
|
delta: z.object({
|
|
659
664
|
role: z.enum(["assistant"]).optional(),
|
|
660
|
-
content: mistralContentSchema,
|
|
665
|
+
content: mistralContentSchema(),
|
|
661
666
|
tool_calls: z.array(z.object({
|
|
662
667
|
index: z.number().nullish(),
|
|
663
668
|
id: z.string().nullish(),
|
|
@@ -671,7 +676,7 @@ const mistralChatChunkSchema = z.object({
|
|
|
671
676
|
index: z.number()
|
|
672
677
|
})),
|
|
673
678
|
usage: mistralUsageSchema.nullish()
|
|
674
|
-
});
|
|
679
|
+
})));
|
|
675
680
|
//#endregion
|
|
676
681
|
//#region src/convert-to-mistral-conversation-inputs.ts
|
|
677
682
|
function convertToMistralConversationInputs(prompt, toolNameMapping) {
|
|
@@ -785,7 +790,7 @@ function convertToMistralConversationInputs(prompt, toolNameMapping) {
|
|
|
785
790
|
}
|
|
786
791
|
//#endregion
|
|
787
792
|
//#region src/mistral-conversation-language-model-options.ts
|
|
788
|
-
const mistralLanguageModelConversationOptions = mistralLanguageModelChatOptions;
|
|
793
|
+
const mistralLanguageModelConversationOptions = lazySchema(() => zodSchema(mistralLanguageModelChatOptions()));
|
|
789
794
|
//#endregion
|
|
790
795
|
//#region src/mistral-conversation-prepare-tools.ts
|
|
791
796
|
const mistralProviderToolNames = {
|
|
@@ -1283,7 +1288,7 @@ function createContentConverter({ tools, generateId }) {
|
|
|
1283
1288
|
}
|
|
1284
1289
|
};
|
|
1285
1290
|
}
|
|
1286
|
-
const mistralConversationContentSchema = z.discriminatedUnion("type", [
|
|
1291
|
+
const mistralConversationContentSchema = () => z.discriminatedUnion("type", [
|
|
1287
1292
|
z.object({
|
|
1288
1293
|
type: z.literal("text"),
|
|
1289
1294
|
text: z.string()
|
|
@@ -1302,8 +1307,8 @@ const mistralConversationContentSchema = z.discriminatedUnion("type", [
|
|
|
1302
1307
|
url: z.string().nullish()
|
|
1303
1308
|
})
|
|
1304
1309
|
]);
|
|
1305
|
-
const mistralConversationMessageContentSchema = z.union([z.string(), z.array(mistralConversationContentSchema)]);
|
|
1306
|
-
const mistralConversationToolExecutionSchema = z.object({
|
|
1310
|
+
const mistralConversationMessageContentSchema = () => z.union([z.string(), z.array(mistralConversationContentSchema())]);
|
|
1311
|
+
const mistralConversationToolExecutionSchema = () => z.object({
|
|
1307
1312
|
type: z.literal("tool.execution"),
|
|
1308
1313
|
id: z.string(),
|
|
1309
1314
|
name: z.string(),
|
|
@@ -1311,31 +1316,31 @@ const mistralConversationToolExecutionSchema = z.object({
|
|
|
1311
1316
|
function: z.string().nullish(),
|
|
1312
1317
|
info: z.record(z.string(), z.json()).nullish()
|
|
1313
1318
|
});
|
|
1314
|
-
const mistralConversationFunctionCallSchema = z.object({
|
|
1319
|
+
const mistralConversationFunctionCallSchema = () => z.object({
|
|
1315
1320
|
type: z.literal("function.call"),
|
|
1316
1321
|
tool_call_id: z.string(),
|
|
1317
1322
|
name: z.string(),
|
|
1318
1323
|
arguments: z.union([z.string(), z.record(z.string(), z.json())])
|
|
1319
1324
|
});
|
|
1320
|
-
const mistralConversationUsageSchema = mistralUsageSchema.extend({
|
|
1325
|
+
const mistralConversationUsageSchema = () => mistralUsageSchema.extend({
|
|
1321
1326
|
prompt_tokens: z.number().default(0),
|
|
1322
1327
|
completion_tokens: z.number().default(0),
|
|
1323
1328
|
total_tokens: z.number().default(0)
|
|
1324
1329
|
});
|
|
1325
|
-
const mistralConversationResponseSchema = z.object({
|
|
1330
|
+
const mistralConversationResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
1326
1331
|
conversation_id: z.string(),
|
|
1327
1332
|
outputs: z.array(z.discriminatedUnion("type", [
|
|
1328
|
-
mistralConversationToolExecutionSchema,
|
|
1329
|
-
mistralConversationFunctionCallSchema,
|
|
1333
|
+
mistralConversationToolExecutionSchema(),
|
|
1334
|
+
mistralConversationFunctionCallSchema(),
|
|
1330
1335
|
z.object({
|
|
1331
1336
|
type: z.literal("message.output"),
|
|
1332
|
-
content: mistralConversationMessageContentSchema,
|
|
1337
|
+
content: mistralConversationMessageContentSchema(),
|
|
1333
1338
|
model: z.string().nullish()
|
|
1334
1339
|
})
|
|
1335
1340
|
])),
|
|
1336
|
-
usage: mistralConversationUsageSchema.nullish()
|
|
1337
|
-
});
|
|
1338
|
-
const mistralConversationChunkSchema = z.discriminatedUnion("type", [
|
|
1341
|
+
usage: mistralConversationUsageSchema().nullish()
|
|
1342
|
+
})));
|
|
1343
|
+
const mistralConversationChunkSchema = lazySchema(() => zodSchema(z.discriminatedUnion("type", [
|
|
1339
1344
|
z.object({
|
|
1340
1345
|
type: z.literal("conversation.response.started"),
|
|
1341
1346
|
conversation_id: z.string(),
|
|
@@ -1343,7 +1348,7 @@ const mistralConversationChunkSchema = z.discriminatedUnion("type", [
|
|
|
1343
1348
|
}),
|
|
1344
1349
|
z.object({
|
|
1345
1350
|
type: z.literal("conversation.response.done"),
|
|
1346
|
-
usage: mistralConversationUsageSchema.nullish()
|
|
1351
|
+
usage: mistralConversationUsageSchema().nullish()
|
|
1347
1352
|
}),
|
|
1348
1353
|
z.object({
|
|
1349
1354
|
type: z.literal("conversation.response.error"),
|
|
@@ -1354,7 +1359,7 @@ const mistralConversationChunkSchema = z.discriminatedUnion("type", [
|
|
|
1354
1359
|
type: z.literal("message.output.delta"),
|
|
1355
1360
|
id: z.string(),
|
|
1356
1361
|
content_index: z.number().nullish(),
|
|
1357
|
-
content: z.union([z.string(), mistralConversationContentSchema]),
|
|
1362
|
+
content: z.union([z.string(), mistralConversationContentSchema()]),
|
|
1358
1363
|
model: z.string().nullish()
|
|
1359
1364
|
}),
|
|
1360
1365
|
z.object({
|
|
@@ -1378,7 +1383,7 @@ const mistralConversationChunkSchema = z.discriminatedUnion("type", [
|
|
|
1378
1383
|
function: z.string().nullish(),
|
|
1379
1384
|
info: z.record(z.string(), z.json()).nullish()
|
|
1380
1385
|
})
|
|
1381
|
-
]);
|
|
1386
|
+
])));
|
|
1382
1387
|
//#endregion
|
|
1383
1388
|
//#region src/mistral-embedding-model-options.ts
|
|
1384
1389
|
const mistralEmbeddingModelOptions = z.object({
|
|
@@ -1462,19 +1467,30 @@ var MistralEmbeddingModel = class MistralEmbeddingModel {
|
|
|
1462
1467
|
};
|
|
1463
1468
|
}
|
|
1464
1469
|
};
|
|
1465
|
-
const MistralTextEmbeddingResponseSchema = z.object({
|
|
1470
|
+
const MistralTextEmbeddingResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
1466
1471
|
data: z.array(z.object({ embedding: z.array(z.number()) })),
|
|
1467
1472
|
usage: z.object({ prompt_tokens: z.number() }).nullish()
|
|
1468
|
-
});
|
|
1473
|
+
})));
|
|
1469
1474
|
//#endregion
|
|
1470
1475
|
//#region src/mistral-speech-model-options.ts
|
|
1471
|
-
const mistralSpeechModelOptions = z.object({
|
|
1472
|
-
/**
|
|
1473
|
-
* Base64-encoded reference audio for one-off voice cloning.
|
|
1474
|
-
*
|
|
1475
|
-
* When provided, this takes precedence over the standard `voice` option.
|
|
1476
|
-
*/
|
|
1477
|
-
refAudio: z.string().min(1).optional()
|
|
1476
|
+
const mistralSpeechModelOptions = lazySchema(() => zodSchema(z.object({
|
|
1477
|
+
/**
|
|
1478
|
+
* Base64-encoded reference audio for one-off voice cloning.
|
|
1479
|
+
*
|
|
1480
|
+
* When provided, this takes precedence over the standard `voice` option.
|
|
1481
|
+
*/
|
|
1482
|
+
refAudio: z.string().min(1).optional(),
|
|
1483
|
+
/**
|
|
1484
|
+
* How expressive the speech is, from 1 to 5. Higher values trade voice
|
|
1485
|
+
* similarity and stability for stronger delivery. Supported by Voxtral 3.
|
|
1486
|
+
*/
|
|
1487
|
+
expressiveness: z.number().min(1).max(5).optional(),
|
|
1488
|
+
/**
|
|
1489
|
+
* Pronunciation hints mapping words to lists of IPA phonemes.
|
|
1490
|
+
* Supported by Voxtral 3.
|
|
1491
|
+
*/
|
|
1492
|
+
phonemeHints: z.record(z.string().min(1), z.array(z.string().min(1)).min(1)).optional()
|
|
1493
|
+
})));
|
|
1478
1494
|
//#endregion
|
|
1479
1495
|
//#region src/mistral-speech-model.ts
|
|
1480
1496
|
var MistralSpeechModel = class MistralSpeechModel {
|
|
@@ -1536,6 +1552,8 @@ var MistralSpeechModel = class MistralSpeechModel {
|
|
|
1536
1552
|
input: text,
|
|
1537
1553
|
voice_id: refAudio == null ? voice : void 0,
|
|
1538
1554
|
ref_audio: refAudio,
|
|
1555
|
+
expressiveness: mistralOptions?.expressiveness,
|
|
1556
|
+
phoneme_hints: mistralOptions?.phonemeHints,
|
|
1539
1557
|
response_format: responseFormat,
|
|
1540
1558
|
stream: false
|
|
1541
1559
|
};
|
|
@@ -1576,7 +1594,7 @@ var MistralSpeechModel = class MistralSpeechModel {
|
|
|
1576
1594
|
};
|
|
1577
1595
|
}
|
|
1578
1596
|
};
|
|
1579
|
-
const mistralSpeechResponseSchema = z.object({ audio_data: z.string() });
|
|
1597
|
+
const mistralSpeechResponseSchema = lazySchema(() => zodSchema(z.object({ audio_data: z.string() })));
|
|
1580
1598
|
//#endregion
|
|
1581
1599
|
//#region src/mistral-transcription-model-options.ts
|
|
1582
1600
|
const mistralTranscriptionModelOptions = lazySchema(() => zodSchema(z.object({
|
|
@@ -1586,25 +1604,32 @@ const mistralTranscriptionModelOptions = lazySchema(() => zodSchema(z.object({
|
|
|
1586
1604
|
*/
|
|
1587
1605
|
language: z.string().min(1).optional(),
|
|
1588
1606
|
/**
|
|
1607
|
+
* Return the detected language. Cannot be combined with `language`.
|
|
1608
|
+
*/
|
|
1609
|
+
returnLanguage: z.boolean().optional(),
|
|
1610
|
+
/**
|
|
1589
1611
|
* The sampling temperature.
|
|
1590
1612
|
*/
|
|
1591
1613
|
temperature: z.number().optional(),
|
|
1592
1614
|
/**
|
|
1593
1615
|
* The timestamp granularities to include in the transcription response.
|
|
1616
|
+
* Voxtral 3 supports segment timestamps only.
|
|
1594
1617
|
*/
|
|
1595
1618
|
timestampGranularities: z.array(z.enum(["segment", "word"])).min(1).optional(),
|
|
1596
1619
|
/**
|
|
1597
1620
|
* Whether to identify speakers in the transcription.
|
|
1621
|
+
* Voxtral 3 requires segment timestamps when diarization is enabled.
|
|
1598
1622
|
*/
|
|
1599
1623
|
diarize: z.boolean().optional(),
|
|
1600
1624
|
/**
|
|
1601
1625
|
* Words or phrases to guide the model toward correct spellings of names,
|
|
1602
1626
|
* technical terms, or domain-specific vocabulary.
|
|
1603
1627
|
*
|
|
1604
|
-
*
|
|
1605
|
-
*
|
|
1628
|
+
* Voxtral 3 also accepts phrases and descriptions of the recording,
|
|
1629
|
+
* including spaces and punctuation. Entries share the context window
|
|
1630
|
+
* with the audio.
|
|
1606
1631
|
*/
|
|
1607
|
-
contextBias: z.array(z.string().min(1)
|
|
1632
|
+
contextBias: z.array(z.string().min(1)).optional()
|
|
1608
1633
|
})));
|
|
1609
1634
|
//#endregion
|
|
1610
1635
|
//#region src/mistral-transcription-model.ts
|
|
@@ -1633,16 +1658,25 @@ var MistralTranscriptionModel = class MistralTranscriptionModel {
|
|
|
1633
1658
|
providerOptions,
|
|
1634
1659
|
schema: mistralTranscriptionModelOptions
|
|
1635
1660
|
});
|
|
1636
|
-
if (
|
|
1661
|
+
if ([
|
|
1662
|
+
"voxtral-mini-2507",
|
|
1663
|
+
"voxtral-mini-2602",
|
|
1664
|
+
"voxtral-mini-latest"
|
|
1665
|
+
].includes(this.modelId) && mistralOptions?.language != null && mistralOptions.timestampGranularities != null) throw new InvalidArgumentError({
|
|
1637
1666
|
argument: "providerOptions",
|
|
1638
1667
|
message: "providerOptions.mistral.language cannot be combined with providerOptions.mistral.timestampGranularities"
|
|
1639
1668
|
});
|
|
1669
|
+
if (mistralOptions?.language != null && mistralOptions.returnLanguage) throw new InvalidArgumentError({
|
|
1670
|
+
argument: "providerOptions",
|
|
1671
|
+
message: "providerOptions.mistral.language cannot be combined with providerOptions.mistral.returnLanguage"
|
|
1672
|
+
});
|
|
1640
1673
|
const formData = new FormData();
|
|
1641
1674
|
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([convertBase64ToUint8Array(audio)]);
|
|
1642
1675
|
formData.append("model", this.modelId);
|
|
1643
1676
|
formData.append("file", new File([blob], "audio", { type: mediaType }), `audio.${mediaTypeToExtension(mediaType)}`);
|
|
1644
1677
|
if (mistralOptions != null) {
|
|
1645
1678
|
appendFormValue(formData, "language", mistralOptions.language);
|
|
1679
|
+
appendFormValue(formData, "return_language", mistralOptions.returnLanguage);
|
|
1646
1680
|
appendFormValue(formData, "temperature", mistralOptions.temperature);
|
|
1647
1681
|
appendFormValue(formData, "timestamp_granularities", mistralOptions.timestampGranularities);
|
|
1648
1682
|
appendFormValue(formData, "diarize", mistralOptions.diarize);
|
|
@@ -1712,7 +1746,7 @@ function appendFormValue(formData, key, value) {
|
|
|
1712
1746
|
}
|
|
1713
1747
|
formData.append(key, String(value));
|
|
1714
1748
|
}
|
|
1715
|
-
const mistralTranscriptionResponseSchema = z.object({
|
|
1749
|
+
const mistralTranscriptionResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
1716
1750
|
model: z.string(),
|
|
1717
1751
|
text: z.string(),
|
|
1718
1752
|
language: z.string().nullish(),
|
|
@@ -1731,10 +1765,10 @@ const mistralTranscriptionResponseSchema = z.object({
|
|
|
1731
1765
|
prompt_audio_seconds: z.number().nullish(),
|
|
1732
1766
|
request_count: z.number().nullish()
|
|
1733
1767
|
}).nullish()
|
|
1734
|
-
});
|
|
1768
|
+
})));
|
|
1735
1769
|
//#endregion
|
|
1736
1770
|
//#region src/version.ts
|
|
1737
|
-
const VERSION = "4.0.
|
|
1771
|
+
const VERSION = "4.0.70";
|
|
1738
1772
|
//#endregion
|
|
1739
1773
|
//#region src/tool/web-search.ts
|
|
1740
1774
|
const inputSchema = lazySchema(() => zodSchema(z.object({ arguments: z.string() })));
|