@ai-sdk/cohere 4.0.88 → 4.0.90
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.ts +92 -207
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +219 -82
- package/dist/index.js.map +1 -1
- package/package.json +8 -4
- package/src/cohere-model-catalog.ts +223 -89
package/dist/index.js
CHANGED
|
@@ -100,52 +100,105 @@ const cohereProviderOptions = {
|
|
|
100
100
|
priority: { description: "Request processing priority." }
|
|
101
101
|
}
|
|
102
102
|
};
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
"command-a-03-2025": standard,
|
|
103
|
+
/**
|
|
104
|
+
* Language model matrix: model IDs by capability. To add a model, add a row
|
|
105
|
+
* and fill in every column.
|
|
106
|
+
*/
|
|
107
|
+
const languageModelDefinitions = {
|
|
108
|
+
"command-a-03-2025": {
|
|
109
|
+
image: false,
|
|
110
|
+
objectGeneration: true,
|
|
111
|
+
functionTools: ["streaming"],
|
|
112
|
+
reasoning: "unknown"
|
|
113
|
+
},
|
|
115
114
|
"command-a-reasoning-08-2025": {
|
|
116
|
-
|
|
115
|
+
image: false,
|
|
116
|
+
objectGeneration: true,
|
|
117
|
+
functionTools: ["streaming"],
|
|
117
118
|
reasoning: true
|
|
118
119
|
},
|
|
119
120
|
"command-a-vision-07-2025": {
|
|
120
|
-
|
|
121
|
-
|
|
121
|
+
image: true,
|
|
122
|
+
objectGeneration: true,
|
|
123
|
+
functionTools: ["streaming"],
|
|
124
|
+
reasoning: "unknown"
|
|
125
|
+
},
|
|
126
|
+
"command-r7b-12-2024": {
|
|
127
|
+
image: false,
|
|
128
|
+
objectGeneration: true,
|
|
129
|
+
functionTools: ["streaming"],
|
|
130
|
+
reasoning: "unknown"
|
|
131
|
+
},
|
|
132
|
+
"command-r-plus-04-2024": {
|
|
133
|
+
image: false,
|
|
134
|
+
objectGeneration: true,
|
|
135
|
+
functionTools: ["streaming"],
|
|
136
|
+
reasoning: "unknown"
|
|
137
|
+
},
|
|
138
|
+
"command-r-plus": {
|
|
139
|
+
image: false,
|
|
140
|
+
objectGeneration: true,
|
|
141
|
+
functionTools: ["streaming"],
|
|
142
|
+
reasoning: "unknown"
|
|
122
143
|
},
|
|
123
|
-
"command-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
command:
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
144
|
+
"command-r-08-2024": {
|
|
145
|
+
image: false,
|
|
146
|
+
objectGeneration: true,
|
|
147
|
+
functionTools: ["streaming"],
|
|
148
|
+
reasoning: "unknown"
|
|
149
|
+
},
|
|
150
|
+
"command-r-03-2024": {
|
|
151
|
+
image: false,
|
|
152
|
+
objectGeneration: true,
|
|
153
|
+
functionTools: ["streaming"],
|
|
154
|
+
reasoning: "unknown"
|
|
155
|
+
},
|
|
156
|
+
"command-r": {
|
|
157
|
+
image: false,
|
|
158
|
+
objectGeneration: true,
|
|
159
|
+
functionTools: ["streaming"],
|
|
160
|
+
reasoning: "unknown"
|
|
161
|
+
},
|
|
162
|
+
command: {
|
|
163
|
+
image: false,
|
|
164
|
+
objectGeneration: false,
|
|
165
|
+
functionTools: false,
|
|
166
|
+
reasoning: "unknown"
|
|
167
|
+
},
|
|
168
|
+
"command-nightly": {
|
|
169
|
+
image: false,
|
|
170
|
+
objectGeneration: false,
|
|
171
|
+
functionTools: false,
|
|
172
|
+
reasoning: "unknown"
|
|
173
|
+
},
|
|
174
|
+
"command-light": {
|
|
175
|
+
image: false,
|
|
176
|
+
objectGeneration: false,
|
|
177
|
+
functionTools: false,
|
|
178
|
+
reasoning: "unknown"
|
|
179
|
+
},
|
|
180
|
+
"command-light-nightly": {
|
|
181
|
+
image: false,
|
|
182
|
+
objectGeneration: false,
|
|
183
|
+
functionTools: false,
|
|
184
|
+
reasoning: "unknown"
|
|
185
|
+
}
|
|
133
186
|
};
|
|
134
|
-
|
|
135
|
-
|
|
187
|
+
/** Maps a matrix row to its entry. Nothing here inspects the model ID. */
|
|
188
|
+
function createLanguageModelEntry(row) {
|
|
136
189
|
return {
|
|
137
190
|
capabilities: { language: {
|
|
138
191
|
inputs: {
|
|
139
|
-
image:
|
|
192
|
+
image: row.image,
|
|
140
193
|
audio: false
|
|
141
194
|
},
|
|
142
|
-
objectGeneration:
|
|
195
|
+
objectGeneration: row.objectGeneration,
|
|
143
196
|
tools: {
|
|
144
|
-
usage:
|
|
145
|
-
streaming:
|
|
197
|
+
usage: row.functionTools === "unknown" ? "unknown" : row.functionTools !== false,
|
|
198
|
+
streaming: row.functionTools === "unknown" ? "unknown" : row.functionTools !== false && row.functionTools.includes("streaming")
|
|
146
199
|
},
|
|
147
200
|
reasoning: {
|
|
148
|
-
support:
|
|
201
|
+
support: row.reasoning,
|
|
149
202
|
maxBudget: 32768
|
|
150
203
|
},
|
|
151
204
|
sampling: {
|
|
@@ -154,13 +207,21 @@ function createLanguageModelEntry(definition) {
|
|
|
154
207
|
logprobs: false
|
|
155
208
|
}
|
|
156
209
|
} },
|
|
157
|
-
providerOptions: { language:
|
|
210
|
+
providerOptions: { language: { thinking: row.reasoning } },
|
|
158
211
|
requestConfig: { language: {
|
|
159
212
|
thinkingType: "enabled",
|
|
160
213
|
reasoningMaxOutputTokens: 32768
|
|
161
214
|
} }
|
|
162
215
|
};
|
|
163
216
|
}
|
|
217
|
+
const listedLanguageModelEntries = Object.fromEntries(Object.entries(languageModelDefinitions).map(([modelId, row]) => [modelId, createLanguageModelEntry(row)]));
|
|
218
|
+
/** Row for every model ID that is not listed in the matrix. */
|
|
219
|
+
const unlistedLanguageModelRow = {
|
|
220
|
+
image: "unknown",
|
|
221
|
+
objectGeneration: "unknown",
|
|
222
|
+
functionTools: "unknown",
|
|
223
|
+
reasoning: "unknown"
|
|
224
|
+
};
|
|
164
225
|
const cohereEmbeddingModelLimits = {
|
|
165
226
|
maxEmbeddingsPerCall: 96,
|
|
166
227
|
supportsParallelCalls: true
|
|
@@ -169,26 +230,21 @@ const embeddingRequestConfig = {
|
|
|
169
230
|
embeddingType: "float",
|
|
170
231
|
inputType: "search_query"
|
|
171
232
|
};
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
"uint8",
|
|
176
|
-
"binary",
|
|
177
|
-
"ubinary"
|
|
178
|
-
];
|
|
179
|
-
function createEmbeddingModelEntry(defaultDimensions, dimensions, formats = embeddingTypes) {
|
|
233
|
+
/** Maps a matrix row to its entry. Nothing here inspects the model ID. */
|
|
234
|
+
function createEmbeddingModelEntry(row) {
|
|
235
|
+
const { defaultDimensions, dimensions, embeddingTypes } = row;
|
|
180
236
|
const customDimensions = dimensions.length > 1;
|
|
181
237
|
return {
|
|
182
238
|
capabilities: { embedding: {
|
|
183
239
|
defaultDimensions,
|
|
184
240
|
customDimensions,
|
|
185
241
|
dimensions,
|
|
186
|
-
embeddingTypes
|
|
242
|
+
embeddingTypes,
|
|
187
243
|
...cohereEmbeddingModelLimits
|
|
188
244
|
} },
|
|
189
245
|
providerOptions: { embedding: declareProviderOptions(cohereProviderOptions.embedding, true, {
|
|
190
246
|
outputDimension: customDimensions,
|
|
191
|
-
embeddingType:
|
|
247
|
+
embeddingType: embeddingTypes.length === 1 ? { condition: "Only embeddingType: 'float' is supported." } : true
|
|
192
248
|
}) },
|
|
193
249
|
requestConfig: { embedding: embeddingRequestConfig }
|
|
194
250
|
};
|
|
@@ -206,37 +262,119 @@ function createRerankingModelEntry(declared) {
|
|
|
206
262
|
providerOptions: { reranking: declareProviderOptions(cohereProviderOptions.reranking, support, {}) }
|
|
207
263
|
};
|
|
208
264
|
}
|
|
209
|
-
const cohereEmbeddingModelEntries = {
|
|
210
|
-
"embed-v5.0-pro":
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
265
|
+
const cohereEmbeddingModelEntries = Object.fromEntries(Object.entries({
|
|
266
|
+
"embed-v5.0-pro": {
|
|
267
|
+
defaultDimensions: 2048,
|
|
268
|
+
dimensions: [
|
|
269
|
+
256,
|
|
270
|
+
512,
|
|
271
|
+
768,
|
|
272
|
+
1024,
|
|
273
|
+
1536,
|
|
274
|
+
2048
|
|
275
|
+
],
|
|
276
|
+
embeddingTypes: [
|
|
277
|
+
"float",
|
|
278
|
+
"int8",
|
|
279
|
+
"uint8",
|
|
280
|
+
"binary",
|
|
281
|
+
"ubinary"
|
|
282
|
+
]
|
|
283
|
+
},
|
|
284
|
+
"embed-v5.0-fast": {
|
|
285
|
+
defaultDimensions: 2048,
|
|
286
|
+
dimensions: [
|
|
287
|
+
256,
|
|
288
|
+
512,
|
|
289
|
+
768,
|
|
290
|
+
1024,
|
|
291
|
+
1536,
|
|
292
|
+
2048
|
|
293
|
+
],
|
|
294
|
+
embeddingTypes: [
|
|
295
|
+
"float",
|
|
296
|
+
"int8",
|
|
297
|
+
"uint8",
|
|
298
|
+
"binary",
|
|
299
|
+
"ubinary"
|
|
300
|
+
]
|
|
301
|
+
},
|
|
302
|
+
"embed-v4.0": {
|
|
303
|
+
defaultDimensions: 1536,
|
|
304
|
+
dimensions: [
|
|
305
|
+
256,
|
|
306
|
+
512,
|
|
307
|
+
1024,
|
|
308
|
+
1536
|
|
309
|
+
],
|
|
310
|
+
embeddingTypes: [
|
|
311
|
+
"float",
|
|
312
|
+
"int8",
|
|
313
|
+
"uint8",
|
|
314
|
+
"binary",
|
|
315
|
+
"ubinary"
|
|
316
|
+
]
|
|
317
|
+
},
|
|
318
|
+
"embed-english-v3.0": {
|
|
319
|
+
defaultDimensions: 1024,
|
|
320
|
+
dimensions: [1024],
|
|
321
|
+
embeddingTypes: [
|
|
322
|
+
"float",
|
|
323
|
+
"int8",
|
|
324
|
+
"uint8",
|
|
325
|
+
"binary",
|
|
326
|
+
"ubinary"
|
|
327
|
+
]
|
|
328
|
+
},
|
|
329
|
+
"embed-multilingual-v3.0": {
|
|
330
|
+
defaultDimensions: 1024,
|
|
331
|
+
dimensions: [1024],
|
|
332
|
+
embeddingTypes: [
|
|
333
|
+
"float",
|
|
334
|
+
"int8",
|
|
335
|
+
"uint8",
|
|
336
|
+
"binary",
|
|
337
|
+
"ubinary"
|
|
338
|
+
]
|
|
339
|
+
},
|
|
340
|
+
"embed-english-light-v3.0": {
|
|
341
|
+
defaultDimensions: 384,
|
|
342
|
+
dimensions: [384],
|
|
343
|
+
embeddingTypes: [
|
|
344
|
+
"float",
|
|
345
|
+
"int8",
|
|
346
|
+
"uint8",
|
|
347
|
+
"binary",
|
|
348
|
+
"ubinary"
|
|
349
|
+
]
|
|
350
|
+
},
|
|
351
|
+
"embed-multilingual-light-v3.0": {
|
|
352
|
+
defaultDimensions: 384,
|
|
353
|
+
dimensions: [384],
|
|
354
|
+
embeddingTypes: [
|
|
355
|
+
"float",
|
|
356
|
+
"int8",
|
|
357
|
+
"uint8",
|
|
358
|
+
"binary",
|
|
359
|
+
"ubinary"
|
|
360
|
+
]
|
|
361
|
+
},
|
|
362
|
+
"embed-english-v2.0": {
|
|
363
|
+
defaultDimensions: 4096,
|
|
364
|
+
dimensions: [4096],
|
|
365
|
+
embeddingTypes: ["float"]
|
|
366
|
+
},
|
|
367
|
+
"embed-english-light-v2.0": {
|
|
368
|
+
defaultDimensions: 1024,
|
|
369
|
+
dimensions: [1024],
|
|
370
|
+
embeddingTypes: ["float"]
|
|
371
|
+
},
|
|
372
|
+
"embed-multilingual-v2.0": {
|
|
373
|
+
defaultDimensions: 768,
|
|
374
|
+
dimensions: [768],
|
|
375
|
+
embeddingTypes: ["float"]
|
|
376
|
+
}
|
|
377
|
+
}).map(([modelId, row]) => [modelId, createEmbeddingModelEntry(row)]));
|
|
240
378
|
const cohereRerankingModelEntries = {
|
|
241
379
|
"rerank-v4.0-pro": createRerankingModelEntry(true),
|
|
242
380
|
"rerank-v4.0-fast": createRerankingModelEntry(true),
|
|
@@ -245,20 +383,19 @@ const cohereRerankingModelEntries = {
|
|
|
245
383
|
"rerank-multilingual-v3.0": createRerankingModelEntry(true)
|
|
246
384
|
};
|
|
247
385
|
const cohereModelCatalog = {
|
|
248
|
-
...
|
|
386
|
+
...listedLanguageModelEntries,
|
|
249
387
|
...cohereEmbeddingModelEntries,
|
|
250
388
|
...cohereRerankingModelEntries
|
|
251
389
|
};
|
|
252
390
|
function findModelEntry(modelId) {
|
|
253
391
|
return Object.prototype.hasOwnProperty.call(cohereModelCatalog, modelId) ? cohereModelCatalog[modelId] : void 0;
|
|
254
392
|
}
|
|
393
|
+
/**
|
|
394
|
+
* Returns the entry of a listed language model ID from its row. Every other
|
|
395
|
+
* model ID uses the row for unlisted IDs.
|
|
396
|
+
*/
|
|
255
397
|
function getCohereLanguageModelEntry(modelId) {
|
|
256
|
-
|
|
257
|
-
return entry?.capabilities.language != null && entry.providerOptions?.language != null && entry.requestConfig?.language != null ? {
|
|
258
|
-
capabilities: { language: entry.capabilities.language },
|
|
259
|
-
providerOptions: { language: entry.providerOptions.language },
|
|
260
|
-
requestConfig: { language: entry.requestConfig.language }
|
|
261
|
-
} : createLanguageModelEntry();
|
|
398
|
+
return Object.prototype.hasOwnProperty.call(listedLanguageModelEntries, modelId) ? listedLanguageModelEntries[modelId] : createLanguageModelEntry(unlistedLanguageModelRow);
|
|
262
399
|
}
|
|
263
400
|
function getCohereEmbeddingModelEntry(modelId) {
|
|
264
401
|
const entry = findModelEntry(modelId);
|
|
@@ -1111,7 +1248,7 @@ var CohereRerankingModel = class {
|
|
|
1111
1248
|
};
|
|
1112
1249
|
//#endregion
|
|
1113
1250
|
//#region src/version.ts
|
|
1114
|
-
const VERSION = "4.0.
|
|
1251
|
+
const VERSION = "4.0.90";
|
|
1115
1252
|
//#endregion
|
|
1116
1253
|
//#region src/cohere-provider.ts
|
|
1117
1254
|
/**
|