Skip to content

Commit e1cf70d

Browse files
release: 0.3.0 (#21)
Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
1 parent cc50fc3 commit e1cf70d

34 files changed

+1698
-167
lines changed

.devcontainer/Dockerfile

Lines changed: 0 additions & 23 deletions
This file was deleted.

.devcontainer/devcontainer.json

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
22
// README at: https://github.com/devcontainers/templates/tree/main/src/debian
33
{
4-
"name": "Debian",
5-
"build": {
6-
"dockerfile": "Dockerfile"
4+
"name": "Development",
5+
"image": "mcr.microsoft.com/devcontainers/typescript-node:latest",
6+
"features": {
7+
"ghcr.io/devcontainers/features/node:1": {}
8+
},
9+
"postCreateCommand": "yarn install",
10+
"customizations": {
11+
"vscode": {
12+
"extensions": [
13+
"esbenp.prettier-vscode"
14+
]
15+
}
716
}
8-
9-
// Features to add to the dev container. More info: https://containers.dev/features.
10-
// "features": {},
11-
12-
// Use 'forwardPorts' to make a list of ports inside the container available locally.
13-
// "forwardPorts": [],
14-
15-
// Configure tool-specific properties.
16-
// "customizations": {},
17-
18-
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
19-
// "remoteUser": "root"
2017
}

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.2.0"
2+
".": "0.3.0"
33
}

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
configured_endpoints: 35
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/contextual-ai%2Fsunrise-d79ccb778953ad5c2ae4b99115429c8b3f68b3b23d9b6d90b1b40393f11a4383.yml
1+
configured_endpoints: 46
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/contextual-ai%2Fsunrise-5298551c424bb999f258bdd6c311e96c80c70701ad59bbce19b46c788ee13bd4.yml

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
# Changelog
22

3+
## 0.3.0 (2025-02-26)
4+
5+
Full Changelog: [v0.2.0...v0.3.0](https://github.com/ContextualAI/contextual-client-node/compare/v0.2.0...v0.3.0)
6+
7+
### Features
8+
9+
* **api:** update via SDK Studio ([#20](https://github.com/ContextualAI/contextual-client-node/issues/20)) ([ca5487d](https://github.com/ContextualAI/contextual-client-node/commit/ca5487db83e2aea688b31413e9c594ff3f463f63))
10+
* **api:** update via SDK Studio ([#25](https://github.com/ContextualAI/contextual-client-node/issues/25)) ([366e7bc](https://github.com/ContextualAI/contextual-client-node/commit/366e7bc974e79509e2627d764523f5156ff6d5bb))
11+
* **api:** update via SDK Studio ([#26](https://github.com/ContextualAI/contextual-client-node/issues/26)) ([87470ef](https://github.com/ContextualAI/contextual-client-node/commit/87470ef70c3a84cf8873f2cac7f705305fd9dde8))
12+
13+
14+
### Bug Fixes
15+
16+
* **client:** fix export map for index exports ([#22](https://github.com/ContextualAI/contextual-client-node/issues/22)) ([9775826](https://github.com/ContextualAI/contextual-client-node/commit/977582624e283aac91c128e9b0f004e2e40f3562))
17+
18+
19+
### Chores
20+
21+
* **internal:** codegen related update ([#23](https://github.com/ContextualAI/contextual-client-node/issues/23)) ([1643590](https://github.com/ContextualAI/contextual-client-node/commit/16435904607828ebae0559d90397c7a15dca2619))
22+
* **internal:** fix devcontainers setup ([#24](https://github.com/ContextualAI/contextual-client-node/issues/24)) ([ecf1652](https://github.com/ContextualAI/contextual-client-node/commit/ecf16521a46c1265811ca2d66cad02b172eda636))
23+
324
## 0.2.0 (2025-02-08)
425

526
Full Changelog: [v0.1.0...v0.2.0](https://github.com/ContextualAI/contextual-client-node/compare/v0.1.0...v0.2.0)

README.md

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const client = new ContextualAI({
2525
});
2626

2727
async function main() {
28-
const createAgentOutput = await client.agents.create({ name: 'xxx' });
28+
const createAgentOutput = await client.agents.create({ name: 'Example' });
2929

3030
console.log(createAgentOutput.id);
3131
}
@@ -46,7 +46,7 @@ const client = new ContextualAI({
4646
});
4747

4848
async function main() {
49-
const params: ContextualAI.AgentCreateParams = { name: 'xxx' };
49+
const params: ContextualAI.AgentCreateParams = { name: 'Example' };
5050
const createAgentOutput: ContextualAI.CreateAgentOutput = await client.agents.create(params);
5151
}
5252

@@ -55,6 +55,46 @@ main();
5555

5656
Documentation for each method, request param, and response field are available in docstrings and will appear on hover in most modern editors.
5757

58+
## File uploads
59+
60+
Request parameters that correspond to file uploads can be passed in many different forms:
61+
62+
- `File` (or an object with the same structure)
63+
- a `fetch` `Response` (or an object with the same structure)
64+
- an `fs.ReadStream`
65+
- the return value of our `toFile` helper
66+
67+
```ts
68+
import fs from 'fs';
69+
import fetch from 'node-fetch';
70+
import ContextualAI, { toFile } from 'contextual-client';
71+
72+
const client = new ContextualAI();
73+
74+
// If you have access to Node `fs` we recommend using `fs.createReadStream()`:
75+
await client.datastores.documents.ingest('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
76+
file: fs.createReadStream('/path/to/file'),
77+
});
78+
79+
// Or if you have the web `File` API you can pass a `File` instance:
80+
await client.datastores.documents.ingest('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
81+
file: new File(['my bytes'], 'file'),
82+
});
83+
84+
// You can also pass a `fetch` `Response`:
85+
await client.datastores.documents.ingest('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
86+
file: await fetch('https://somesite/file'),
87+
});
88+
89+
// Finally, if none of the above are convenient, you can use our `toFile` helper:
90+
await client.datastores.documents.ingest('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
91+
file: await toFile(Buffer.from('my bytes'), 'file'),
92+
});
93+
await client.datastores.documents.ingest('182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', {
94+
file: await toFile(new Uint8Array([0, 1, 2]), 'file'),
95+
});
96+
```
97+
5898
## Handling errors
5999

60100
When the library is unable to connect to the API,
@@ -64,7 +104,7 @@ a subclass of `APIError` will be thrown:
64104
<!-- prettier-ignore -->
65105
```ts
66106
async function main() {
67-
const createAgentOutput = await client.agents.create({ name: 'xxx' }).catch(async (err) => {
107+
const createAgentOutput = await client.agents.create({ name: 'Example' }).catch(async (err) => {
68108
if (err instanceof ContextualAI.APIError) {
69109
console.log(err.status); // 400
70110
console.log(err.name); // BadRequestError
@@ -107,7 +147,7 @@ const client = new ContextualAI({
107147
});
108148

109149
// Or, configure per-request:
110-
await client.agents.create({ name: 'xxx' }, {
150+
await client.agents.create({ name: 'Example' }, {
111151
maxRetries: 5,
112152
});
113153
```
@@ -124,7 +164,7 @@ const client = new ContextualAI({
124164
});
125165

126166
// Override per-request:
127-
await client.agents.create({ name: 'xxx' }, {
167+
await client.agents.create({ name: 'Example' }, {
128168
timeout: 5 * 1000,
129169
});
130170
```
@@ -176,11 +216,13 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi
176216
```ts
177217
const client = new ContextualAI();
178218

179-
const response = await client.agents.create({ name: 'xxx' }).asResponse();
219+
const response = await client.agents.create({ name: 'Example' }).asResponse();
180220
console.log(response.headers.get('X-My-Header'));
181221
console.log(response.statusText); // access the underlying Response object
182222

183-
const { data: createAgentOutput, response: raw } = await client.agents.create({ name: 'xxx' }).withResponse();
223+
const { data: createAgentOutput, response: raw } = await client.agents
224+
.create({ name: 'Example' })
225+
.withResponse();
184226
console.log(raw.headers.get('X-My-Header'));
185227
console.log(createAgentOutput.id);
186228
```
@@ -287,7 +329,7 @@ const client = new ContextualAI({
287329

288330
// Override per-request:
289331
await client.agents.create(
290-
{ name: 'xxx' },
332+
{ name: 'Example' },
291333
{
292334
httpAgent: new http.Agent({ keepAlive: false }),
293335
},

api.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Methods:
3030
- <code title="delete /datastores/{datastore_id}/documents/{document_id}">client.datastores.documents.<a href="./src/resources/datastores/documents.ts">delete</a>(datastoreId, documentId) -> unknown</code>
3131
- <code title="post /datastores/{datastore_id}/documents">client.datastores.documents.<a href="./src/resources/datastores/documents.ts">ingest</a>(datastoreId, { ...params }) -> IngestionResponse</code>
3232
- <code title="get /datastores/{datastore_id}/documents/{document_id}/metadata">client.datastores.documents.<a href="./src/resources/datastores/documents.ts">metadata</a>(datastoreId, documentId) -> DocumentMetadata</code>
33+
- <code title="post /datastores/{datastore_id}/documents/{document_id}/metadata">client.datastores.documents.<a href="./src/resources/datastores/documents.ts">setMetadata</a>(datastoreId, documentId, { ...params }) -> DocumentMetadata</code>
3334

3435
# Agents
3536

@@ -98,6 +99,21 @@ Types:
9899
- <code><a href="./src/resources/agents/datasets/datasets.ts">DatasetMetadata</a></code>
99100
- <code><a href="./src/resources/agents/datasets/datasets.ts">ListDatasetsResponse</a></code>
100101

102+
### Tune
103+
104+
Types:
105+
106+
- <code><a href="./src/resources/agents/datasets/tune.ts">TuneDeleteResponse</a></code>
107+
108+
Methods:
109+
110+
- <code title="post /agents/{agent_id}/datasets/tune">client.agents.datasets.tune.<a href="./src/resources/agents/datasets/tune.ts">create</a>(agentId, { ...params }) -> CreateDatasetResponse</code>
111+
- <code title="get /agents/{agent_id}/datasets/tune/{dataset_name}">client.agents.datasets.tune.<a href="./src/resources/agents/datasets/tune.ts">retrieve</a>(agentId, datasetName, { ...params }) -> Response</code>
112+
- <code title="put /agents/{agent_id}/datasets/tune/{dataset_name}">client.agents.datasets.tune.<a href="./src/resources/agents/datasets/tune.ts">update</a>(agentId, datasetName, { ...params }) -> CreateDatasetResponse</code>
113+
- <code title="get /agents/{agent_id}/datasets/tune">client.agents.datasets.tune.<a href="./src/resources/agents/datasets/tune.ts">list</a>(agentId, { ...params }) -> ListDatasetsResponse</code>
114+
- <code title="delete /agents/{agent_id}/datasets/tune/{dataset_name}">client.agents.datasets.tune.<a href="./src/resources/agents/datasets/tune.ts">delete</a>(agentId, datasetName) -> unknown</code>
115+
- <code title="get /agents/{agent_id}/datasets/tune/{dataset_name}/metadata">client.agents.datasets.tune.<a href="./src/resources/agents/datasets/tune.ts">metadata</a>(agentId, datasetName, { ...params }) -> DatasetMetadata</code>
116+
101117
### Evaluate
102118

103119
Types:
@@ -147,6 +163,23 @@ Methods:
147163

148164
- <code title="get /agents/{agent_id}/tune/models">client.agents.tune.models.<a href="./src/resources/agents/tune/models.ts">list</a>(agentId) -> ListTuneModelsResponse</code>
149165

166+
# Users
167+
168+
Types:
169+
170+
- <code><a href="./src/resources/users.ts">InviteUsersResponse</a></code>
171+
- <code><a href="./src/resources/users.ts">ListUsersResponse</a></code>
172+
- <code><a href="./src/resources/users.ts">NewUser</a></code>
173+
- <code><a href="./src/resources/users.ts">UserUpdateResponse</a></code>
174+
- <code><a href="./src/resources/users.ts">UserDeactivateResponse</a></code>
175+
176+
Methods:
177+
178+
- <code title="put /users">client.users.<a href="./src/resources/users.ts">update</a>({ ...params }) -> unknown</code>
179+
- <code title="get /users">client.users.<a href="./src/resources/users.ts">list</a>({ ...params }) -> ListUsersResponseUsersUsersPage</code>
180+
- <code title="delete /users">client.users.<a href="./src/resources/users.ts">deactivate</a>({ ...params }) -> unknown</code>
181+
- <code title="post /users">client.users.<a href="./src/resources/users.ts">invite</a>({ ...params }) -> InviteUsersResponse</code>
182+
150183
# LMUnit
151184

152185
Types:

package.json

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "contextual-client",
3-
"version": "0.2.0",
3+
"version": "0.3.0",
44
"description": "The official TypeScript library for the Contextual AI API",
55
"author": "Contextual AI <support@contextual.ai>",
66
"types": "dist/index.d.ts",
@@ -107,17 +107,38 @@
107107
"default": "./dist/index.mjs"
108108
},
109109
"./*.mjs": {
110-
"types": "./dist/*.d.ts",
111-
"default": "./dist/*.mjs"
110+
"types": [
111+
"./dist/*.d.ts",
112+
"./dist/*/index.d.ts"
113+
],
114+
"default": [
115+
"./dist/*.mjs",
116+
"./dist/*/index.mjs"
117+
]
112118
},
113119
"./*.js": {
114-
"types": "./dist/*.d.ts",
115-
"default": "./dist/*.js"
120+
"types": [
121+
"./dist/*.d.ts",
122+
"./dist/*/index.d.ts"
123+
],
124+
"default": [
125+
"./dist/*.js",
126+
"./dist/*/index.js"
127+
]
116128
},
117129
"./*": {
118-
"types": "./dist/*.d.ts",
119-
"require": "./dist/*.js",
120-
"default": "./dist/*.mjs"
130+
"types": [
131+
"./dist/*.d.ts",
132+
"./dist/*/index.d.ts"
133+
],
134+
"require": [
135+
"./dist/*.js",
136+
"./dist/*/index.js"
137+
],
138+
"default": [
139+
"./dist/*.mjs",
140+
"./dist/*/index.mjs"
141+
]
121142
}
122143
}
123144
}

src/index.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,27 @@ import {
1212
DocumentsPageResponse,
1313
type PageParams,
1414
PageResponse,
15+
type UsersPageParams,
16+
UsersPageResponse,
1517
} from './pagination';
1618
import * as Uploads from './uploads';
1719
import * as API from './resources/index';
1820
import { Generate, GenerateCreateParams, GenerateCreateResponse } from './resources/generate';
1921
import { LMUnit, LMUnitCreateParams, LMUnitCreateResponse } from './resources/lmunit';
2022
import { Rerank, RerankCreateParams, RerankCreateResponse } from './resources/rerank';
23+
import {
24+
InviteUsersResponse,
25+
ListUsersResponse,
26+
ListUsersResponseUsersUsersPage,
27+
NewUser,
28+
UserDeactivateParams,
29+
UserDeactivateResponse,
30+
UserInviteParams,
31+
UserListParams,
32+
UserUpdateParams,
33+
UserUpdateResponse,
34+
Users,
35+
} from './resources/users';
2136
import {
2237
Agent as AgentsAPIAgent,
2338
AgentCreateParams,
@@ -158,6 +173,7 @@ export class ContextualAI extends Core.APIClient {
158173

159174
datastores: API.Datastores = new API.Datastores(this);
160175
agents: API.Agents = new API.Agents(this);
176+
users: API.Users = new API.Users(this);
161177
lmUnit: API.LMUnit = new API.LMUnit(this);
162178
rerank: API.Rerank = new API.Rerank(this);
163179
generate: API.Generate = new API.Generate(this);
@@ -206,6 +222,8 @@ ContextualAI.Datastores = Datastores;
206222
ContextualAI.DatastoresDatastoresPage = DatastoresDatastoresPage;
207223
ContextualAI.Agents = Agents;
208224
ContextualAI.AgentsPage = AgentsPage;
225+
ContextualAI.Users = Users;
226+
ContextualAI.ListUsersResponseUsersUsersPage = ListUsersResponseUsersUsersPage;
209227
ContextualAI.LMUnit = LMUnit;
210228
ContextualAI.Rerank = Rerank;
211229
ContextualAI.Generate = Generate;
@@ -224,6 +242,9 @@ export declare namespace ContextualAI {
224242
type DocumentsPageResponse as DocumentsPageResponse,
225243
};
226244

245+
export import UsersPage = Pagination.UsersPage;
246+
export { type UsersPageParams as UsersPageParams, type UsersPageResponse as UsersPageResponse };
247+
227248
export import Page = Pagination.Page;
228249
export { type PageParams as PageParams, type PageResponse as PageResponse };
229250

@@ -253,6 +274,20 @@ export declare namespace ContextualAI {
253274
type AgentListParams as AgentListParams,
254275
};
255276

277+
export {
278+
Users as Users,
279+
type InviteUsersResponse as InviteUsersResponse,
280+
type ListUsersResponse as ListUsersResponse,
281+
type NewUser as NewUser,
282+
type UserUpdateResponse as UserUpdateResponse,
283+
type UserDeactivateResponse as UserDeactivateResponse,
284+
ListUsersResponseUsersUsersPage as ListUsersResponseUsersUsersPage,
285+
type UserUpdateParams as UserUpdateParams,
286+
type UserListParams as UserListParams,
287+
type UserDeactivateParams as UserDeactivateParams,
288+
type UserInviteParams as UserInviteParams,
289+
};
290+
256291
export {
257292
LMUnit as LMUnit,
258293
type LMUnitCreateResponse as LMUnitCreateResponse,

0 commit comments

Comments
 (0)