@ai-sdk/mistral 4.0.0-beta.2 → 4.0.0-beta.21
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 +151 -8
- package/README.md +2 -0
- package/dist/index.d.mts +14 -10
- package/dist/index.d.ts +14 -10
- package/dist/index.js +44 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -10
- package/dist/index.mjs.map +1 -1
- package/docs/20-mistral.mdx +21 -0
- package/package.json +3 -5
- package/src/convert-mistral-usage.ts +2 -2
- package/src/convert-to-mistral-chat-messages.ts +11 -5
- package/src/map-mistral-finish-reason.ts +2 -2
- package/src/mistral-chat-language-model.ts +54 -19
- package/src/mistral-chat-options.ts +18 -12
- package/src/mistral-embedding-model.ts +5 -5
- package/src/mistral-prepare-tools.ts +6 -6
- package/src/mistral-provider.ts +12 -12
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
LanguageModelV4CallOptions,
|
|
3
|
+
SharedV4Warning,
|
|
4
4
|
UnsupportedFunctionalityError,
|
|
5
5
|
} from '@ai-sdk/provider';
|
|
6
6
|
import { MistralToolChoice } from './mistral-chat-prompt';
|
|
@@ -9,8 +9,8 @@ export function prepareTools({
|
|
|
9
9
|
tools,
|
|
10
10
|
toolChoice,
|
|
11
11
|
}: {
|
|
12
|
-
tools:
|
|
13
|
-
toolChoice?:
|
|
12
|
+
tools: LanguageModelV4CallOptions['tools'];
|
|
13
|
+
toolChoice?: LanguageModelV4CallOptions['toolChoice'];
|
|
14
14
|
}): {
|
|
15
15
|
tools:
|
|
16
16
|
| Array<{
|
|
@@ -24,12 +24,12 @@ export function prepareTools({
|
|
|
24
24
|
}>
|
|
25
25
|
| undefined;
|
|
26
26
|
toolChoice: MistralToolChoice | undefined;
|
|
27
|
-
toolWarnings:
|
|
27
|
+
toolWarnings: SharedV4Warning[];
|
|
28
28
|
} {
|
|
29
29
|
// when the tools array is empty, change it to undefined to prevent errors:
|
|
30
30
|
tools = tools?.length ? tools : undefined;
|
|
31
31
|
|
|
32
|
-
const toolWarnings:
|
|
32
|
+
const toolWarnings: SharedV4Warning[] = [];
|
|
33
33
|
|
|
34
34
|
if (tools == null) {
|
|
35
35
|
return { tools: undefined, toolChoice: undefined, toolWarnings };
|
package/src/mistral-provider.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
EmbeddingModelV4,
|
|
3
|
+
LanguageModelV4,
|
|
4
4
|
NoSuchModelError,
|
|
5
|
-
|
|
5
|
+
ProviderV4,
|
|
6
6
|
} from '@ai-sdk/provider';
|
|
7
7
|
import {
|
|
8
8
|
FetchFunction,
|
|
@@ -16,38 +16,38 @@ import { MistralEmbeddingModel } from './mistral-embedding-model';
|
|
|
16
16
|
import { MistralEmbeddingModelId } from './mistral-embedding-options';
|
|
17
17
|
import { VERSION } from './version';
|
|
18
18
|
|
|
19
|
-
export interface MistralProvider extends
|
|
20
|
-
(modelId: MistralChatModelId):
|
|
19
|
+
export interface MistralProvider extends ProviderV4 {
|
|
20
|
+
(modelId: MistralChatModelId): LanguageModelV4;
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Creates a model for text generation.
|
|
24
24
|
*/
|
|
25
|
-
languageModel(modelId: MistralChatModelId):
|
|
25
|
+
languageModel(modelId: MistralChatModelId): LanguageModelV4;
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Creates a model for text generation.
|
|
29
29
|
*/
|
|
30
|
-
chat(modelId: MistralChatModelId):
|
|
30
|
+
chat(modelId: MistralChatModelId): LanguageModelV4;
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Creates a model for text embeddings.
|
|
34
34
|
*/
|
|
35
|
-
embedding(modelId: MistralEmbeddingModelId):
|
|
35
|
+
embedding(modelId: MistralEmbeddingModelId): EmbeddingModelV4;
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Creates a model for text embeddings.
|
|
39
39
|
*/
|
|
40
|
-
embeddingModel: (modelId: MistralEmbeddingModelId) =>
|
|
40
|
+
embeddingModel: (modelId: MistralEmbeddingModelId) => EmbeddingModelV4;
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
43
|
* @deprecated Use `embedding` instead.
|
|
44
44
|
*/
|
|
45
|
-
textEmbedding(modelId: MistralEmbeddingModelId):
|
|
45
|
+
textEmbedding(modelId: MistralEmbeddingModelId): EmbeddingModelV4;
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
48
|
* @deprecated Use `embeddingModel` instead.
|
|
49
49
|
*/
|
|
50
|
-
textEmbeddingModel(modelId: MistralEmbeddingModelId):
|
|
50
|
+
textEmbeddingModel(modelId: MistralEmbeddingModelId): EmbeddingModelV4;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export interface MistralProviderSettings {
|
|
@@ -126,7 +126,7 @@ export function createMistral(
|
|
|
126
126
|
return createChatModel(modelId);
|
|
127
127
|
};
|
|
128
128
|
|
|
129
|
-
provider.specificationVersion = '
|
|
129
|
+
provider.specificationVersion = 'v4' as const;
|
|
130
130
|
provider.languageModel = createChatModel;
|
|
131
131
|
provider.chat = createChatModel;
|
|
132
132
|
provider.embedding = createEmbeddingModel;
|