@ai-sdk/cohere 4.0.89 → 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/dist/index.js CHANGED
@@ -100,52 +100,105 @@ const cohereProviderOptions = {
100
100
  priority: { description: "Request processing priority." }
101
101
  }
102
102
  };
103
- const standard = {
104
- image: false,
105
- objectGeneration: true,
106
- tools: true
107
- };
108
- const legacy = {
109
- image: false,
110
- objectGeneration: false,
111
- tools: false
112
- };
113
- const languageDefinitions = {
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
- ...standard,
115
+ image: false,
116
+ objectGeneration: true,
117
+ functionTools: ["streaming"],
117
118
  reasoning: true
118
119
  },
119
120
  "command-a-vision-07-2025": {
120
- ...standard,
121
- image: true
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-r7b-12-2024": standard,
124
- "command-r-plus-04-2024": standard,
125
- "command-r-plus": standard,
126
- "command-r-08-2024": standard,
127
- "command-r-03-2024": standard,
128
- "command-r": standard,
129
- command: legacy,
130
- "command-nightly": legacy,
131
- "command-light": legacy,
132
- "command-light-nightly": legacy
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
- function createLanguageModelEntry(definition) {
135
- const reasoningSupport = definition?.reasoning ?? "unknown";
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: definition?.image ?? "unknown",
192
+ image: row.image,
140
193
  audio: false
141
194
  },
142
- objectGeneration: definition?.objectGeneration ?? "unknown",
195
+ objectGeneration: row.objectGeneration,
143
196
  tools: {
144
- usage: definition?.tools ?? "unknown",
145
- streaming: definition?.tools ?? "unknown"
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: reasoningSupport,
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: declareProviderOptions(cohereProviderOptions.language, definition != null ? true : "unknown", { thinking: reasoningSupport }) },
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
- const embeddingTypes = [
173
- "float",
174
- "int8",
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: formats,
242
+ embeddingTypes,
187
243
  ...cohereEmbeddingModelLimits
188
244
  } },
189
245
  providerOptions: { embedding: declareProviderOptions(cohereProviderOptions.embedding, true, {
190
246
  outputDimension: customDimensions,
191
- embeddingType: formats.length === 1 ? { condition: "Only embeddingType: 'float' is supported." } : true
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": createEmbeddingModelEntry(2048, [
211
- 256,
212
- 512,
213
- 768,
214
- 1024,
215
- 1536,
216
- 2048
217
- ]),
218
- "embed-v5.0-fast": createEmbeddingModelEntry(2048, [
219
- 256,
220
- 512,
221
- 768,
222
- 1024,
223
- 1536,
224
- 2048
225
- ]),
226
- "embed-v4.0": createEmbeddingModelEntry(1536, [
227
- 256,
228
- 512,
229
- 1024,
230
- 1536
231
- ]),
232
- "embed-english-v3.0": createEmbeddingModelEntry(1024, [1024]),
233
- "embed-multilingual-v3.0": createEmbeddingModelEntry(1024, [1024]),
234
- "embed-english-light-v3.0": createEmbeddingModelEntry(384, [384]),
235
- "embed-multilingual-light-v3.0": createEmbeddingModelEntry(384, [384]),
236
- "embed-english-v2.0": createEmbeddingModelEntry(4096, [4096], ["float"]),
237
- "embed-english-light-v2.0": createEmbeddingModelEntry(1024, [1024], ["float"]),
238
- "embed-multilingual-v2.0": createEmbeddingModelEntry(768, [768], ["float"])
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
- ...Object.fromEntries(Object.entries(languageDefinitions).map(([modelId, definition]) => [modelId, createLanguageModelEntry(definition)])),
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
- const entry = findModelEntry(modelId);
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.89";
1251
+ const VERSION = "4.0.90";
1115
1252
  //#endregion
1116
1253
  //#region src/cohere-provider.ts
1117
1254
  /**