@tanstack/ai-mistral 0.2.3 → 0.3.0
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/dist/esm/adapters/embedding.d.ts +76 -0
- package/dist/esm/adapters/embedding.js +122 -0
- package/dist/esm/adapters/embedding.js.map +1 -0
- package/dist/esm/adapters/text.js +702 -731
- package/dist/esm/adapters/text.js.map +1 -1
- package/dist/esm/embedding/embedding-provider-options.d.ts +29 -0
- package/dist/esm/index.d.ts +4 -2
- package/dist/esm/index.js +3 -8
- package/dist/esm/model-meta.d.ts +31 -4
- package/dist/esm/model-meta.js +253 -49
- package/dist/esm/model-meta.js.map +1 -1
- package/dist/esm/tools/function-tool.js +33 -23
- package/dist/esm/tools/function-tool.js.map +1 -1
- package/dist/esm/tools/tool-converter.js +11 -7
- package/dist/esm/tools/tool-converter.js.map +1 -1
- package/dist/esm/utils/client.js +36 -37
- package/dist/esm/utils/client.js.map +1 -1
- package/dist/esm/utils/schema-converter.js +73 -89
- package/dist/esm/utils/schema-converter.js.map +1 -1
- package/package.json +10 -6
- package/src/adapters/embedding.ts +177 -0
- package/src/adapters/text.ts +11 -2
- package/src/embedding/embedding-provider-options.ts +32 -0
- package/src/index.ts +17 -1
- package/src/model-meta.ts +42 -5
- package/src/utils/schema-converter.ts +2 -2
- package/dist/esm/index.js.map +0 -1
package/dist/esm/model-meta.js
CHANGED
|
@@ -1,50 +1,254 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
1
|
+
/**
|
|
2
|
+
* All supported Mistral chat model identifiers.
|
|
3
|
+
*/
|
|
4
|
+
var MISTRAL_CHAT_MODELS = [
|
|
5
|
+
{
|
|
6
|
+
name: "mistral-large-latest",
|
|
7
|
+
context_window: 131072,
|
|
8
|
+
max_completion_tokens: 8192,
|
|
9
|
+
pricing: {
|
|
10
|
+
input: { normal: .5 },
|
|
11
|
+
output: { normal: 1.5 }
|
|
12
|
+
},
|
|
13
|
+
supports: {
|
|
14
|
+
input: ["text"],
|
|
15
|
+
output: ["text"],
|
|
16
|
+
endpoints: ["chat"],
|
|
17
|
+
features: [
|
|
18
|
+
"streaming",
|
|
19
|
+
"tools",
|
|
20
|
+
"json_object",
|
|
21
|
+
"json_schema"
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
}.name,
|
|
25
|
+
{
|
|
26
|
+
name: "mistral-medium-latest",
|
|
27
|
+
context_window: 131072,
|
|
28
|
+
max_completion_tokens: 8192,
|
|
29
|
+
pricing: {
|
|
30
|
+
input: { normal: .4 },
|
|
31
|
+
output: { normal: 2 }
|
|
32
|
+
},
|
|
33
|
+
supports: {
|
|
34
|
+
input: [
|
|
35
|
+
"text",
|
|
36
|
+
"image",
|
|
37
|
+
"document"
|
|
38
|
+
],
|
|
39
|
+
output: ["text"],
|
|
40
|
+
endpoints: ["chat"],
|
|
41
|
+
features: [
|
|
42
|
+
"streaming",
|
|
43
|
+
"tools",
|
|
44
|
+
"json_object",
|
|
45
|
+
"json_schema",
|
|
46
|
+
"vision"
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
}.name,
|
|
50
|
+
{
|
|
51
|
+
name: "mistral-small-latest",
|
|
52
|
+
context_window: 131072,
|
|
53
|
+
max_completion_tokens: 8192,
|
|
54
|
+
pricing: {
|
|
55
|
+
input: { normal: .1 },
|
|
56
|
+
output: { normal: .3 }
|
|
57
|
+
},
|
|
58
|
+
supports: {
|
|
59
|
+
input: [
|
|
60
|
+
"text",
|
|
61
|
+
"image",
|
|
62
|
+
"document"
|
|
63
|
+
],
|
|
64
|
+
output: ["text"],
|
|
65
|
+
endpoints: ["chat"],
|
|
66
|
+
features: [
|
|
67
|
+
"streaming",
|
|
68
|
+
"tools",
|
|
69
|
+
"json_object",
|
|
70
|
+
"json_schema",
|
|
71
|
+
"vision"
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
}.name,
|
|
75
|
+
{
|
|
76
|
+
name: "ministral-8b-latest",
|
|
77
|
+
context_window: 131072,
|
|
78
|
+
max_completion_tokens: 8192,
|
|
79
|
+
pricing: {
|
|
80
|
+
input: { normal: .1 },
|
|
81
|
+
output: { normal: .1 }
|
|
82
|
+
},
|
|
83
|
+
supports: {
|
|
84
|
+
input: ["text"],
|
|
85
|
+
output: ["text"],
|
|
86
|
+
endpoints: ["chat"],
|
|
87
|
+
features: [
|
|
88
|
+
"streaming",
|
|
89
|
+
"tools",
|
|
90
|
+
"json_object",
|
|
91
|
+
"json_schema"
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
}.name,
|
|
95
|
+
{
|
|
96
|
+
name: "ministral-3b-latest",
|
|
97
|
+
context_window: 131072,
|
|
98
|
+
max_completion_tokens: 8192,
|
|
99
|
+
pricing: {
|
|
100
|
+
input: { normal: .04 },
|
|
101
|
+
output: { normal: .04 }
|
|
102
|
+
},
|
|
103
|
+
supports: {
|
|
104
|
+
input: ["text"],
|
|
105
|
+
output: ["text"],
|
|
106
|
+
endpoints: ["chat"],
|
|
107
|
+
features: [
|
|
108
|
+
"streaming",
|
|
109
|
+
"tools",
|
|
110
|
+
"json_object",
|
|
111
|
+
"json_schema"
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
}.name,
|
|
115
|
+
{
|
|
116
|
+
name: "codestral-latest",
|
|
117
|
+
context_window: 256e3,
|
|
118
|
+
max_completion_tokens: 8192,
|
|
119
|
+
pricing: {
|
|
120
|
+
input: { normal: .3 },
|
|
121
|
+
output: { normal: .9 }
|
|
122
|
+
},
|
|
123
|
+
supports: {
|
|
124
|
+
input: ["text"],
|
|
125
|
+
output: ["text"],
|
|
126
|
+
endpoints: ["chat"],
|
|
127
|
+
features: [
|
|
128
|
+
"streaming",
|
|
129
|
+
"tools",
|
|
130
|
+
"json_object",
|
|
131
|
+
"json_schema",
|
|
132
|
+
"code"
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
}.name,
|
|
136
|
+
{
|
|
137
|
+
name: "pixtral-large-latest",
|
|
138
|
+
context_window: 131072,
|
|
139
|
+
max_completion_tokens: 8192,
|
|
140
|
+
pricing: {
|
|
141
|
+
input: { normal: 2 },
|
|
142
|
+
output: { normal: 6 }
|
|
143
|
+
},
|
|
144
|
+
supports: {
|
|
145
|
+
input: [
|
|
146
|
+
"text",
|
|
147
|
+
"image",
|
|
148
|
+
"document"
|
|
149
|
+
],
|
|
150
|
+
output: ["text"],
|
|
151
|
+
endpoints: ["chat"],
|
|
152
|
+
features: [
|
|
153
|
+
"streaming",
|
|
154
|
+
"tools",
|
|
155
|
+
"json_object",
|
|
156
|
+
"json_schema",
|
|
157
|
+
"vision"
|
|
158
|
+
]
|
|
159
|
+
}
|
|
160
|
+
}.name,
|
|
161
|
+
{
|
|
162
|
+
name: "pixtral-12b-2409",
|
|
163
|
+
context_window: 131072,
|
|
164
|
+
max_completion_tokens: 8192,
|
|
165
|
+
pricing: {
|
|
166
|
+
input: { normal: .15 },
|
|
167
|
+
output: { normal: .15 }
|
|
168
|
+
},
|
|
169
|
+
supports: {
|
|
170
|
+
input: [
|
|
171
|
+
"text",
|
|
172
|
+
"image",
|
|
173
|
+
"document"
|
|
174
|
+
],
|
|
175
|
+
output: ["text"],
|
|
176
|
+
endpoints: ["chat"],
|
|
177
|
+
features: [
|
|
178
|
+
"streaming",
|
|
179
|
+
"tools",
|
|
180
|
+
"json_object",
|
|
181
|
+
"vision"
|
|
182
|
+
]
|
|
183
|
+
}
|
|
184
|
+
}.name,
|
|
185
|
+
{
|
|
186
|
+
name: "magistral-medium-latest",
|
|
187
|
+
context_window: 4e4,
|
|
188
|
+
max_completion_tokens: 4e4,
|
|
189
|
+
pricing: {
|
|
190
|
+
input: { normal: 2 },
|
|
191
|
+
output: { normal: 5 }
|
|
192
|
+
},
|
|
193
|
+
supports: {
|
|
194
|
+
input: ["text"],
|
|
195
|
+
output: ["text"],
|
|
196
|
+
endpoints: ["chat"],
|
|
197
|
+
features: [
|
|
198
|
+
"streaming",
|
|
199
|
+
"tools",
|
|
200
|
+
"reasoning",
|
|
201
|
+
"json_object",
|
|
202
|
+
"json_schema"
|
|
203
|
+
]
|
|
204
|
+
}
|
|
205
|
+
}.name,
|
|
206
|
+
{
|
|
207
|
+
name: "magistral-small-latest",
|
|
208
|
+
context_window: 4e4,
|
|
209
|
+
max_completion_tokens: 4e4,
|
|
210
|
+
pricing: {
|
|
211
|
+
input: { normal: .5 },
|
|
212
|
+
output: { normal: 1.5 }
|
|
213
|
+
},
|
|
214
|
+
supports: {
|
|
215
|
+
input: ["text"],
|
|
216
|
+
output: ["text"],
|
|
217
|
+
endpoints: ["chat"],
|
|
218
|
+
features: [
|
|
219
|
+
"streaming",
|
|
220
|
+
"tools",
|
|
221
|
+
"reasoning",
|
|
222
|
+
"json_object",
|
|
223
|
+
"json_schema"
|
|
224
|
+
]
|
|
225
|
+
}
|
|
226
|
+
}.name,
|
|
227
|
+
{
|
|
228
|
+
name: "open-mistral-nemo",
|
|
229
|
+
context_window: 131072,
|
|
230
|
+
max_completion_tokens: 8192,
|
|
231
|
+
pricing: {
|
|
232
|
+
input: { normal: .15 },
|
|
233
|
+
output: { normal: .15 }
|
|
234
|
+
},
|
|
235
|
+
supports: {
|
|
236
|
+
input: ["text"],
|
|
237
|
+
output: ["text"],
|
|
238
|
+
endpoints: ["chat"],
|
|
239
|
+
features: [
|
|
240
|
+
"streaming",
|
|
241
|
+
"tools",
|
|
242
|
+
"json_object"
|
|
243
|
+
]
|
|
244
|
+
}
|
|
245
|
+
}.name
|
|
46
246
|
];
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
247
|
+
/**
|
|
248
|
+
* Embedding models (based on endpoints: "embeddings")
|
|
249
|
+
*/
|
|
250
|
+
var MISTRAL_EMBEDDING_MODELS = ["mistral-embed", "codestral-embed"];
|
|
251
|
+
//#endregion
|
|
252
|
+
export { MISTRAL_CHAT_MODELS, MISTRAL_EMBEDDING_MODELS };
|
|
253
|
+
|
|
254
|
+
//# sourceMappingURL=model-meta.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-meta.js","sources":["../../src/model-meta.ts"],"sourcesContent":["import type { MistralTextProviderOptions } from './text/text-provider-options'\n\n/** Provider options for vision-capable Mistral models (pixtral-*). */\nexport type MistralVisionProviderOptions = MistralTextProviderOptions\n\n/** Provider options for reasoning-capable Mistral models (magistral-*). */\nexport type MistralReasoningProviderOptions = MistralTextProviderOptions\n\n/**\n * Internal metadata structure describing a Mistral model's capabilities\n * and approximate pricing (USD per million tokens).\n */\ninterface ModelMeta<TProviderOptions = unknown> {\n name: string\n context_window?: number\n max_completion_tokens?: number\n pricing: {\n input?: { normal: number; cached?: number }\n output?: { normal: number }\n }\n supports: {\n input: Array<'text' | 'image' | 'audio'>\n output: Array<'text'>\n endpoints: Array<'chat' | 'embeddings'>\n\n features: Array<\n | 'streaming'\n | 'tools'\n | 'json_object'\n | 'json_schema'\n | 'reasoning'\n | 'vision'\n | 'code'\n >\n }\n providerOptions?: TProviderOptions\n}\n\nconst MISTRAL_LARGE_LATEST = {\n name: 'mistral-large-latest',\n context_window: 131_072,\n max_completion_tokens: 8_192,\n pricing: {\n input: { normal: 0.5 },\n output: { normal: 1.5 },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'tools', 'json_object', 'json_schema'],\n },\n} as const satisfies ModelMeta<MistralTextProviderOptions>\n\nconst MISTRAL_MEDIUM_LATEST = {\n name: 'mistral-medium-latest',\n context_window: 131_072,\n max_completion_tokens: 8_192,\n pricing: {\n input: { normal: 0.4 },\n output: { normal: 2 },\n },\n supports: {\n input: ['text', 'image'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'tools', 'json_object', 'json_schema', 'vision'],\n },\n} as const satisfies ModelMeta<MistralTextProviderOptions>\n\nconst MISTRAL_SMALL_LATEST = {\n name: 'mistral-small-latest',\n context_window: 131_072,\n max_completion_tokens: 8_192,\n pricing: {\n input: { normal: 0.1 },\n output: { normal: 0.3 },\n },\n supports: {\n input: ['text', 'image'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'tools', 'json_object', 'json_schema', 'vision'],\n },\n} as const satisfies ModelMeta<MistralTextProviderOptions>\n\nconst MINISTRAL_8B_LATEST = {\n name: 'ministral-8b-latest',\n context_window: 131_072,\n max_completion_tokens: 8_192,\n pricing: {\n input: { normal: 0.1 },\n output: { normal: 0.1 },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'tools', 'json_object', 'json_schema'],\n },\n} as const satisfies ModelMeta<MistralTextProviderOptions>\n\nconst MINISTRAL_3B_LATEST = {\n name: 'ministral-3b-latest',\n context_window: 131_072,\n max_completion_tokens: 8_192,\n pricing: {\n input: { normal: 0.04 },\n output: { normal: 0.04 },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'tools', 'json_object', 'json_schema'],\n },\n} as const satisfies ModelMeta<MistralTextProviderOptions>\n\nconst CODESTRAL_LATEST = {\n name: 'codestral-latest',\n context_window: 256_000,\n max_completion_tokens: 8_192,\n pricing: {\n input: { normal: 0.3 },\n output: { normal: 0.9 },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'tools', 'json_object', 'json_schema', 'code'],\n },\n} as const satisfies ModelMeta<MistralTextProviderOptions>\n\nconst PIXTRAL_LARGE_LATEST = {\n name: 'pixtral-large-latest',\n context_window: 131_072,\n max_completion_tokens: 8_192,\n pricing: {\n input: { normal: 2 },\n output: { normal: 6 },\n },\n supports: {\n input: ['text', 'image'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'tools', 'json_object', 'json_schema', 'vision'],\n },\n} as const satisfies ModelMeta<MistralTextProviderOptions>\n\nconst PIXTRAL_12B_2409 = {\n name: 'pixtral-12b-2409',\n context_window: 131_072,\n max_completion_tokens: 8_192,\n pricing: {\n input: { normal: 0.15 },\n output: { normal: 0.15 },\n },\n supports: {\n input: ['text', 'image'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'tools', 'json_object', 'vision'],\n },\n} as const satisfies ModelMeta<MistralTextProviderOptions>\n\nconst MAGISTRAL_MEDIUM_LATEST = {\n name: 'magistral-medium-latest',\n context_window: 40_000,\n max_completion_tokens: 40_000,\n pricing: {\n input: { normal: 2 },\n output: { normal: 5 },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'tools', 'reasoning', 'json_object', 'json_schema'],\n },\n} as const satisfies ModelMeta<MistralTextProviderOptions>\n\nconst MAGISTRAL_SMALL_LATEST = {\n name: 'magistral-small-latest',\n context_window: 40_000,\n max_completion_tokens: 40_000,\n pricing: {\n input: { normal: 0.5 },\n output: { normal: 1.5 },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'tools', 'reasoning', 'json_object', 'json_schema'],\n },\n} as const satisfies ModelMeta<MistralTextProviderOptions>\n\nconst OPEN_MISTRAL_NEMO = {\n name: 'open-mistral-nemo',\n context_window: 131_072,\n max_completion_tokens: 8_192,\n pricing: {\n input: { normal: 0.15 },\n output: { normal: 0.15 },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'tools', 'json_object'],\n },\n} as const satisfies ModelMeta<MistralTextProviderOptions>\n\n/**\n * All supported Mistral chat model identifiers.\n */\nexport const MISTRAL_CHAT_MODELS = [\n MISTRAL_LARGE_LATEST.name,\n MISTRAL_MEDIUM_LATEST.name,\n MISTRAL_SMALL_LATEST.name,\n MINISTRAL_8B_LATEST.name,\n MINISTRAL_3B_LATEST.name,\n CODESTRAL_LATEST.name,\n PIXTRAL_LARGE_LATEST.name,\n PIXTRAL_12B_2409.name,\n MAGISTRAL_MEDIUM_LATEST.name,\n MAGISTRAL_SMALL_LATEST.name,\n OPEN_MISTRAL_NEMO.name,\n] as const\n\n/**\n * Union type of all supported Mistral chat model names.\n */\nexport type MistralChatModels = (typeof MISTRAL_CHAT_MODELS)[number]\n\n/**\n * Type-only map from Mistral chat model name to its supported input modalities.\n */\nexport type MistralModelInputModalitiesByName = {\n [MISTRAL_LARGE_LATEST.name]: typeof MISTRAL_LARGE_LATEST.supports.input\n [MISTRAL_MEDIUM_LATEST.name]: typeof MISTRAL_MEDIUM_LATEST.supports.input\n [MISTRAL_SMALL_LATEST.name]: typeof MISTRAL_SMALL_LATEST.supports.input\n [MINISTRAL_8B_LATEST.name]: typeof MINISTRAL_8B_LATEST.supports.input\n [MINISTRAL_3B_LATEST.name]: typeof MINISTRAL_3B_LATEST.supports.input\n [CODESTRAL_LATEST.name]: typeof CODESTRAL_LATEST.supports.input\n [PIXTRAL_LARGE_LATEST.name]: typeof PIXTRAL_LARGE_LATEST.supports.input\n [PIXTRAL_12B_2409.name]: typeof PIXTRAL_12B_2409.supports.input\n [MAGISTRAL_MEDIUM_LATEST.name]: typeof MAGISTRAL_MEDIUM_LATEST.supports.input\n [MAGISTRAL_SMALL_LATEST.name]: typeof MAGISTRAL_SMALL_LATEST.supports.input\n [OPEN_MISTRAL_NEMO.name]: typeof OPEN_MISTRAL_NEMO.supports.input\n}\n\n/**\n * Type-only map from Mistral chat model name to its provider options type.\n */\nexport type MistralChatModelProviderOptionsByName = {\n [MISTRAL_LARGE_LATEST.name]: MistralTextProviderOptions\n [MISTRAL_MEDIUM_LATEST.name]: MistralVisionProviderOptions\n [MISTRAL_SMALL_LATEST.name]: MistralVisionProviderOptions\n [MINISTRAL_8B_LATEST.name]: MistralTextProviderOptions\n [MINISTRAL_3B_LATEST.name]: MistralTextProviderOptions\n [CODESTRAL_LATEST.name]: MistralTextProviderOptions\n [PIXTRAL_LARGE_LATEST.name]: MistralVisionProviderOptions\n [PIXTRAL_12B_2409.name]: MistralVisionProviderOptions\n [MAGISTRAL_MEDIUM_LATEST.name]: MistralReasoningProviderOptions\n [MAGISTRAL_SMALL_LATEST.name]: MistralReasoningProviderOptions\n [OPEN_MISTRAL_NEMO.name]: MistralTextProviderOptions\n}\n\n/**\n * Resolves the provider options type for a specific Mistral model.\n */\nexport type ResolveProviderOptions<TModel extends string> =\n TModel extends keyof MistralChatModelProviderOptionsByName\n ? MistralChatModelProviderOptionsByName[TModel]\n : MistralTextProviderOptions\n\n/**\n * Resolve input modalities for a specific model.\n */\nexport type ResolveInputModalities<TModel extends string> =\n TModel extends keyof MistralModelInputModalitiesByName\n ? MistralModelInputModalitiesByName[TModel]\n : readonly ['text']\n"],"names":[],"mappings":"AAsCA,MAAM,uBAAuB;AAAA,EAC3B,MAAM;AAaR;AAEA,MAAM,wBAAwB;AAAA,EAC5B,MAAM;AAaR;AAEA,MAAM,uBAAuB;AAAA,EAC3B,MAAM;AAaR;AAEA,MAAM,sBAAsB;AAAA,EAC1B,MAAM;AAaR;AAEA,MAAM,sBAAsB;AAAA,EAC1B,MAAM;AAaR;AAEA,MAAM,mBAAmB;AAAA,EACvB,MAAM;AAaR;AAEA,MAAM,uBAAuB;AAAA,EAC3B,MAAM;AAaR;AAEA,MAAM,mBAAmB;AAAA,EACvB,MAAM;AAaR;AAEA,MAAM,0BAA0B;AAAA,EAC9B,MAAM;AAaR;AAEA,MAAM,yBAAyB;AAAA,EAC7B,MAAM;AAaR;AAEA,MAAM,oBAAoB;AAAA,EACxB,MAAM;AAaR;AAKO,MAAM,sBAAsB;AAAA,EACjC,qBAAqB;AAAA,EACrB,sBAAsB;AAAA,EACtB,qBAAqB;AAAA,EACrB,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,iBAAiB;AAAA,EACjB,qBAAqB;AAAA,EACrB,iBAAiB;AAAA,EACjB,wBAAwB;AAAA,EACxB,uBAAuB;AAAA,EACvB,kBAAkB;AACpB;"}
|
|
1
|
+
{"version":3,"file":"model-meta.js","names":[],"sources":["../../src/model-meta.ts"],"sourcesContent":["import type { MistralTextProviderOptions } from './text/text-provider-options'\nimport type {\n CodestralEmbedProviderOptions,\n MistralEmbedProviderOptions,\n} from './embedding/embedding-provider-options'\n\n/** Provider options for vision-capable Mistral models (pixtral-*). */\nexport type MistralVisionProviderOptions = MistralTextProviderOptions\n\n/** Provider options for reasoning-capable Mistral models (magistral-*). */\nexport type MistralReasoningProviderOptions = MistralTextProviderOptions\n\n/**\n * Internal metadata structure describing a Mistral model's capabilities\n * and approximate pricing (USD per million tokens).\n */\ninterface ModelMeta<TProviderOptions = unknown> {\n name: string\n context_window?: number\n max_completion_tokens?: number\n pricing: {\n input?: { normal: number; cached?: number }\n output?: { normal: number }\n }\n supports: {\n input: Array<'text' | 'image' | 'audio' | 'document'>\n output: Array<'text'>\n endpoints: Array<'chat' | 'embeddings'>\n\n features: Array<\n | 'streaming'\n | 'tools'\n | 'json_object'\n | 'json_schema'\n | 'reasoning'\n | 'vision'\n | 'code'\n >\n }\n providerOptions?: TProviderOptions\n}\n\nconst MISTRAL_LARGE_LATEST = {\n name: 'mistral-large-latest',\n context_window: 131_072,\n max_completion_tokens: 8_192,\n pricing: {\n input: { normal: 0.5 },\n output: { normal: 1.5 },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'tools', 'json_object', 'json_schema'],\n },\n} as const satisfies ModelMeta<MistralTextProviderOptions>\n\nconst MISTRAL_MEDIUM_LATEST = {\n name: 'mistral-medium-latest',\n context_window: 131_072,\n max_completion_tokens: 8_192,\n pricing: {\n input: { normal: 0.4 },\n output: { normal: 2 },\n },\n supports: {\n input: ['text', 'image', 'document'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'tools', 'json_object', 'json_schema', 'vision'],\n },\n} as const satisfies ModelMeta<MistralTextProviderOptions>\n\nconst MISTRAL_SMALL_LATEST = {\n name: 'mistral-small-latest',\n context_window: 131_072,\n max_completion_tokens: 8_192,\n pricing: {\n input: { normal: 0.1 },\n output: { normal: 0.3 },\n },\n supports: {\n input: ['text', 'image', 'document'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'tools', 'json_object', 'json_schema', 'vision'],\n },\n} as const satisfies ModelMeta<MistralTextProviderOptions>\n\nconst MINISTRAL_8B_LATEST = {\n name: 'ministral-8b-latest',\n context_window: 131_072,\n max_completion_tokens: 8_192,\n pricing: {\n input: { normal: 0.1 },\n output: { normal: 0.1 },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'tools', 'json_object', 'json_schema'],\n },\n} as const satisfies ModelMeta<MistralTextProviderOptions>\n\nconst MINISTRAL_3B_LATEST = {\n name: 'ministral-3b-latest',\n context_window: 131_072,\n max_completion_tokens: 8_192,\n pricing: {\n input: { normal: 0.04 },\n output: { normal: 0.04 },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'tools', 'json_object', 'json_schema'],\n },\n} as const satisfies ModelMeta<MistralTextProviderOptions>\n\nconst CODESTRAL_LATEST = {\n name: 'codestral-latest',\n context_window: 256_000,\n max_completion_tokens: 8_192,\n pricing: {\n input: { normal: 0.3 },\n output: { normal: 0.9 },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'tools', 'json_object', 'json_schema', 'code'],\n },\n} as const satisfies ModelMeta<MistralTextProviderOptions>\n\nconst PIXTRAL_LARGE_LATEST = {\n name: 'pixtral-large-latest',\n context_window: 131_072,\n max_completion_tokens: 8_192,\n pricing: {\n input: { normal: 2 },\n output: { normal: 6 },\n },\n supports: {\n input: ['text', 'image', 'document'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'tools', 'json_object', 'json_schema', 'vision'],\n },\n} as const satisfies ModelMeta<MistralTextProviderOptions>\n\nconst PIXTRAL_12B_2409 = {\n name: 'pixtral-12b-2409',\n context_window: 131_072,\n max_completion_tokens: 8_192,\n pricing: {\n input: { normal: 0.15 },\n output: { normal: 0.15 },\n },\n supports: {\n input: ['text', 'image', 'document'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'tools', 'json_object', 'vision'],\n },\n} as const satisfies ModelMeta<MistralTextProviderOptions>\n\nconst MAGISTRAL_MEDIUM_LATEST = {\n name: 'magistral-medium-latest',\n context_window: 40_000,\n max_completion_tokens: 40_000,\n pricing: {\n input: { normal: 2 },\n output: { normal: 5 },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'tools', 'reasoning', 'json_object', 'json_schema'],\n },\n} as const satisfies ModelMeta<MistralTextProviderOptions>\n\nconst MAGISTRAL_SMALL_LATEST = {\n name: 'magistral-small-latest',\n context_window: 40_000,\n max_completion_tokens: 40_000,\n pricing: {\n input: { normal: 0.5 },\n output: { normal: 1.5 },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'tools', 'reasoning', 'json_object', 'json_schema'],\n },\n} as const satisfies ModelMeta<MistralTextProviderOptions>\n\nconst OPEN_MISTRAL_NEMO = {\n name: 'open-mistral-nemo',\n context_window: 131_072,\n max_completion_tokens: 8_192,\n pricing: {\n input: { normal: 0.15 },\n output: { normal: 0.15 },\n },\n supports: {\n input: ['text'],\n output: ['text'],\n endpoints: ['chat'],\n features: ['streaming', 'tools', 'json_object'],\n },\n} as const satisfies ModelMeta<MistralTextProviderOptions>\n\n/**\n * All supported Mistral chat model identifiers.\n */\nexport const MISTRAL_CHAT_MODELS = [\n MISTRAL_LARGE_LATEST.name,\n MISTRAL_MEDIUM_LATEST.name,\n MISTRAL_SMALL_LATEST.name,\n MINISTRAL_8B_LATEST.name,\n MINISTRAL_3B_LATEST.name,\n CODESTRAL_LATEST.name,\n PIXTRAL_LARGE_LATEST.name,\n PIXTRAL_12B_2409.name,\n MAGISTRAL_MEDIUM_LATEST.name,\n MAGISTRAL_SMALL_LATEST.name,\n OPEN_MISTRAL_NEMO.name,\n] as const\n\n/**\n * Union type of all supported Mistral chat model names.\n */\nexport type MistralChatModels = (typeof MISTRAL_CHAT_MODELS)[number]\n\n/**\n * Type-only map from Mistral chat model name to its supported input modalities.\n */\nexport type MistralModelInputModalitiesByName = {\n [MISTRAL_LARGE_LATEST.name]: typeof MISTRAL_LARGE_LATEST.supports.input\n [MISTRAL_MEDIUM_LATEST.name]: typeof MISTRAL_MEDIUM_LATEST.supports.input\n [MISTRAL_SMALL_LATEST.name]: typeof MISTRAL_SMALL_LATEST.supports.input\n [MINISTRAL_8B_LATEST.name]: typeof MINISTRAL_8B_LATEST.supports.input\n [MINISTRAL_3B_LATEST.name]: typeof MINISTRAL_3B_LATEST.supports.input\n [CODESTRAL_LATEST.name]: typeof CODESTRAL_LATEST.supports.input\n [PIXTRAL_LARGE_LATEST.name]: typeof PIXTRAL_LARGE_LATEST.supports.input\n [PIXTRAL_12B_2409.name]: typeof PIXTRAL_12B_2409.supports.input\n [MAGISTRAL_MEDIUM_LATEST.name]: typeof MAGISTRAL_MEDIUM_LATEST.supports.input\n [MAGISTRAL_SMALL_LATEST.name]: typeof MAGISTRAL_SMALL_LATEST.supports.input\n [OPEN_MISTRAL_NEMO.name]: typeof OPEN_MISTRAL_NEMO.supports.input\n}\n\n/**\n * Type-only map from Mistral chat model name to its provider options type.\n */\nexport type MistralChatModelProviderOptionsByName = {\n [MISTRAL_LARGE_LATEST.name]: MistralTextProviderOptions\n [MISTRAL_MEDIUM_LATEST.name]: MistralVisionProviderOptions\n [MISTRAL_SMALL_LATEST.name]: MistralVisionProviderOptions\n [MINISTRAL_8B_LATEST.name]: MistralTextProviderOptions\n [MINISTRAL_3B_LATEST.name]: MistralTextProviderOptions\n [CODESTRAL_LATEST.name]: MistralTextProviderOptions\n [PIXTRAL_LARGE_LATEST.name]: MistralVisionProviderOptions\n [PIXTRAL_12B_2409.name]: MistralVisionProviderOptions\n [MAGISTRAL_MEDIUM_LATEST.name]: MistralReasoningProviderOptions\n [MAGISTRAL_SMALL_LATEST.name]: MistralReasoningProviderOptions\n [OPEN_MISTRAL_NEMO.name]: MistralTextProviderOptions\n}\n\n/**\n * Embedding models (based on endpoints: \"embeddings\")\n */\nexport const MISTRAL_EMBEDDING_MODELS = [\n 'mistral-embed',\n 'codestral-embed',\n] as const\n\n/**\n * Union type of all supported Mistral embedding model names.\n */\nexport type MistralEmbeddingModel = (typeof MISTRAL_EMBEDDING_MODELS)[number]\n\n/**\n * Type-only map from embedding model name to its provider options type.\n *\n * `mistral-embed` accepts no provider options (fixed 1024-dim output);\n * `codestral-embed` additionally supports `outputDtype`.\n */\nexport type MistralEmbeddingModelProviderOptionsByName = {\n 'mistral-embed': MistralEmbedProviderOptions\n 'codestral-embed': CodestralEmbedProviderOptions\n}\n\n/**\n * Per-model input modalities for embedding models. Mistral embedding models\n * are text-only, so image inputs fail at compile time.\n */\nexport type MistralEmbeddingModelInputModalitiesByName = {\n 'mistral-embed': readonly ['text']\n 'codestral-embed': readonly ['text']\n}\n\n/**\n * Resolves the provider options type for a specific Mistral model.\n */\nexport type ResolveProviderOptions<TModel extends string> =\n TModel extends keyof MistralChatModelProviderOptionsByName\n ? MistralChatModelProviderOptionsByName[TModel]\n : MistralTextProviderOptions\n\n/**\n * Resolve input modalities for a specific model.\n */\nexport type ResolveInputModalities<TModel extends string> =\n TModel extends keyof MistralModelInputModalitiesByName\n ? MistralModelInputModalitiesByName[TModel]\n : readonly ['text']\n"],"mappings":"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"}
|
|
@@ -1,26 +1,36 @@
|
|
|
1
1
|
import { makeMistralStructuredOutputCompatible } from "../utils/schema-converter.js";
|
|
2
|
+
//#region src/tools/function-tool.ts
|
|
3
|
+
/**
|
|
4
|
+
* Converts a standard Tool to Mistral ChatCompletionTool format.
|
|
5
|
+
*
|
|
6
|
+
* Tool schemas are already converted to JSON Schema in the ai layer.
|
|
7
|
+
* We apply Mistral-specific transformations for strict mode:
|
|
8
|
+
* - All properties in required array
|
|
9
|
+
* - Optional fields made nullable
|
|
10
|
+
* - additionalProperties: false
|
|
11
|
+
*/
|
|
2
12
|
function convertFunctionToolToAdapterFormat(tool) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
const baseSchema = tool.inputSchema ?? {
|
|
14
|
+
type: "object",
|
|
15
|
+
properties: {},
|
|
16
|
+
required: []
|
|
17
|
+
};
|
|
18
|
+
const inputSchema = baseSchema.type === "object" && !baseSchema.properties ? {
|
|
19
|
+
...baseSchema,
|
|
20
|
+
properties: {}
|
|
21
|
+
} : { ...baseSchema };
|
|
22
|
+
const jsonSchema = makeMistralStructuredOutputCompatible(inputSchema, inputSchema.required || []);
|
|
23
|
+
return {
|
|
24
|
+
type: "function",
|
|
25
|
+
function: {
|
|
26
|
+
name: tool.name,
|
|
27
|
+
description: tool.description,
|
|
28
|
+
parameters: jsonSchema,
|
|
29
|
+
strict: true
|
|
30
|
+
}
|
|
31
|
+
};
|
|
22
32
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
//# sourceMappingURL=function-tool.js.map
|
|
33
|
+
//#endregion
|
|
34
|
+
export { convertFunctionToolToAdapterFormat };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=function-tool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function-tool.js","sources":["../../../src/tools/function-tool.ts"],"sourcesContent":["import { makeMistralStructuredOutputCompatible } from '../utils/schema-converter'\nimport type { JSONSchema, Tool } from '@tanstack/ai'\nimport type { ChatCompletionTool } from '../message-types'\n\nexport type FunctionTool = ChatCompletionTool\n\n/**\n * Converts a standard Tool to Mistral ChatCompletionTool format.\n *\n * Tool schemas are already converted to JSON Schema in the ai layer.\n * We apply Mistral-specific transformations for strict mode:\n * - All properties in required array\n * - Optional fields made nullable\n * - additionalProperties: false\n */\nexport function convertFunctionToolToAdapterFormat(tool: Tool): FunctionTool {\n const baseSchema = (tool.inputSchema ?? {\n type: 'object',\n properties: {},\n required: [],\n }) as JSONSchema\n\n const inputSchema: JSONSchema =\n baseSchema.type === 'object' && !baseSchema.properties\n ? { ...baseSchema, properties: {} }\n : { ...baseSchema }\n\n const jsonSchema = makeMistralStructuredOutputCompatible(\n inputSchema,\n inputSchema.required || [],\n )\n\n return {\n type: 'function',\n function: {\n name: tool.name,\n description: tool.description,\n parameters: jsonSchema,\n strict: true,\n },\n } satisfies FunctionTool\n}\n"],"
|
|
1
|
+
{"version":3,"file":"function-tool.js","names":[],"sources":["../../../src/tools/function-tool.ts"],"sourcesContent":["import { makeMistralStructuredOutputCompatible } from '../utils/schema-converter'\nimport type { JSONSchema, Tool } from '@tanstack/ai'\nimport type { ChatCompletionTool } from '../message-types'\n\nexport type FunctionTool = ChatCompletionTool\n\n/**\n * Converts a standard Tool to Mistral ChatCompletionTool format.\n *\n * Tool schemas are already converted to JSON Schema in the ai layer.\n * We apply Mistral-specific transformations for strict mode:\n * - All properties in required array\n * - Optional fields made nullable\n * - additionalProperties: false\n */\nexport function convertFunctionToolToAdapterFormat(tool: Tool): FunctionTool {\n const baseSchema = (tool.inputSchema ?? {\n type: 'object',\n properties: {},\n required: [],\n }) as JSONSchema\n\n const inputSchema: JSONSchema =\n baseSchema.type === 'object' && !baseSchema.properties\n ? { ...baseSchema, properties: {} }\n : { ...baseSchema }\n\n const jsonSchema = makeMistralStructuredOutputCompatible(\n inputSchema,\n inputSchema.required || [],\n )\n\n return {\n type: 'function',\n function: {\n name: tool.name,\n description: tool.description,\n parameters: jsonSchema,\n strict: true,\n },\n } satisfies FunctionTool\n}\n"],"mappings":";;;;;;;;;;;AAeA,SAAgB,mCAAmC,MAA0B;CAC3E,MAAM,aAAc,KAAK,eAAe;EACtC,MAAM;EACN,YAAY,CAAC;EACb,UAAU,CAAC;CACb;CAEA,MAAM,cACJ,WAAW,SAAS,YAAY,CAAC,WAAW,aACxC;EAAE,GAAG;EAAY,YAAY,CAAC;CAAE,IAChC,EAAE,GAAG,WAAW;CAEtB,MAAM,aAAa,sCACjB,aACA,YAAY,YAAY,CAAC,CAC3B;CAEA,OAAO;EACL,MAAM;EACN,UAAU;GACR,MAAM,KAAK;GACX,aAAa,KAAK;GAClB,YAAY;GACZ,QAAQ;EACV;CACF;AACF"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { convertFunctionToolToAdapterFormat } from "./function-tool.js";
|
|
2
|
+
//#region src/tools/tool-converter.ts
|
|
3
|
+
/**
|
|
4
|
+
* Converts an array of standard Tools to Mistral-specific format.
|
|
5
|
+
*/
|
|
2
6
|
function convertToolsToProviderFormat(tools) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
7
|
+
return tools.map((tool) => {
|
|
8
|
+
return convertFunctionToolToAdapterFormat(tool);
|
|
9
|
+
});
|
|
6
10
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
//# sourceMappingURL=tool-converter.js.map
|
|
11
|
+
//#endregion
|
|
12
|
+
export { convertToolsToProviderFormat };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=tool-converter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-converter.js","sources":["../../../src/tools/tool-converter.ts"],"sourcesContent":["import { convertFunctionToolToAdapterFormat } from './function-tool'\nimport type { FunctionTool } from './function-tool'\nimport type { Tool } from '@tanstack/ai'\n\n/**\n * Converts an array of standard Tools to Mistral-specific format.\n */\nexport function convertToolsToProviderFormat(\n tools: Array<Tool>,\n): Array<FunctionTool> {\n return tools.map((tool) => {\n return convertFunctionToolToAdapterFormat(tool)\n })\n}\n"],"
|
|
1
|
+
{"version":3,"file":"tool-converter.js","names":[],"sources":["../../../src/tools/tool-converter.ts"],"sourcesContent":["import { convertFunctionToolToAdapterFormat } from './function-tool'\nimport type { FunctionTool } from './function-tool'\nimport type { Tool } from '@tanstack/ai'\n\n/**\n * Converts an array of standard Tools to Mistral-specific format.\n */\nexport function convertToolsToProviderFormat(\n tools: Array<Tool>,\n): Array<FunctionTool> {\n return tools.map((tool) => {\n return convertFunctionToolToAdapterFormat(tool)\n })\n}\n"],"mappings":";;;;;AAOA,SAAgB,6BACd,OACqB;CACrB,OAAO,MAAM,KAAK,SAAS;EACzB,OAAO,mCAAmC,IAAI;CAChD,CAAC;AACH"}
|
package/dist/esm/utils/client.js
CHANGED
|
@@ -1,44 +1,43 @@
|
|
|
1
1
|
import { HTTPClient, Mistral } from "@mistralai/mistralai";
|
|
2
|
+
//#region src/utils/client.ts
|
|
3
|
+
/**
|
|
4
|
+
* Creates a Mistral SDK client instance.
|
|
5
|
+
*/
|
|
2
6
|
function createMistralClient(config) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
...httpClient !== void 0 ? { httpClient } : {}
|
|
19
|
-
});
|
|
7
|
+
const { apiKey, serverURL, timeoutMs, defaultHeaders } = config;
|
|
8
|
+
let httpClient;
|
|
9
|
+
if (defaultHeaders && Object.keys(defaultHeaders).length > 0) {
|
|
10
|
+
httpClient = new HTTPClient();
|
|
11
|
+
httpClient.addHook("beforeRequest", (req) => {
|
|
12
|
+
for (const [key, value] of Object.entries(defaultHeaders)) req.headers.set(key, value);
|
|
13
|
+
return req;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return new Mistral({
|
|
17
|
+
apiKey,
|
|
18
|
+
...serverURL !== void 0 ? { serverURL } : {},
|
|
19
|
+
...timeoutMs !== void 0 ? { timeoutMs } : {},
|
|
20
|
+
...httpClient !== void 0 ? { httpClient } : {}
|
|
21
|
+
});
|
|
20
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Gets Mistral API key from environment variables.
|
|
25
|
+
* @throws Error if MISTRAL_API_KEY is not found
|
|
26
|
+
*/
|
|
21
27
|
function getMistralApiKeyFromEnv() {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
key = g.window?.env?.MISTRAL_API_KEY;
|
|
28
|
-
}
|
|
29
|
-
if (!key) {
|
|
30
|
-
throw new Error(
|
|
31
|
-
"MISTRAL_API_KEY is required. In Node.js set it as an environment variable; in browser environments inject it via window.env.MISTRAL_API_KEY or use the factory function with an explicit API key."
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
return key;
|
|
28
|
+
let key;
|
|
29
|
+
if (typeof process !== "undefined" && typeof process.env !== "undefined") key = process.env.MISTRAL_API_KEY;
|
|
30
|
+
else key = globalThis.window?.env?.MISTRAL_API_KEY;
|
|
31
|
+
if (!key) throw new Error("MISTRAL_API_KEY is required. In Node.js set it as an environment variable; in browser environments inject it via window.env.MISTRAL_API_KEY or use the factory function with an explicit API key.");
|
|
32
|
+
return key;
|
|
35
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Generates a unique ID with a prefix.
|
|
36
|
+
*/
|
|
36
37
|
function generateId(prefix) {
|
|
37
|
-
|
|
38
|
+
return `${prefix}-${crypto.randomUUID()}`;
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
};
|
|
44
|
-
//# sourceMappingURL=client.js.map
|
|
40
|
+
//#endregion
|
|
41
|
+
export { createMistralClient, generateId, getMistralApiKeyFromEnv };
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sources":["../../../src/utils/client.ts"],"sourcesContent":["import { HTTPClient, Mistral } from '@mistralai/mistralai'\n\nexport interface MistralClientConfig {\n /** Mistral API key. */\n apiKey: string\n\n /** Optional server URL override. */\n serverURL?: string\n\n /** Optional request timeout (ms). */\n timeoutMs?: number\n\n /** Optional default headers to include with every request. */\n defaultHeaders?: Record<string, string>\n}\n\n/**\n * Creates a Mistral SDK client instance.\n */\nexport function createMistralClient(config: MistralClientConfig): Mistral {\n const { apiKey, serverURL, timeoutMs, defaultHeaders } = config\n\n let httpClient: HTTPClient | undefined\n if (defaultHeaders && Object.keys(defaultHeaders).length > 0) {\n httpClient = new HTTPClient()\n httpClient.addHook('beforeRequest', (req) => {\n for (const [key, value] of Object.entries(defaultHeaders)) {\n req.headers.set(key, value)\n }\n return req\n })\n }\n\n return new Mistral({\n apiKey,\n ...(serverURL !== undefined ? { serverURL } : {}),\n ...(timeoutMs !== undefined ? { timeoutMs } : {}),\n ...(httpClient !== undefined ? { httpClient } : {}),\n })\n}\n\n/**\n * Gets Mistral API key from environment variables.\n * @throws Error if MISTRAL_API_KEY is not found\n */\nexport function getMistralApiKeyFromEnv(): string {\n let key: string | undefined\n\n if (typeof process !== 'undefined' && typeof process.env !== 'undefined') {\n key = process.env.MISTRAL_API_KEY\n } else {\n const g = globalThis as { window?: { env?: Record<string, string> } }\n key = g.window?.env?.MISTRAL_API_KEY\n }\n\n if (!key) {\n throw new Error(\n 'MISTRAL_API_KEY is required. In Node.js set it as an environment variable; in browser environments inject it via window.env.MISTRAL_API_KEY or use the factory function with an explicit API key.',\n )\n }\n\n return key\n}\n\n/**\n * Generates a unique ID with a prefix.\n */\nexport function generateId(prefix: string): string {\n return `${prefix}-${crypto.randomUUID()}`\n}\n"],"
|
|
1
|
+
{"version":3,"file":"client.js","names":[],"sources":["../../../src/utils/client.ts"],"sourcesContent":["import { HTTPClient, Mistral } from '@mistralai/mistralai'\n\nexport interface MistralClientConfig {\n /** Mistral API key. */\n apiKey: string\n\n /** Optional server URL override. */\n serverURL?: string\n\n /** Optional request timeout (ms). */\n timeoutMs?: number\n\n /** Optional default headers to include with every request. */\n defaultHeaders?: Record<string, string>\n}\n\n/**\n * Creates a Mistral SDK client instance.\n */\nexport function createMistralClient(config: MistralClientConfig): Mistral {\n const { apiKey, serverURL, timeoutMs, defaultHeaders } = config\n\n let httpClient: HTTPClient | undefined\n if (defaultHeaders && Object.keys(defaultHeaders).length > 0) {\n httpClient = new HTTPClient()\n httpClient.addHook('beforeRequest', (req) => {\n for (const [key, value] of Object.entries(defaultHeaders)) {\n req.headers.set(key, value)\n }\n return req\n })\n }\n\n return new Mistral({\n apiKey,\n ...(serverURL !== undefined ? { serverURL } : {}),\n ...(timeoutMs !== undefined ? { timeoutMs } : {}),\n ...(httpClient !== undefined ? { httpClient } : {}),\n })\n}\n\n/**\n * Gets Mistral API key from environment variables.\n * @throws Error if MISTRAL_API_KEY is not found\n */\nexport function getMistralApiKeyFromEnv(): string {\n let key: string | undefined\n\n if (typeof process !== 'undefined' && typeof process.env !== 'undefined') {\n key = process.env.MISTRAL_API_KEY\n } else {\n const g = globalThis as { window?: { env?: Record<string, string> } }\n key = g.window?.env?.MISTRAL_API_KEY\n }\n\n if (!key) {\n throw new Error(\n 'MISTRAL_API_KEY is required. In Node.js set it as an environment variable; in browser environments inject it via window.env.MISTRAL_API_KEY or use the factory function with an explicit API key.',\n )\n }\n\n return key\n}\n\n/**\n * Generates a unique ID with a prefix.\n */\nexport function generateId(prefix: string): string {\n return `${prefix}-${crypto.randomUUID()}`\n}\n"],"mappings":";;;;;AAmBA,SAAgB,oBAAoB,QAAsC;CACxE,MAAM,EAAE,QAAQ,WAAW,WAAW,mBAAmB;CAEzD,IAAI;CACJ,IAAI,kBAAkB,OAAO,KAAK,cAAc,CAAC,CAAC,SAAS,GAAG;EAC5D,aAAa,IAAI,WAAW;EAC5B,WAAW,QAAQ,kBAAkB,QAAQ;GAC3C,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,cAAc,GACtD,IAAI,QAAQ,IAAI,KAAK,KAAK;GAE5B,OAAO;EACT,CAAC;CACH;CAEA,OAAO,IAAI,QAAQ;EACjB;EACA,GAAI,cAAc,KAAA,IAAY,EAAE,UAAU,IAAI,CAAC;EAC/C,GAAI,cAAc,KAAA,IAAY,EAAE,UAAU,IAAI,CAAC;EAC/C,GAAI,eAAe,KAAA,IAAY,EAAE,WAAW,IAAI,CAAC;CACnD,CAAC;AACH;;;;;AAMA,SAAgB,0BAAkC;CAChD,IAAI;CAEJ,IAAI,OAAO,YAAY,eAAe,OAAO,QAAQ,QAAQ,aAC3D,MAAM,QAAQ,IAAI;MAGlB,MAAM,WAAE,QAAQ,KAAK;CAGvB,IAAI,CAAC,KACH,MAAM,IAAI,MACR,mMACF;CAGF,OAAO;AACT;;;;AAKA,SAAgB,WAAW,QAAwB;CACjD,OAAO,GAAG,OAAO,GAAG,OAAO,WAAW;AACxC"}
|