Skip to content

Commit cc50fc3

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

File tree

21 files changed

+391
-52
lines changed

21 files changed

+391
-52
lines changed

.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.1.0"
2+
".": "0.2.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: 33
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/contextual-ai%2Fsunrise-4ed32c3243ce7a772e55bb1ba204736fc3fb1d712d8ca0eb91bac0c7ac626938.yml
1+
configured_endpoints: 35
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/contextual-ai%2Fsunrise-d79ccb778953ad5c2ae4b99115429c8b3f68b3b23d9b6d90b1b40393f11a4383.yml

CHANGELOG.md

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

3+
## 0.2.0 (2025-02-08)
4+
5+
Full Changelog: [v0.1.0...v0.2.0](https://github.com/ContextualAI/contextual-client-node/compare/v0.1.0...v0.2.0)
6+
7+
### Features
8+
9+
* **api:** update via SDK Studio ([#15](https://github.com/ContextualAI/contextual-client-node/issues/15)) ([6aaf723](https://github.com/ContextualAI/contextual-client-node/commit/6aaf723c236fa90c113f89e3c455c071fdf311e4))
10+
* **api:** update via SDK Studio ([#16](https://github.com/ContextualAI/contextual-client-node/issues/16)) ([0cfb143](https://github.com/ContextualAI/contextual-client-node/commit/0cfb143e6a706365c1ea6d21404e1d3dfdca87eb))
11+
* **api:** update via SDK Studio ([#18](https://github.com/ContextualAI/contextual-client-node/issues/18)) ([54f5551](https://github.com/ContextualAI/contextual-client-node/commit/54f55516820f04498db0f45997539d9fa142f589))
12+
* **client:** send `X-Stainless-Timeout` header ([#17](https://github.com/ContextualAI/contextual-client-node/issues/17)) ([6cb5614](https://github.com/ContextualAI/contextual-client-node/commit/6cb56149556ce93fae414e40e23114229929f8ed))
13+
14+
15+
### Chores
16+
17+
* **internal:** codegen related update ([#11](https://github.com/ContextualAI/contextual-client-node/issues/11)) ([30253b7](https://github.com/ContextualAI/contextual-client-node/commit/30253b751d480a41574804fa080a02449c37936a))
18+
* **internal:** codegen related update ([#13](https://github.com/ContextualAI/contextual-client-node/issues/13)) ([69a063a](https://github.com/ContextualAI/contextual-client-node/commit/69a063afb19f3739fc877ddbc90bf3c8da826d48))
19+
* **internal:** codegen related update ([#14](https://github.com/ContextualAI/contextual-client-node/issues/14)) ([ed84da5](https://github.com/ContextualAI/contextual-client-node/commit/ed84da5bd3a9085f5d9bed012112d8ef386a9f64))
20+
321
## 0.1.0 (2025-01-15)
422

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

api.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,23 @@ Types:
156156
Methods:
157157

158158
- <code title="post /lmunit">client.lmUnit.<a href="./src/resources/lmunit.ts">create</a>({ ...params }) -> LMUnitCreateResponse</code>
159+
160+
# Rerank
161+
162+
Types:
163+
164+
- <code><a href="./src/resources/rerank.ts">RerankCreateResponse</a></code>
165+
166+
Methods:
167+
168+
- <code title="post /rerank">client.rerank.<a href="./src/resources/rerank.ts">create</a>({ ...params }) -> RerankCreateResponse</code>
169+
170+
# Generate
171+
172+
Types:
173+
174+
- <code><a href="./src/resources/generate.ts">GenerateCreateResponse</a></code>
175+
176+
Methods:
177+
178+
- <code title="post /generate">client.generate.<a href="./src/resources/generate.ts">create</a>({ ...params }) -> GenerateCreateResponse</code>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "contextual-client",
3-
"version": "0.1.0",
3+
"version": "0.2.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",

src/core.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ export abstract class APIClient {
280280
options: FinalRequestOptions<Req>,
281281
{ retryCount = 0 }: { retryCount?: number } = {},
282282
): { req: RequestInit; url: string; timeout: number } {
283+
options = { ...options };
283284
const { method, path, query, headers: headers = {} } = options;
284285

285286
const body =
@@ -292,9 +293,9 @@ export abstract class APIClient {
292293

293294
const url = this.buildURL(path!, query);
294295
if ('timeout' in options) validatePositiveInteger('timeout', options.timeout);
295-
const timeout = options.timeout ?? this.timeout;
296+
options.timeout = options.timeout ?? this.timeout;
296297
const httpAgent = options.httpAgent ?? this.httpAgent ?? getDefaultAgent(url);
297-
const minAgentTimeout = timeout + 1000;
298+
const minAgentTimeout = options.timeout + 1000;
298299
if (
299300
typeof (httpAgent as any)?.options?.timeout === 'number' &&
300301
minAgentTimeout > ((httpAgent as any).options.timeout ?? 0)
@@ -323,7 +324,7 @@ export abstract class APIClient {
323324
signal: options.signal ?? null,
324325
};
325326

326-
return { req, url, timeout };
327+
return { req, url, timeout: options.timeout };
327328
}
328329

329330
private buildHeaders({
@@ -351,15 +352,22 @@ export abstract class APIClient {
351352
delete reqHeaders['content-type'];
352353
}
353354

354-
// Don't set the retry count header if it was already set or removed through default headers or by the
355-
// caller. We check `defaultHeaders` and `headers`, which can contain nulls, instead of `reqHeaders` to
356-
// account for the removal case.
355+
// Don't set theses headers if they were already set or removed through default headers or by the caller.
356+
// We check `defaultHeaders` and `headers`, which can contain nulls, instead of `reqHeaders` to account
357+
// for the removal case.
357358
if (
358359
getHeader(defaultHeaders, 'x-stainless-retry-count') === undefined &&
359360
getHeader(headers, 'x-stainless-retry-count') === undefined
360361
) {
361362
reqHeaders['x-stainless-retry-count'] = String(retryCount);
362363
}
364+
if (
365+
getHeader(defaultHeaders, 'x-stainless-timeout') === undefined &&
366+
getHeader(headers, 'x-stainless-timeout') === undefined &&
367+
options.timeout
368+
) {
369+
reqHeaders['x-stainless-timeout'] = String(options.timeout);
370+
}
363371

364372
this.validateHeaders(reqHeaders, headers);
365373

src/index.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ import {
1515
} from './pagination';
1616
import * as Uploads from './uploads';
1717
import * as API from './resources/index';
18+
import { Generate, GenerateCreateParams, GenerateCreateResponse } from './resources/generate';
1819
import { LMUnit, LMUnitCreateParams, LMUnitCreateResponse } from './resources/lmunit';
20+
import { Rerank, RerankCreateParams, RerankCreateResponse } from './resources/rerank';
1921
import {
2022
Agent as AgentsAPIAgent,
2123
AgentCreateParams,
@@ -61,15 +63,15 @@ export interface ClientOptions {
6163
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
6264
* much longer than this timeout before the promise succeeds or fails.
6365
*/
64-
timeout?: number;
66+
timeout?: number | undefined;
6567

6668
/**
6769
* An HTTP agent used to manage HTTP(S) connections.
6870
*
6971
* If not provided, an agent will be constructed by default in the Node.js environment,
7072
* otherwise no agent is used.
7173
*/
72-
httpAgent?: Agent;
74+
httpAgent?: Agent | undefined;
7375

7476
/**
7577
* Specify a custom `fetch` function implementation.
@@ -85,23 +87,23 @@ export interface ClientOptions {
8587
*
8688
* @default 2
8789
*/
88-
maxRetries?: number;
90+
maxRetries?: number | undefined;
8991

9092
/**
9193
* Default headers to include with every request to the API.
9294
*
9395
* These can be removed in individual requests by explicitly setting the
9496
* header to `undefined` or `null` in request options.
9597
*/
96-
defaultHeaders?: Core.Headers;
98+
defaultHeaders?: Core.Headers | undefined;
9799

98100
/**
99101
* Default query parameters to include with every request to the API.
100102
*
101103
* These can be removed in individual requests by explicitly setting the
102104
* param to `undefined` in request options.
103105
*/
104-
defaultQuery?: Core.DefaultQuery;
106+
defaultQuery?: Core.DefaultQuery | undefined;
105107
}
106108

107109
/**
@@ -157,6 +159,8 @@ export class ContextualAI extends Core.APIClient {
157159
datastores: API.Datastores = new API.Datastores(this);
158160
agents: API.Agents = new API.Agents(this);
159161
lmUnit: API.LMUnit = new API.LMUnit(this);
162+
rerank: API.Rerank = new API.Rerank(this);
163+
generate: API.Generate = new API.Generate(this);
160164

161165
protected override defaultQuery(): Core.DefaultQuery | undefined {
162166
return this._options.defaultQuery;
@@ -203,6 +207,8 @@ ContextualAI.DatastoresDatastoresPage = DatastoresDatastoresPage;
203207
ContextualAI.Agents = Agents;
204208
ContextualAI.AgentsPage = AgentsPage;
205209
ContextualAI.LMUnit = LMUnit;
210+
ContextualAI.Rerank = Rerank;
211+
ContextualAI.Generate = Generate;
206212
export declare namespace ContextualAI {
207213
export type RequestOptions = Core.RequestOptions;
208214

@@ -252,6 +258,18 @@ export declare namespace ContextualAI {
252258
type LMUnitCreateResponse as LMUnitCreateResponse,
253259
type LMUnitCreateParams as LMUnitCreateParams,
254260
};
261+
262+
export {
263+
Rerank as Rerank,
264+
type RerankCreateResponse as RerankCreateResponse,
265+
type RerankCreateParams as RerankCreateParams,
266+
};
267+
268+
export {
269+
Generate as Generate,
270+
type GenerateCreateResponse as GenerateCreateResponse,
271+
type GenerateCreateParams as GenerateCreateParams,
272+
};
255273
}
256274

257275
export { toFile, fileFromPath } from './uploads';

src/resources/agents/agents.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export interface AgentMetadata {
138138
* These queries will show up as suggestions in the Contextual UI when users load
139139
* the agent. We recommend including common queries that users will ask, as well as
140140
* complex queries so users understand the types of complex queries the system can
141-
* handle.
141+
* handle. The max length of all the suggested queries is 1000.
142142
*/
143143
suggested_queries?: Array<string>;
144144

@@ -209,7 +209,7 @@ export interface AgentCreateParams {
209209
* These queries will show up as suggestions in the Contextual UI when users load
210210
* the agent. We recommend including common queries that users will ask, as well as
211211
* complex queries so users understand the types of complex queries the system can
212-
* handle.
212+
* handle. The max length of all the suggested queries is 1000.
213213
*/
214214
suggested_queries?: Array<string>;
215215

@@ -237,7 +237,7 @@ export interface AgentUpdateParams {
237237
* These queries will show up as suggestions in the Contextual UI when users load
238238
* the agent. We recommend including common queries that users will ask, as well as
239239
* complex queries so users understand the types of complex queries the system can
240-
* handle.
240+
* handle. The max length of all the suggested queries is 1000.
241241
*/
242242
suggested_queries?: Array<string>;
243243

src/resources/agents/datasets/evaluate.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ import { type Response } from '../../../_shims/index';
99
export class Evaluate extends APIResource {
1010
/**
1111
* Create a new evaluation `Dataset` for the specified `Agent` using the provided
12-
* JSONL file. A `Dataset` is a versioned collection of samples conforming to a
13-
* particular schema, and can be used to store `Evaluation` test-sets and retrieve
14-
* `Evaluation` results.
12+
* JSONL or CSV file. A `Dataset` is a versioned collection of samples conforming
13+
* to a particular schema, and can be used to store `Evaluation` test-sets and
14+
* retrieve `Evaluation` results.
1515
*
1616
* Each `Dataset` is versioned and validated against its schema during creation and
1717
* subsequent updates. The provided `Dataset` file must conform to the schema
1818
* defined for the `dataset_type`.
1919
*
20-
* File schema for `dataset_type` `evaluation_set` is a JSONL or CSV file where
21-
* each line is one JSON object with the following required keys:
20+
* File schema for `dataset_type` `evaluation_set` is a CSV file or a JSONL file
21+
* where each line is one JSON object. The following keys are required:
2222
*
23-
* - `prompt` (required, `string`): Prompt or question
23+
* - `prompt` (`string`): Prompt or question
2424
*
25-
* - `reference` (required, `string`): Required reference or ground truth response
25+
* - `reference` (`string`): Reference or ground truth response
2626
*/
2727
create(
2828
agentId: string,
@@ -80,12 +80,12 @@ export class Evaluate extends APIResource {
8080
* Create a new version of the dataset by appending content to the `Dataset` and
8181
* validating against its schema.
8282
*
83-
* File schema for `dataset_type` `evaluation_set` is a JSONL file where each line
84-
* is one JSON object with the following required keys:
83+
* File schema for `dataset_type` `evaluation_set` is a CSV file or a JSONL file
84+
* where each line is one JSON object. The following keys are required:
8585
*
8686
* - `prompt` (`string`): Prompt or question
8787
*
88-
* - `reference` (`string`): Required reference or ground truth response
88+
* - `reference` (`string`): Reference or ground truth response
8989
*/
9090
update(
9191
agentId: string,
@@ -184,7 +184,7 @@ export interface EvaluateCreateParams {
184184
dataset_type: 'evaluation_set';
185185

186186
/**
187-
* JSONL file containing the evaluation dataset
187+
* JSONL or CSV file containing the evaluation dataset
188188
*/
189189
file: Core.Uploadable;
190190
}
@@ -210,7 +210,7 @@ export interface EvaluateUpdateParams {
210210
dataset_type: 'evaluation_set';
211211

212212
/**
213-
* JSONL file containing the entries to append to the evaluation dataset
213+
* JSONL or CSV file containing the entries to append to the evaluation dataset
214214
*/
215215
file: Core.Uploadable;
216216
}

src/resources/agents/evaluate/evaluate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export interface EvaluateCreateParams {
7272
/**
7373
* ID of the model to evaluate. Uses the default model if not specified.
7474
*/
75-
llm_model_id?: string | null;
75+
llm_model_id?: string;
7676
}
7777

7878
Evaluate.Jobs = Jobs;

0 commit comments

Comments
 (0)