@ai-sdk/cohere 4.0.0-beta.3 → 4.0.0-beta.31
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 +240 -4
- package/README.md +2 -0
- package/dist/index.d.ts +10 -10
- package/dist/index.js +319 -252
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
- package/src/cohere-chat-language-model.ts +100 -33
- package/src/cohere-embedding-model.ts +26 -9
- package/src/cohere-prepare-tools.ts +7 -7
- package/src/cohere-provider.ts +18 -19
- package/src/convert-cohere-usage.ts +2 -2
- package/src/convert-to-cohere-chat-prompt.ts +31 -30
- package/src/map-cohere-finish-reason.ts +2 -2
- package/src/reranking/cohere-reranking-model.ts +9 -10
- package/src/reranking/cohere-reranking-options.ts +5 -1
- package/dist/index.d.mts +0 -117
- package/dist/index.mjs +0 -1067
- package/dist/index.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,241 @@
|
|
|
1
1
|
# @ai-sdk/cohere
|
|
2
2
|
|
|
3
|
+
## 4.0.0-beta.31
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9bd6512: feat(provider): change file part data property to be tagged with a type and remove the image part type
|
|
8
|
+
- 258c093: chore: ensure consistent import handling and avoid import duplicates or cycles
|
|
9
|
+
- Updated dependencies [9bd6512]
|
|
10
|
+
- Updated dependencies [258c093]
|
|
11
|
+
- Updated dependencies [b6783da]
|
|
12
|
+
- @ai-sdk/provider-utils@5.0.0-beta.29
|
|
13
|
+
- @ai-sdk/provider@4.0.0-beta.14
|
|
14
|
+
|
|
15
|
+
## 4.0.0-beta.30
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 9f0e36c: trigger release for all packages after provenance setup
|
|
20
|
+
- Updated dependencies [9f0e36c]
|
|
21
|
+
- @ai-sdk/provider@4.0.0-beta.13
|
|
22
|
+
- @ai-sdk/provider-utils@5.0.0-beta.28
|
|
23
|
+
|
|
24
|
+
## 4.0.0-beta.29
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- 58a2ad7: fix: more precise default message for tool execution denial
|
|
29
|
+
- Updated dependencies [785fe16]
|
|
30
|
+
- Updated dependencies [67df0a0]
|
|
31
|
+
- Updated dependencies [befb78c]
|
|
32
|
+
- Updated dependencies [0458559]
|
|
33
|
+
- Updated dependencies [5852c0a]
|
|
34
|
+
- Updated dependencies [fc92055]
|
|
35
|
+
- @ai-sdk/provider-utils@5.0.0-beta.27
|
|
36
|
+
|
|
37
|
+
## 4.0.0-beta.28
|
|
38
|
+
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- Updated dependencies [2e98477]
|
|
42
|
+
- @ai-sdk/provider-utils@5.0.0-beta.26
|
|
43
|
+
|
|
44
|
+
## 4.0.0-beta.27
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- Updated dependencies [eea8d98]
|
|
49
|
+
- @ai-sdk/provider-utils@5.0.0-beta.25
|
|
50
|
+
|
|
51
|
+
## 4.0.0-beta.26
|
|
52
|
+
|
|
53
|
+
### Patch Changes
|
|
54
|
+
|
|
55
|
+
- Updated dependencies [f807e45]
|
|
56
|
+
- @ai-sdk/provider-utils@5.0.0-beta.24
|
|
57
|
+
|
|
58
|
+
## 4.0.0-beta.25
|
|
59
|
+
|
|
60
|
+
### Patch Changes
|
|
61
|
+
|
|
62
|
+
- Updated dependencies [350ea38]
|
|
63
|
+
- @ai-sdk/provider-utils@5.0.0-beta.23
|
|
64
|
+
|
|
65
|
+
## 4.0.0-beta.24
|
|
66
|
+
|
|
67
|
+
### Patch Changes
|
|
68
|
+
|
|
69
|
+
- Updated dependencies [083947b]
|
|
70
|
+
- @ai-sdk/provider-utils@5.0.0-beta.22
|
|
71
|
+
|
|
72
|
+
## 4.0.0-beta.23
|
|
73
|
+
|
|
74
|
+
### Patch Changes
|
|
75
|
+
|
|
76
|
+
- Updated dependencies [add1126]
|
|
77
|
+
- @ai-sdk/provider-utils@5.0.0-beta.21
|
|
78
|
+
|
|
79
|
+
## 4.0.0-beta.22
|
|
80
|
+
|
|
81
|
+
### Patch Changes
|
|
82
|
+
|
|
83
|
+
- b3976a2: Add workflow serialization support to all provider models.
|
|
84
|
+
|
|
85
|
+
**`@ai-sdk/provider-utils`:** New `serializeModel()` helper that extracts only serializable properties from a model instance, filtering out functions and objects containing functions. Third-party provider authors can use this to add workflow support to their own models.
|
|
86
|
+
|
|
87
|
+
**All providers:** `headers` is now optional in provider config types. This is non-breaking — existing code that passes `headers` continues to work. Custom provider implementations that construct model configs manually can now omit `headers`, which is useful when models are deserialized from a workflow step boundary where auth is provided separately.
|
|
88
|
+
|
|
89
|
+
All provider model classes now include `WORKFLOW_SERIALIZE` and `WORKFLOW_DESERIALIZE` static methods, enabling them to cross workflow step boundaries without serialization errors.
|
|
90
|
+
|
|
91
|
+
- Updated dependencies [b3976a2]
|
|
92
|
+
- Updated dependencies [ff5eba1]
|
|
93
|
+
- @ai-sdk/provider-utils@5.0.0-beta.20
|
|
94
|
+
- @ai-sdk/provider@4.0.0-beta.12
|
|
95
|
+
|
|
96
|
+
## 4.0.0-beta.21
|
|
97
|
+
|
|
98
|
+
### Major Changes
|
|
99
|
+
|
|
100
|
+
- ef992f8: Remove CommonJS exports from all packages. All packages are now ESM-only (`"type": "module"`). Consumers using `require()` must switch to ESM `import` syntax.
|
|
101
|
+
|
|
102
|
+
### Patch Changes
|
|
103
|
+
|
|
104
|
+
- Updated dependencies [ef992f8]
|
|
105
|
+
- @ai-sdk/provider@4.0.0-beta.11
|
|
106
|
+
- @ai-sdk/provider-utils@5.0.0-beta.19
|
|
107
|
+
|
|
108
|
+
## 4.0.0-beta.20
|
|
109
|
+
|
|
110
|
+
### Patch Changes
|
|
111
|
+
|
|
112
|
+
- 90e2d8a: chore: fix unused vars not being flagged by our lint tooling
|
|
113
|
+
- Updated dependencies [90e2d8a]
|
|
114
|
+
- @ai-sdk/provider-utils@5.0.0-beta.18
|
|
115
|
+
|
|
116
|
+
## 4.0.0-beta.19
|
|
117
|
+
|
|
118
|
+
### Patch Changes
|
|
119
|
+
|
|
120
|
+
- Updated dependencies [3ae1786]
|
|
121
|
+
- @ai-sdk/provider-utils@5.0.0-beta.17
|
|
122
|
+
|
|
123
|
+
## 4.0.0-beta.18
|
|
124
|
+
|
|
125
|
+
### Patch Changes
|
|
126
|
+
|
|
127
|
+
- Updated dependencies [176466a]
|
|
128
|
+
- @ai-sdk/provider@4.0.0-beta.10
|
|
129
|
+
- @ai-sdk/provider-utils@5.0.0-beta.16
|
|
130
|
+
|
|
131
|
+
## 4.0.0-beta.17
|
|
132
|
+
|
|
133
|
+
### Patch Changes
|
|
134
|
+
|
|
135
|
+
- Updated dependencies [e311194]
|
|
136
|
+
- @ai-sdk/provider@4.0.0-beta.9
|
|
137
|
+
- @ai-sdk/provider-utils@5.0.0-beta.15
|
|
138
|
+
|
|
139
|
+
## 4.0.0-beta.16
|
|
140
|
+
|
|
141
|
+
### Patch Changes
|
|
142
|
+
|
|
143
|
+
- Updated dependencies [34bd95d]
|
|
144
|
+
- Updated dependencies [008271d]
|
|
145
|
+
- @ai-sdk/provider@4.0.0-beta.8
|
|
146
|
+
- @ai-sdk/provider-utils@5.0.0-beta.14
|
|
147
|
+
|
|
148
|
+
## 4.0.0-beta.15
|
|
149
|
+
|
|
150
|
+
### Patch Changes
|
|
151
|
+
|
|
152
|
+
- Updated dependencies [b0c2869]
|
|
153
|
+
- Updated dependencies [7e26e81]
|
|
154
|
+
- @ai-sdk/provider-utils@5.0.0-beta.13
|
|
155
|
+
|
|
156
|
+
## 4.0.0-beta.14
|
|
157
|
+
|
|
158
|
+
### Patch Changes
|
|
159
|
+
|
|
160
|
+
- Updated dependencies [46d1149]
|
|
161
|
+
- @ai-sdk/provider-utils@5.0.0-beta.12
|
|
162
|
+
|
|
163
|
+
## 4.0.0-beta.13
|
|
164
|
+
|
|
165
|
+
### Patch Changes
|
|
166
|
+
|
|
167
|
+
- 6fd51c0: fix(provider): preserve error type prefix in getErrorMessage
|
|
168
|
+
- Updated dependencies [6fd51c0]
|
|
169
|
+
- @ai-sdk/provider-utils@5.0.0-beta.11
|
|
170
|
+
- @ai-sdk/provider@4.0.0-beta.7
|
|
171
|
+
|
|
172
|
+
## 4.0.0-beta.12
|
|
173
|
+
|
|
174
|
+
### Patch Changes
|
|
175
|
+
|
|
176
|
+
- c29a26f: feat(provider): add support for provider references and uploading files as supported per provider
|
|
177
|
+
- Updated dependencies [c29a26f]
|
|
178
|
+
- @ai-sdk/provider-utils@5.0.0-beta.10
|
|
179
|
+
- @ai-sdk/provider@4.0.0-beta.6
|
|
180
|
+
|
|
181
|
+
## 4.0.0-beta.11
|
|
182
|
+
|
|
183
|
+
### Patch Changes
|
|
184
|
+
|
|
185
|
+
- 38fc777: Add AI Gateway hint to provider READMEs
|
|
186
|
+
|
|
187
|
+
## 4.0.0-beta.10
|
|
188
|
+
|
|
189
|
+
### Patch Changes
|
|
190
|
+
|
|
191
|
+
- Updated dependencies [2e17091]
|
|
192
|
+
- @ai-sdk/provider-utils@5.0.0-beta.9
|
|
193
|
+
|
|
194
|
+
## 4.0.0-beta.9
|
|
195
|
+
|
|
196
|
+
### Patch Changes
|
|
197
|
+
|
|
198
|
+
- Updated dependencies [986c6fd]
|
|
199
|
+
- Updated dependencies [493295c]
|
|
200
|
+
- @ai-sdk/provider-utils@5.0.0-beta.8
|
|
201
|
+
|
|
202
|
+
## 4.0.0-beta.8
|
|
203
|
+
|
|
204
|
+
### Patch Changes
|
|
205
|
+
|
|
206
|
+
- Updated dependencies [1f509d4]
|
|
207
|
+
- @ai-sdk/provider-utils@5.0.0-beta.7
|
|
208
|
+
- @ai-sdk/provider@4.0.0-beta.5
|
|
209
|
+
|
|
210
|
+
## 4.0.0-beta.7
|
|
211
|
+
|
|
212
|
+
### Patch Changes
|
|
213
|
+
|
|
214
|
+
- 74d520f: feat: migrate providers to support new top-level `reasoning` parameter
|
|
215
|
+
|
|
216
|
+
## 4.0.0-beta.6
|
|
217
|
+
|
|
218
|
+
### Patch Changes
|
|
219
|
+
|
|
220
|
+
- Updated dependencies [3887c70]
|
|
221
|
+
- @ai-sdk/provider-utils@5.0.0-beta.6
|
|
222
|
+
- @ai-sdk/provider@4.0.0-beta.4
|
|
223
|
+
|
|
224
|
+
## 4.0.0-beta.5
|
|
225
|
+
|
|
226
|
+
### Patch Changes
|
|
227
|
+
|
|
228
|
+
- Updated dependencies [776b617]
|
|
229
|
+
- @ai-sdk/provider-utils@5.0.0-beta.5
|
|
230
|
+
- @ai-sdk/provider@4.0.0-beta.3
|
|
231
|
+
|
|
232
|
+
## 4.0.0-beta.4
|
|
233
|
+
|
|
234
|
+
### Patch Changes
|
|
235
|
+
|
|
236
|
+
- Updated dependencies [61753c3]
|
|
237
|
+
- @ai-sdk/provider-utils@5.0.0-beta.4
|
|
238
|
+
|
|
3
239
|
## 4.0.0-beta.3
|
|
4
240
|
|
|
5
241
|
### Patch Changes
|
|
@@ -232,13 +468,13 @@
|
|
|
232
468
|
Before
|
|
233
469
|
|
|
234
470
|
```ts
|
|
235
|
-
model.textEmbeddingModel(
|
|
471
|
+
model.textEmbeddingModel("my-model-id");
|
|
236
472
|
```
|
|
237
473
|
|
|
238
474
|
After
|
|
239
475
|
|
|
240
476
|
```ts
|
|
241
|
-
model.embeddingModel(
|
|
477
|
+
model.embeddingModel("my-model-id");
|
|
242
478
|
```
|
|
243
479
|
|
|
244
480
|
- 2625a04: feat(openai); update spec for mcp approval
|
|
@@ -450,13 +686,13 @@
|
|
|
450
686
|
Before
|
|
451
687
|
|
|
452
688
|
```ts
|
|
453
|
-
model.textEmbeddingModel(
|
|
689
|
+
model.textEmbeddingModel("my-model-id");
|
|
454
690
|
```
|
|
455
691
|
|
|
456
692
|
After
|
|
457
693
|
|
|
458
694
|
```ts
|
|
459
|
-
model.embeddingModel(
|
|
695
|
+
model.embeddingModel("my-model-id");
|
|
460
696
|
```
|
|
461
697
|
|
|
462
698
|
- Updated dependencies [8d9e8ad]
|
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
The **[Cohere provider](https://ai-sdk.dev/providers/ai-sdk-providers/cohere)** for the [AI SDK](https://ai-sdk.dev/docs) contains language model support for the Cohere API.
|
|
4
4
|
|
|
5
|
+
> **Deploying to Vercel?** With Vercel's AI Gateway you can access Cohere (and hundreds of models from other providers) — no additional packages, API keys, or extra cost. [Get started with AI Gateway](https://vercel.com/ai-gateway).
|
|
6
|
+
|
|
5
7
|
## Setup
|
|
6
8
|
|
|
7
9
|
The Cohere provider is available in the `@ai-sdk/cohere` module. You can install it with
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod/v4';
|
|
2
|
-
import {
|
|
2
|
+
import { ProviderV4, LanguageModelV4, EmbeddingModelV4, RerankingModelV4 } from '@ai-sdk/provider';
|
|
3
3
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
4
|
|
|
5
5
|
type CohereChatModelId = 'command-a-03-2025' | 'command-a-reasoning-08-2025' | 'command-r7b-12-2024' | 'command-r-plus-04-2024' | 'command-r-plus' | 'command-r-08-2024' | 'command-r-03-2024' | 'command-r' | 'command' | 'command-nightly' | 'command-light' | 'command-light-nightly' | (string & {});
|
|
@@ -47,36 +47,36 @@ declare const cohereEmbeddingModelOptions: z.ZodObject<{
|
|
|
47
47
|
}, z.core.$strip>;
|
|
48
48
|
type CohereEmbeddingModelOptions = z.infer<typeof cohereEmbeddingModelOptions>;
|
|
49
49
|
|
|
50
|
-
interface CohereProvider extends
|
|
51
|
-
(modelId: CohereChatModelId):
|
|
50
|
+
interface CohereProvider extends ProviderV4 {
|
|
51
|
+
(modelId: CohereChatModelId): LanguageModelV4;
|
|
52
52
|
/**
|
|
53
53
|
* Creates a model for text generation.
|
|
54
54
|
*/
|
|
55
|
-
languageModel(modelId: CohereChatModelId):
|
|
55
|
+
languageModel(modelId: CohereChatModelId): LanguageModelV4;
|
|
56
56
|
/**
|
|
57
57
|
* Creates a model for text embeddings.
|
|
58
58
|
*/
|
|
59
|
-
embedding(modelId: CohereEmbeddingModelId):
|
|
59
|
+
embedding(modelId: CohereEmbeddingModelId): EmbeddingModelV4;
|
|
60
60
|
/**
|
|
61
61
|
* Creates a model for text embeddings.
|
|
62
62
|
*/
|
|
63
|
-
embeddingModel(modelId: CohereEmbeddingModelId):
|
|
63
|
+
embeddingModel(modelId: CohereEmbeddingModelId): EmbeddingModelV4;
|
|
64
64
|
/**
|
|
65
65
|
* @deprecated Use `embedding` instead.
|
|
66
66
|
*/
|
|
67
|
-
textEmbedding(modelId: CohereEmbeddingModelId):
|
|
67
|
+
textEmbedding(modelId: CohereEmbeddingModelId): EmbeddingModelV4;
|
|
68
68
|
/**
|
|
69
69
|
* @deprecated Use `embeddingModel` instead.
|
|
70
70
|
*/
|
|
71
|
-
textEmbeddingModel(modelId: CohereEmbeddingModelId):
|
|
71
|
+
textEmbeddingModel(modelId: CohereEmbeddingModelId): EmbeddingModelV4;
|
|
72
72
|
/**
|
|
73
73
|
* Creates a model for reranking.
|
|
74
74
|
*/
|
|
75
|
-
reranking(modelId: CohereRerankingModelId):
|
|
75
|
+
reranking(modelId: CohereRerankingModelId): RerankingModelV4;
|
|
76
76
|
/**
|
|
77
77
|
* Creates a model for reranking.
|
|
78
78
|
*/
|
|
79
|
-
rerankingModel(modelId: CohereRerankingModelId):
|
|
79
|
+
rerankingModel(modelId: CohereRerankingModelId): RerankingModelV4;
|
|
80
80
|
}
|
|
81
81
|
interface CohereProviderSettings {
|
|
82
82
|
/**
|