Skip to content

Commit ad583e3

Browse files
🌿 Fern Regeneration -- July 8, 2025 (#246)
* SDK regeneration * Fix response parsers to use V2 serializers and include raw response in fetchOverride * Delete jest.config.js * Replace jest.config.mjs with jest.config.js for TypeScript support * Remove TypeScript error suppression for File appending tests --------- Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Co-authored-by: Billy Trend <[email protected]> Co-authored-by: billytrend-cohere <[email protected]>
1 parent 6846cd4 commit ad583e3

File tree

441 files changed

+5029
-3657
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

441 files changed

+5029
-3657
lines changed

.fernignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ src/ClientV2.ts
1717
src/CustomClient.ts
1818
src/core/form-data-utils/FormDataWrapper.ts
1919
tests/unit/form-data-utils/formDataWrapper.test.ts
20+
jest.config.mjs

package.json

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cohere-ai",
3-
"version": "7.17.1",
3+
"version": "7.18.0",
44
"private": false,
55
"repository": "https://github.com/cohere-ai/cohere-typescript",
66
"main": "./index.js",
@@ -15,36 +15,37 @@
1515
"url-join": "4.0.1",
1616
"form-data": "^4.0.0",
1717
"formdata-node": "^6.0.3",
18-
"node-fetch": "2.7.0",
19-
"qs": "6.11.2",
18+
"node-fetch": "^2.7.0",
19+
"qs": "^6.13.1",
2020
"readable-stream": "^4.5.2",
21-
"js-base64": "3.7.2",
21+
"js-base64": "3.7.7",
2222
"form-data-encoder": "^4.0.2",
2323
"@aws-sdk/client-sagemaker": "^3.583.0",
2424
"@aws-sdk/credential-providers": "^3.583.0",
25-
"@smithy/protocol-http": "^5.1.2",
26-
"@smithy/signature-v4": "^5.1.2",
25+
"@aws-sdk/protocol-http": "^3.374.0",
26+
"@aws-sdk/signature-v4": "^3.374.0",
2727
"convict": "^6.2.4"
2828
},
2929
"devDependencies": {
3030
"@types/url-join": "4.0.1",
31-
"@types/qs": "6.9.8",
32-
"@types/node-fetch": "2.6.9",
31+
"@types/qs": "^6.9.17",
32+
"@types/node-fetch": "^2.6.12",
3333
"@types/readable-stream": "^4.0.14",
3434
"webpack": "^5.91.0",
3535
"ts-loader": "^9.5.1",
3636
"jest": "^29.7.0",
37-
"@types/jest": "29.5.5",
37+
"@types/jest": "^29.5.14",
3838
"ts-jest": "^29.1.2",
39-
"jest-environment-jsdom": "29.7.0",
40-
"@types/node": "17.0.33",
41-
"prettier": "2.7.1",
42-
"typescript": "4.6.4",
39+
"jest-environment-jsdom": "^29.7.0",
40+
"@types/node": "^18.19.70",
41+
"prettier": "^3.4.2",
42+
"typescript": "~5.7.2",
4343
"@types/convict": "^6.1.6"
4444
},
4545
"browser": {
4646
"fs": false,
4747
"os": false,
4848
"path": false
49-
}
50-
}
49+
},
50+
"packageManager": "[email protected]"
51+
}

reference.md

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ await client.checkApiKey();
5959

6060
## V2
6161

62-
<details><summary><code>client.v2.<a href="/src/api/resources/v2/client/Client.ts">chatStream</a>({ ...params }) -> core.Stream<Cohere.StreamedChatResponseV2></code></summary>
62+
<details><summary><code>client.v2.<a href="/src/api/resources/v2/client/Client.ts">chatStream</a>({ ...params }) -> core.Stream<Cohere.V2ChatStreamResponse></code></summary>
6363
<dl>
6464
<dd>
6565

