@ai-sdk/cohere 4.0.0-beta.1 → 4.0.0-beta.10
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 +72 -4
- package/dist/index.d.mts +10 -10
- package/dist/index.d.ts +10 -10
- package/dist/index.js +50 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +49 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -5
- package/src/cohere-chat-language-model.ts +72 -25
- package/src/cohere-embedding-model.ts +5 -5
- package/src/cohere-prepare-tools.ts +6 -6
- package/src/cohere-provider.ts +14 -14
- package/src/convert-cohere-usage.ts +2 -2
- package/src/convert-to-cohere-chat-prompt.ts +5 -5
- package/src/map-cohere-finish-reason.ts +2 -2
- package/src/reranking/cohere-reranking-model.ts +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,73 @@
|
|
|
1
1
|
# @ai-sdk/cohere
|
|
2
2
|
|
|
3
|
+
## 4.0.0-beta.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [2e17091]
|
|
8
|
+
- @ai-sdk/provider-utils@5.0.0-beta.9
|
|
9
|
+
|
|
10
|
+
## 4.0.0-beta.9
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [986c6fd]
|
|
15
|
+
- Updated dependencies [493295c]
|
|
16
|
+
- @ai-sdk/provider-utils@5.0.0-beta.8
|
|
17
|
+
|
|
18
|
+
## 4.0.0-beta.8
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [1f509d4]
|
|
23
|
+
- @ai-sdk/provider-utils@5.0.0-beta.7
|
|
24
|
+
- @ai-sdk/provider@4.0.0-beta.5
|
|
25
|
+
|
|
26
|
+
## 4.0.0-beta.7
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- 74d520f: feat: migrate providers to support new top-level `reasoning` parameter
|
|
31
|
+
|
|
32
|
+
## 4.0.0-beta.6
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- Updated dependencies [3887c70]
|
|
37
|
+
- @ai-sdk/provider-utils@5.0.0-beta.6
|
|
38
|
+
- @ai-sdk/provider@4.0.0-beta.4
|
|
39
|
+
|
|
40
|
+
## 4.0.0-beta.5
|
|
41
|
+
|
|
42
|
+
### Patch Changes
|
|
43
|
+
|
|
44
|
+
- Updated dependencies [776b617]
|
|
45
|
+
- @ai-sdk/provider-utils@5.0.0-beta.5
|
|
46
|
+
- @ai-sdk/provider@4.0.0-beta.3
|
|
47
|
+
|
|
48
|
+
## 4.0.0-beta.4
|
|
49
|
+
|
|
50
|
+
### Patch Changes
|
|
51
|
+
|
|
52
|
+
- Updated dependencies [61753c3]
|
|
53
|
+
- @ai-sdk/provider-utils@5.0.0-beta.4
|
|
54
|
+
|
|
55
|
+
## 4.0.0-beta.3
|
|
56
|
+
|
|
57
|
+
### Patch Changes
|
|
58
|
+
|
|
59
|
+
- Updated dependencies [f7d4f01]
|
|
60
|
+
- @ai-sdk/provider-utils@5.0.0-beta.3
|
|
61
|
+
- @ai-sdk/provider@4.0.0-beta.2
|
|
62
|
+
|
|
63
|
+
## 4.0.0-beta.2
|
|
64
|
+
|
|
65
|
+
### Patch Changes
|
|
66
|
+
|
|
67
|
+
- Updated dependencies [5c2a5a2]
|
|
68
|
+
- @ai-sdk/provider@4.0.0-beta.1
|
|
69
|
+
- @ai-sdk/provider-utils@5.0.0-beta.2
|
|
70
|
+
|
|
3
71
|
## 4.0.0-beta.1
|
|
4
72
|
|
|
5
73
|
### Patch Changes
|
|
@@ -216,13 +284,13 @@
|
|
|
216
284
|
Before
|
|
217
285
|
|
|
218
286
|
```ts
|
|
219
|
-
model.textEmbeddingModel(
|
|
287
|
+
model.textEmbeddingModel("my-model-id");
|
|
220
288
|
```
|
|
221
289
|
|
|
222
290
|
After
|
|
223
291
|
|
|
224
292
|
```ts
|
|
225
|
-
model.embeddingModel(
|
|
293
|
+
model.embeddingModel("my-model-id");
|
|
226
294
|
```
|
|
227
295
|
|
|
228
296
|
- 2625a04: feat(openai); update spec for mcp approval
|
|
@@ -434,13 +502,13 @@
|
|
|
434
502
|
Before
|
|
435
503
|
|
|
436
504
|
```ts
|
|
437
|
-
model.textEmbeddingModel(
|
|
505
|
+
model.textEmbeddingModel("my-model-id");
|
|
438
506
|
```
|
|
439
507
|
|
|
440
508
|
After
|
|
441
509
|
|
|
442
510
|
```ts
|
|
443
|
-
model.embeddingModel(
|
|
511
|
+
model.embeddingModel("my-model-id");
|
|
444
512
|
```
|
|
445
513
|
|
|
446
514
|
- Updated dependencies [8d9e8ad]
|
package/dist/index.d.mts
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
|
/**
|
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
|
/**
|
package/dist/index.js
CHANGED
|
@@ -18,13 +18,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
20
|
// src/index.ts
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
23
|
VERSION: () => VERSION,
|
|
24
24
|
cohere: () => cohere,
|
|
25
25
|
createCohere: () => createCohere
|
|
26
26
|
});
|
|
27
|
-
module.exports = __toCommonJS(
|
|
27
|
+
module.exports = __toCommonJS(index_exports);
|
|
28
28
|
|
|
29
29
|
// src/cohere-provider.ts
|
|
30
30
|
var import_provider4 = require("@ai-sdk/provider");
|
|
@@ -295,7 +295,7 @@ function mapCohereFinishReason(finishReason) {
|
|
|
295
295
|
// src/cohere-chat-language-model.ts
|
|
296
296
|
var CohereChatLanguageModel = class {
|
|
297
297
|
constructor(modelId, config) {
|
|
298
|
-
this.specificationVersion = "
|
|
298
|
+
this.specificationVersion = "v4";
|
|
299
299
|
this.supportedUrls = {
|
|
300
300
|
// No URLs are supported.
|
|
301
301
|
};
|
|
@@ -316,11 +316,13 @@ var CohereChatLanguageModel = class {
|
|
|
316
316
|
stopSequences,
|
|
317
317
|
responseFormat,
|
|
318
318
|
seed,
|
|
319
|
+
reasoning,
|
|
319
320
|
tools,
|
|
320
321
|
toolChoice,
|
|
321
322
|
providerOptions
|
|
322
323
|
}) {
|
|
323
|
-
var _a
|
|
324
|
+
var _a;
|
|
325
|
+
const warnings = [];
|
|
324
326
|
const cohereOptions = (_a = await (0, import_provider_utils2.parseProviderOptions)({
|
|
325
327
|
provider: "cohere",
|
|
326
328
|
providerOptions,
|
|
@@ -336,6 +338,7 @@ var CohereChatLanguageModel = class {
|
|
|
336
338
|
toolChoice: cohereToolChoice,
|
|
337
339
|
toolWarnings
|
|
338
340
|
} = prepareTools({ tools, toolChoice });
|
|
341
|
+
warnings.push(...toolWarnings, ...promptWarnings);
|
|
339
342
|
return {
|
|
340
343
|
args: {
|
|
341
344
|
// model id:
|
|
@@ -358,15 +361,14 @@ var CohereChatLanguageModel = class {
|
|
|
358
361
|
tool_choice: cohereToolChoice,
|
|
359
362
|
// documents for RAG:
|
|
360
363
|
...cohereDocuments.length > 0 && { documents: cohereDocuments },
|
|
361
|
-
// reasoning
|
|
362
|
-
...
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
}
|
|
364
|
+
// reasoning:
|
|
365
|
+
...resolveCohereThinking({
|
|
366
|
+
reasoning,
|
|
367
|
+
cohereOptions,
|
|
368
|
+
warnings
|
|
369
|
+
})
|
|
368
370
|
},
|
|
369
|
-
warnings
|
|
371
|
+
warnings
|
|
370
372
|
};
|
|
371
373
|
}
|
|
372
374
|
async doGenerate(options) {
|
|
@@ -617,6 +619,37 @@ var CohereChatLanguageModel = class {
|
|
|
617
619
|
};
|
|
618
620
|
}
|
|
619
621
|
};
|
|
622
|
+
function resolveCohereThinking({
|
|
623
|
+
reasoning,
|
|
624
|
+
cohereOptions,
|
|
625
|
+
warnings
|
|
626
|
+
}) {
|
|
627
|
+
var _a;
|
|
628
|
+
if (cohereOptions.thinking) {
|
|
629
|
+
return {
|
|
630
|
+
thinking: {
|
|
631
|
+
type: (_a = cohereOptions.thinking.type) != null ? _a : "enabled",
|
|
632
|
+
token_budget: cohereOptions.thinking.tokenBudget
|
|
633
|
+
}
|
|
634
|
+
};
|
|
635
|
+
}
|
|
636
|
+
if (!(0, import_provider_utils2.isCustomReasoning)(reasoning)) {
|
|
637
|
+
return {};
|
|
638
|
+
}
|
|
639
|
+
if (reasoning === "none") {
|
|
640
|
+
return { thinking: { type: "disabled" } };
|
|
641
|
+
}
|
|
642
|
+
const tokenBudget = (0, import_provider_utils2.mapReasoningToProviderBudget)({
|
|
643
|
+
reasoning,
|
|
644
|
+
maxOutputTokens: 32768,
|
|
645
|
+
maxReasoningBudget: 32768,
|
|
646
|
+
warnings
|
|
647
|
+
});
|
|
648
|
+
if (tokenBudget == null) {
|
|
649
|
+
return {};
|
|
650
|
+
}
|
|
651
|
+
return { thinking: { type: "enabled", token_budget: tokenBudget } };
|
|
652
|
+
}
|
|
620
653
|
var cohereChatResponseSchema = import_v43.z.object({
|
|
621
654
|
generation_id: import_v43.z.string().nullish(),
|
|
622
655
|
message: import_v43.z.object({
|
|
@@ -820,7 +853,7 @@ var cohereEmbeddingModelOptions = import_v44.z.object({
|
|
|
820
853
|
// src/cohere-embedding-model.ts
|
|
821
854
|
var CohereEmbeddingModel = class {
|
|
822
855
|
constructor(modelId, config) {
|
|
823
|
-
this.specificationVersion = "
|
|
856
|
+
this.specificationVersion = "v4";
|
|
824
857
|
this.maxEmbeddingsPerCall = 96;
|
|
825
858
|
this.supportsParallelCalls = true;
|
|
826
859
|
this.modelId = modelId;
|
|
@@ -929,7 +962,7 @@ var cohereRerankingModelOptionsSchema = (0, import_provider_utils5.lazySchema)(
|
|
|
929
962
|
// src/reranking/cohere-reranking-model.ts
|
|
930
963
|
var CohereRerankingModel = class {
|
|
931
964
|
constructor(modelId, config) {
|
|
932
|
-
this.specificationVersion = "
|
|
965
|
+
this.specificationVersion = "v4";
|
|
933
966
|
this.modelId = modelId;
|
|
934
967
|
this.config = config;
|
|
935
968
|
}
|
|
@@ -997,7 +1030,7 @@ var CohereRerankingModel = class {
|
|
|
997
1030
|
};
|
|
998
1031
|
|
|
999
1032
|
// src/version.ts
|
|
1000
|
-
var VERSION = true ? "4.0.0-beta.
|
|
1033
|
+
var VERSION = true ? "4.0.0-beta.10" : "0.0.0-test";
|
|
1001
1034
|
|
|
1002
1035
|
// src/cohere-provider.ts
|
|
1003
1036
|
function createCohere(options = {}) {
|
|
@@ -1044,7 +1077,7 @@ function createCohere(options = {}) {
|
|
|
1044
1077
|
}
|
|
1045
1078
|
return createChatModel(modelId);
|
|
1046
1079
|
};
|
|
1047
|
-
provider.specificationVersion = "
|
|
1080
|
+
provider.specificationVersion = "v4";
|
|
1048
1081
|
provider.languageModel = createChatModel;
|
|
1049
1082
|
provider.embedding = createEmbeddingModel;
|
|
1050
1083
|
provider.embeddingModel = createEmbeddingModel;
|