@ai-sdk/mistral 3.0.73 → 3.0.75
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 +16 -0
- package/dist/index.d.mts +16 -19
- package/dist/index.d.ts +16 -19
- package/dist/index.js +163 -130
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +155 -106
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/mistral-chat-language-model.ts +102 -85
- package/src/mistral-chat-options.ts +46 -37
- 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
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
lazySchema,
|
|
3
|
+
zodSchema,
|
|
4
|
+
type InferSchema,
|
|
5
|
+
} from '@ai-sdk/provider-utils';
|
|
1
6
|
import { z } from 'zod/v4';
|
|
2
7
|
|
|
3
8
|
// https://docs.mistral.ai/getting-started/models/models_overview/
|
|
@@ -24,48 +29,52 @@ export type MistralChatModelId =
|
|
|
24
29
|
| 'magistral-small-2509'
|
|
25
30
|
| (string & {});
|
|
26
31
|
|
|
27
|
-
export const mistralLanguageModelOptions =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
export const mistralLanguageModelOptions = lazySchema(() =>
|
|
33
|
+
zodSchema(
|
|
34
|
+
z.object({
|
|
35
|
+
/**
|
|
36
|
+
* Whether to inject a safety prompt before all conversations.
|
|
37
|
+
*
|
|
38
|
+
* Defaults to `false`.
|
|
39
|
+
*/
|
|
40
|
+
safePrompt: z.boolean().optional(),
|
|
34
41
|
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
documentImageLimit: z.number().optional(),
|
|
43
|
+
documentPageLimit: z.number().optional(),
|
|
37
44
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Whether to use structured outputs.
|
|
47
|
+
*
|
|
48
|
+
* @default true
|
|
49
|
+
*/
|
|
50
|
+
structuredOutputs: z.boolean().optional(),
|
|
44
51
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Whether to use strict JSON schema validation.
|
|
54
|
+
*
|
|
55
|
+
* @default false
|
|
56
|
+
*/
|
|
57
|
+
strictJsonSchema: z.boolean().optional(),
|
|
51
58
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Whether to enable parallel function calling during tool use.
|
|
61
|
+
* When set to false, the model will use at most one tool per response.
|
|
62
|
+
*
|
|
63
|
+
* @default true
|
|
64
|
+
*/
|
|
65
|
+
parallelToolCalls: z.boolean().optional(),
|
|
59
66
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
})
|
|
67
|
+
/**
|
|
68
|
+
* Controls the reasoning effort for models that support adjustable reasoning.
|
|
69
|
+
*
|
|
70
|
+
* - `'high'`: Enable reasoning
|
|
71
|
+
* - `'none'`: Disable reasoning
|
|
72
|
+
*/
|
|
73
|
+
reasoningEffort: z.enum(['high', 'none']).optional(),
|
|
74
|
+
}),
|
|
75
|
+
),
|
|
76
|
+
);
|
|
68
77
|
|
|
69
|
-
export type MistralLanguageModelOptions =
|
|
78
|
+
export type MistralLanguageModelOptions = InferSchema<
|
|
70
79
|
typeof mistralLanguageModelOptions
|
|
71
80
|
>;
|
|
@@ -3,6 +3,8 @@ import {
|
|
|
3
3
|
type EmbeddingModelV3,
|
|
4
4
|
} from '@ai-sdk/provider';
|
|
5
5
|
import {
|
|
6
|
+
lazySchema,
|
|
7
|
+
zodSchema,
|
|
6
8
|
combineHeaders,
|
|
7
9
|
createJsonResponseHandler,
|
|
8
10
|
postJsonToApi,
|
|
@@ -88,7 +90,11 @@ export class MistralEmbeddingModel implements EmbeddingModelV3 {
|
|
|
88
90
|
|
|
89
91
|
// minimal version of the schema, focussed on what is needed for the implementation
|
|
90
92
|
// this approach limits breakages when the API changes and increases efficiency
|
|
91
|
-
const MistralTextEmbeddingResponseSchema =
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
})
|
|
93
|
+
const MistralTextEmbeddingResponseSchema = lazySchema(() =>
|
|
94
|
+
zodSchema(
|
|
95
|
+
z.object({
|
|
96
|
+
data: z.array(z.object({ embedding: z.array(z.number()) })),
|
|
97
|
+
usage: z.object({ prompt_tokens: z.number() }).nullish(),
|
|
98
|
+
}),
|
|
99
|
+
),
|
|
100
|
+
);
|
package/src/mistral-error.ts
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
lazySchema,
|
|
3
|
+
zodSchema,
|
|
4
|
+
type InferSchema,
|
|
5
|
+
createJsonErrorResponseHandler,
|
|
6
|
+
} from '@ai-sdk/provider-utils';
|
|
2
7
|
import { z } from 'zod/v4';
|
|
3
8
|
|
|
4
|
-
const mistralErrorDataSchema =
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const mistralErrorDataSchema = lazySchema(() =>
|
|
10
|
+
zodSchema(
|
|
11
|
+
z.object({
|
|
12
|
+
object: z.literal('error'),
|
|
13
|
+
message: z.string(),
|
|
14
|
+
type: z.string(),
|
|
15
|
+
param: z.string().nullable(),
|
|
16
|
+
code: z.string().nullable(),
|
|
17
|
+
}),
|
|
18
|
+
),
|
|
19
|
+
);
|
|
11
20
|
|
|
12
|
-
export type MistralErrorData =
|
|
21
|
+
export type MistralErrorData = InferSchema<typeof mistralErrorDataSchema>;
|
|
13
22
|
|
|
14
23
|
export const mistralFailedResponseHandler = createJsonErrorResponseHandler({
|
|
15
24
|
errorSchema: mistralErrorDataSchema,
|
|
@@ -1,16 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
lazySchema,
|
|
3
|
+
zodSchema,
|
|
4
|
+
type InferSchema,
|
|
5
|
+
} from '@ai-sdk/provider-utils';
|
|
1
6
|
import { z } from 'zod/v4';
|
|
2
7
|
|
|
3
8
|
export type MistralSpeechModelId = 'voxtral-mini-tts-2603' | (string & {});
|
|
4
9
|
|
|
5
|
-
export const mistralSpeechModelOptions =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
export const mistralSpeechModelOptions = lazySchema(() =>
|
|
11
|
+
zodSchema(
|
|
12
|
+
z.object({
|
|
13
|
+
/**
|
|
14
|
+
* Base64-encoded reference audio for one-off voice cloning.
|
|
15
|
+
*
|
|
16
|
+
* When provided, this takes precedence over the standard `voice` option.
|
|
17
|
+
*/
|
|
18
|
+
refAudio: z.string().min(1).optional(),
|
|
19
|
+
}),
|
|
20
|
+
),
|
|
21
|
+
);
|
|
13
22
|
|
|
14
|
-
export type MistralSpeechModelOptions =
|
|
23
|
+
export type MistralSpeechModelOptions = InferSchema<
|
|
15
24
|
typeof mistralSpeechModelOptions
|
|
16
25
|
>;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { SharedV3Warning, SpeechModelV3 } from '@ai-sdk/provider';
|
|
2
2
|
import {
|
|
3
|
+
lazySchema,
|
|
4
|
+
zodSchema,
|
|
3
5
|
combineHeaders,
|
|
4
6
|
createJsonResponseHandler,
|
|
5
7
|
parseProviderOptions,
|
|
@@ -157,6 +159,10 @@ export class MistralSpeechModel implements SpeechModelV3 {
|
|
|
157
159
|
}
|
|
158
160
|
}
|
|
159
161
|
|
|
160
|
-
const mistralSpeechResponseSchema =
|
|
161
|
-
|
|
162
|
-
|
|
162
|
+
const mistralSpeechResponseSchema = lazySchema(() =>
|
|
163
|
+
zodSchema(
|
|
164
|
+
z.object({
|
|
165
|
+
audio_data: z.string(),
|
|
166
|
+
}),
|
|
167
|
+
),
|
|
168
|
+
);
|