@@ -90,12 +90,11 @@ Follow the [Migration Guide](https://docs.cohere.com/v2/docs/migrating-v1-to-v2)
9090

9191
```typescript
9292
const response = await client.v2.chatStream({
93-
model: "model",
93+
model: "command-r",
9494
messages: [
9595
{
96-
role: "tool",
97-
toolCallId: "messages",
98-
content: "messages",
96+
role: "user",
97+
content: "Hello!",
9998
},
10099
],
101100
});
@@ -136,7 +135,7 @@ for await (const item of response) {
136135
</dl>
137136
</details>
138137

139-
<details><summary><code>client.v2.<a href="/src/api/resources/v2/client/Client.ts">chat</a>({ ...params }) -> Cohere.ChatResponse</code></summary>
138+
<details><summary><code>client.v2.<a href="/src/api/resources/v2/client/Client.ts">chat</a>({ ...params }) -> Cohere.V2ChatResponse</code></summary>
140139
<dl>
141140
<dd>
142141

@@ -167,12 +166,11 @@ Follow the [Migration Guide](https://docs.cohere.com/v2/docs/migrating-v1-to-v2)
167166

168167
```typescript
169168
await client.v2.chat({
170-
model: "model",
169+
model: "command-a-03-2025",
171170
messages: [
172171
{
173-
role: "tool",
174-
toolCallId: "messages",
175-
content: "messages",
172+
role: "user",
173+
content: "Tell me about LLMs",
176174
},
177175
],
178176
});
@@ -243,8 +241,9 @@ If you want to learn more how to use the embedding model, have a look at the [Se
243241

244242
```typescript
245243
await client.v2.embed({
246-
model: "model",
247-
inputType: "search_document",
244+
texts: ["hello", "goodbye"],
245+
model: "embed-v4.0",
246+
inputType: "classification",
248247
embeddingTypes: ["float"],
249248
});
250249
```
@@ -310,9 +309,16 @@ This endpoint takes in a query and a list of texts and produces an ordered array
310309

311310
```typescript
312311
await client.v2.rerank({
313-
model: "model",
314-
query: "query",
315-
documents: ["documents"],
312+
documents: [
313+
"Carson City is the capital city of the American state of Nevada.",
314+
"The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.",
315+
"Capitalization or capitalisation in English grammar is the use of a capital letter at the start of a word. English usage varies from capitalization in other languages.",
316+
"Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district.",
317+
"Capital punishment has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states.",
318+
],
319+
query: "What is the capital of the United States?",
320+
topN: 3,
321+
model: "rerank-v3.5",
316322
});
317323
```
318324

scripts/rename-to-esm-files.js

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#!/usr/bin/env node
2+
3+
const fs = require("fs").promises;
4+
const path = require("path");
5+
6+
const extensionMap = {
7+
".js": ".mjs",
8+
".d.ts": ".d.mts",
9+
};
10+
const oldExtensions = Object.keys(extensionMap);
11+
12+
async function findFiles(rootPath) {
13+
const files = [];
14+
15+
async function scan(directory) {
16+
const entries = await fs.readdir(directory, { withFileTypes: true });
17+
18+
for (const entry of entries) {
19+
const fullPath = path.join(directory, entry.name);
20+
21+
if (entry.isDirectory()) {
22+
if (entry.name !== "node_modules" && !entry.name.startsWith(".")) {
23+
await scan(fullPath);
24+
}
25+
} else if (entry.isFile()) {
26+
if (oldExtensions.some((ext) => entry.name.endsWith(ext))) {
27+
files.push(fullPath);
28+
}
29+
}
30+
}
31+
}
32+
33+
await scan(rootPath);
34+
return files;
35+
}
36+
37+
async function updateFiles(files) {
38+
const updatedFiles = [];
39+
for (const file of files) {
40+
const updated = await updateFileContents(file);
41+
updatedFiles.push(updated);
42+
}
43+
44+
console.log(`Updated imports in ${updatedFiles.length} files.`);
45+
}
46+
47+
async function updateFileContents(file) {
48+
const content = await fs.readFile(file, "utf8");
49+
50+
let newContent = content;
51+
// Update each extension type defined in the map
52+
for (const [oldExt, newExt] of Object.entries(extensionMap)) {
53+
const regex = new RegExp(`(import|export)(.+from\\s+['"])(\\.\\.?\\/[^'"]+)(\\${oldExt})(['"])`, "g");
54+
newContent = newContent.replace(regex, `$1$2$3${newExt}$5`);
55+
}
56+
57+
if (content !== newContent) {
58+
await fs.writeFile(file, newContent, "utf8");
59+
return true;
60+
}
61+
return false;
62+
}
63+
64+
async function renameFiles(files) {
65+
let counter = 0;
66+
for (const file of files) {
67+
const ext = oldExtensions.find((ext) => file.endsWith(ext));
68+
const newExt = extensionMap[ext];
69+
70+
if (newExt) {
71+
const newPath = file.slice(0, -ext.length) + newExt;
72+
await fs.rename(file, newPath);
73+
counter++;
74+
}
75+
}
76+
77+
console.log(`Renamed ${counter} files.`);
78+
}
79+
80+
async function main() {
81+
try {
82+
const targetDir = process.argv[2];
83+
if (!targetDir) {
84+
console.error("Please provide a target directory");
85+
process.exit(1);
86+
}
87+
88+
const targetPath = path.resolve(targetDir);
89+
const targetStats = await fs.stat(targetPath);
90+
91+
if (!targetStats.isDirectory()) {
92+
console.error("The provided path is not a directory");
93+
process.exit(1);
94+
}
95+
96+
console.log(`Scanning directory: ${targetDir}`);
97+
98+
const files = await findFiles(targetDir);
99+
100+
if (files.length === 0) {
101+
console.log("No matching files found.");
102+
process.exit(0);
103+
}
104+
105+
console.log(`Found ${files.length} files.`);
106+
await updateFiles(files);
107+
await renameFiles(files);
108+
console.log("\nDone!");
109+
} catch (error) {
110+
console.error("An error occurred:", error.message);
111+
process.exit(1);
112+
}
113+
}
114+
115+
main();

0 commit comments

Comments
 (0)