@core-ai/mistral 0.6.0 → 0.7.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/index.d.ts +16 -47
- package/dist/index.js +23 -26
- package/package.json +4 -5
package/dist/index.d.ts
CHANGED
|
@@ -14,44 +14,29 @@ type MistralProvider = {
|
|
|
14
14
|
declare function createMistral(options?: MistralProviderOptions$1): MistralProvider;
|
|
15
15
|
|
|
16
16
|
declare const mistralGenerateProviderOptionsSchema: z.ZodObject<{
|
|
17
|
-
stopSequences: z.ZodOptional<z.ZodArray<z.ZodString
|
|
17
|
+
stopSequences: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
18
18
|
frequencyPenalty: z.ZodOptional<z.ZodNumber>;
|
|
19
19
|
presencePenalty: z.ZodOptional<z.ZodNumber>;
|
|
20
20
|
randomSeed: z.ZodOptional<z.ZodNumber>;
|
|
21
21
|
parallelToolCalls: z.ZodOptional<z.ZodBoolean>;
|
|
22
22
|
promptMode: z.ZodOptional<z.ZodString>;
|
|
23
23
|
safePrompt: z.ZodOptional<z.ZodBoolean>;
|
|
24
|
-
},
|
|
25
|
-
stopSequences?: string[] | undefined;
|
|
26
|
-
frequencyPenalty?: number | undefined;
|
|
27
|
-
presencePenalty?: number | undefined;
|
|
28
|
-
randomSeed?: number | undefined;
|
|
29
|
-
parallelToolCalls?: boolean | undefined;
|
|
30
|
-
promptMode?: string | undefined;
|
|
31
|
-
safePrompt?: boolean | undefined;
|
|
32
|
-
}, {
|
|
33
|
-
stopSequences?: string[] | undefined;
|
|
34
|
-
frequencyPenalty?: number | undefined;
|
|
35
|
-
presencePenalty?: number | undefined;
|
|
36
|
-
randomSeed?: number | undefined;
|
|
37
|
-
parallelToolCalls?: boolean | undefined;
|
|
38
|
-
promptMode?: string | undefined;
|
|
39
|
-
safePrompt?: boolean | undefined;
|
|
40
|
-
}>;
|
|
24
|
+
}, z.core.$strict>;
|
|
41
25
|
type MistralGenerateProviderOptions = z.infer<typeof mistralGenerateProviderOptionsSchema>;
|
|
42
26
|
declare const mistralEmbedProviderOptionsSchema: z.ZodObject<{
|
|
43
|
-
outputDtype: z.ZodOptional<z.ZodEnum<
|
|
44
|
-
|
|
27
|
+
outputDtype: z.ZodOptional<z.ZodEnum<{
|
|
28
|
+
float: "float";
|
|
29
|
+
int8: "int8";
|
|
30
|
+
uint8: "uint8";
|
|
31
|
+
binary: "binary";
|
|
32
|
+
ubinary: "ubinary";
|
|
33
|
+
}>>;
|
|
34
|
+
encodingFormat: z.ZodOptional<z.ZodEnum<{
|
|
35
|
+
float: "float";
|
|
36
|
+
base64: "base64";
|
|
37
|
+
}>>;
|
|
45
38
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
46
|
-
},
|
|
47
|
-
outputDtype?: "float" | "int8" | "uint8" | "binary" | "ubinary" | undefined;
|
|
48
|
-
encodingFormat?: "float" | "base64" | undefined;
|
|
49
|
-
metadata?: Record<string, unknown> | undefined;
|
|
50
|
-
}, {
|
|
51
|
-
outputDtype?: "float" | "int8" | "uint8" | "binary" | "ubinary" | undefined;
|
|
52
|
-
encodingFormat?: "float" | "base64" | undefined;
|
|
53
|
-
metadata?: Record<string, unknown> | undefined;
|
|
54
|
-
}>;
|
|
39
|
+
}, z.core.$strict>;
|
|
55
40
|
type MistralEmbedProviderOptions = z.infer<typeof mistralEmbedProviderOptionsSchema>;
|
|
56
41
|
declare module '@core-ai/core-ai' {
|
|
57
42
|
interface GenerateProviderOptions {
|
|
@@ -62,30 +47,14 @@ declare module '@core-ai/core-ai' {
|
|
|
62
47
|
}
|
|
63
48
|
}
|
|
64
49
|
declare const mistralProviderOptionsSchema: z.ZodObject<{
|
|
65
|
-
stopSequences: z.ZodOptional<z.ZodArray<z.ZodString
|
|
50
|
+
stopSequences: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
66
51
|
frequencyPenalty: z.ZodOptional<z.ZodNumber>;
|
|
67
52
|
presencePenalty: z.ZodOptional<z.ZodNumber>;
|
|
68
53
|
randomSeed: z.ZodOptional<z.ZodNumber>;
|
|
69
54
|
parallelToolCalls: z.ZodOptional<z.ZodBoolean>;
|
|
70
55
|
promptMode: z.ZodOptional<z.ZodString>;
|
|
71
56
|
safePrompt: z.ZodOptional<z.ZodBoolean>;
|
|
72
|
-
},
|
|
73
|
-
stopSequences?: string[] | undefined;
|
|
74
|
-
frequencyPenalty?: number | undefined;
|
|
75
|
-
presencePenalty?: number | undefined;
|
|
76
|
-
randomSeed?: number | undefined;
|
|
77
|
-
parallelToolCalls?: boolean | undefined;
|
|
78
|
-
promptMode?: string | undefined;
|
|
79
|
-
safePrompt?: boolean | undefined;
|
|
80
|
-
}, {
|
|
81
|
-
stopSequences?: string[] | undefined;
|
|
82
|
-
frequencyPenalty?: number | undefined;
|
|
83
|
-
presencePenalty?: number | undefined;
|
|
84
|
-
randomSeed?: number | undefined;
|
|
85
|
-
parallelToolCalls?: boolean | undefined;
|
|
86
|
-
promptMode?: string | undefined;
|
|
87
|
-
safePrompt?: boolean | undefined;
|
|
88
|
-
}>;
|
|
57
|
+
}, z.core.$strict>;
|
|
89
58
|
type MistralProviderOptions = MistralGenerateProviderOptions;
|
|
90
59
|
|
|
91
60
|
export { type MistralEmbedProviderOptions, type MistralGenerateProviderOptions, type MistralProviderOptions as MistralModelProviderOptions, type MistralProvider, type MistralProviderOptions$1 as MistralProviderOptions, createMistral, mistralEmbedProviderOptionsSchema, mistralGenerateProviderOptionsSchema, mistralProviderOptionsSchema };
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "@core-ai/core-ai";
|
|
12
12
|
|
|
13
13
|
// src/chat-adapter.ts
|
|
14
|
-
import {
|
|
14
|
+
import { zodSchemaToJsonSchema } from "@core-ai/core-ai";
|
|
15
15
|
|
|
16
16
|
// src/provider-options.ts
|
|
17
17
|
import { z } from "zod";
|
|
@@ -128,7 +128,7 @@ function convertTools(tools) {
|
|
|
128
128
|
function: {
|
|
129
129
|
name: tool.name,
|
|
130
130
|
description: tool.description,
|
|
131
|
-
parameters:
|
|
131
|
+
parameters: zodSchemaToJsonSchema(tool.parameters)
|
|
132
132
|
}
|
|
133
133
|
}));
|
|
134
134
|
}
|
|
@@ -144,11 +144,7 @@ function convertToolChoice(choice) {
|
|
|
144
144
|
};
|
|
145
145
|
}
|
|
146
146
|
function getStructuredOutputToolName(options) {
|
|
147
|
-
|
|
148
|
-
if (trimmedName && trimmedName.length > 0) {
|
|
149
|
-
return trimmedName;
|
|
150
|
-
}
|
|
151
|
-
return DEFAULT_STRUCTURED_OUTPUT_TOOL_NAME;
|
|
147
|
+
return options.schemaName?.trim() || DEFAULT_STRUCTURED_OUTPUT_TOOL_NAME;
|
|
152
148
|
}
|
|
153
149
|
function createStructuredOutputOptions(options) {
|
|
154
150
|
const toolName = getStructuredOutputToolName(options);
|
|
@@ -212,7 +208,7 @@ function mapMistralProviderOptionsToRequest(baseRequest, providerOptions) {
|
|
|
212
208
|
if (!providerOptions) {
|
|
213
209
|
return baseRequest;
|
|
214
210
|
}
|
|
215
|
-
|
|
211
|
+
return {
|
|
216
212
|
...baseRequest,
|
|
217
213
|
...providerOptions.stopSequences ? { stop: providerOptions.stopSequences } : {},
|
|
218
214
|
...providerOptions.frequencyPenalty !== void 0 ? { frequencyPenalty: providerOptions.frequencyPenalty } : {},
|
|
@@ -222,7 +218,6 @@ function mapMistralProviderOptionsToRequest(baseRequest, providerOptions) {
|
|
|
222
218
|
...providerOptions.promptMode !== void 0 ? { promptMode: providerOptions.promptMode } : {},
|
|
223
219
|
...providerOptions.safePrompt !== void 0 ? { safePrompt: providerOptions.safePrompt } : {}
|
|
224
220
|
};
|
|
225
|
-
return mergedRequest;
|
|
226
221
|
}
|
|
227
222
|
function mapGenerateResponse(response) {
|
|
228
223
|
const firstChoice = response.choices[0];
|
|
@@ -266,6 +261,16 @@ async function* transformStream(stream) {
|
|
|
266
261
|
},
|
|
267
262
|
outputTokenDetails: {}
|
|
268
263
|
};
|
|
264
|
+
const closeReasoning = () => {
|
|
265
|
+
if (!reasoningOpen) {
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
268
|
+
reasoningOpen = false;
|
|
269
|
+
return {
|
|
270
|
+
type: "reasoning-end",
|
|
271
|
+
providerMetadata: { mistral: {} }
|
|
272
|
+
};
|
|
273
|
+
};
|
|
269
274
|
for await (const event of stream) {
|
|
270
275
|
const chunk = event.data;
|
|
271
276
|
if (chunk.usage) {
|
|
@@ -291,12 +296,9 @@ async function* transformStream(stream) {
|
|
|
291
296
|
}
|
|
292
297
|
}
|
|
293
298
|
for (const textDelta of extractTextDeltas(choice.delta.content)) {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
yield
|
|
297
|
-
type: "reasoning-end",
|
|
298
|
-
providerMetadata: { mistral: {} }
|
|
299
|
-
};
|
|
299
|
+
const reasoningEnd2 = closeReasoning();
|
|
300
|
+
if (reasoningEnd2) {
|
|
301
|
+
yield reasoningEnd2;
|
|
300
302
|
}
|
|
301
303
|
yield {
|
|
302
304
|
type: "text-delta",
|
|
@@ -304,12 +306,9 @@ async function* transformStream(stream) {
|
|
|
304
306
|
};
|
|
305
307
|
}
|
|
306
308
|
if (choice.delta.toolCalls) {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
yield
|
|
310
|
-
type: "reasoning-end",
|
|
311
|
-
providerMetadata: { mistral: {} }
|
|
312
|
-
};
|
|
309
|
+
const reasoningEnd2 = closeReasoning();
|
|
310
|
+
if (reasoningEnd2) {
|
|
311
|
+
yield reasoningEnd2;
|
|
313
312
|
}
|
|
314
313
|
for (const [
|
|
315
314
|
position,
|
|
@@ -364,11 +363,9 @@ async function* transformStream(stream) {
|
|
|
364
363
|
yield* emitBufferedToolCalls(bufferedToolCalls, emittedToolCalls);
|
|
365
364
|
}
|
|
366
365
|
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
providerMetadata: { mistral: {} }
|
|
371
|
-
};
|
|
366
|
+
const reasoningEnd = closeReasoning();
|
|
367
|
+
if (reasoningEnd) {
|
|
368
|
+
yield reasoningEnd;
|
|
372
369
|
}
|
|
373
370
|
yield* emitBufferedToolCalls(bufferedToolCalls, emittedToolCalls);
|
|
374
371
|
yield {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@core-ai/mistral",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Mistral provider package for @core-ai/core-ai",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Omnifact (https://omnifact.ai)",
|
|
@@ -41,12 +41,11 @@
|
|
|
41
41
|
"test:watch": "vitest"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@core-ai/core-ai": "^0.
|
|
45
|
-
"@mistralai/mistralai": "^1.14.0"
|
|
46
|
-
"zod-to-json-schema": "^3.25.1"
|
|
44
|
+
"@core-ai/core-ai": "^0.7.0",
|
|
45
|
+
"@mistralai/mistralai": "^1.14.0"
|
|
47
46
|
},
|
|
48
47
|
"peerDependencies": {
|
|
49
|
-
"zod": "^
|
|
48
|
+
"zod": "^4.0.0"
|
|
50
49
|
},
|
|
51
50
|
"devDependencies": {
|
|
52
51
|
"@core-ai/eslint-config": "*",
|