Skip to content

Commit e93fa24

Browse files
release: 0.5.0 (#34)
Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
1 parent aee7e39 commit e93fa24

19 files changed

+304
-33
lines changed

.release-please-manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.4.0"
2+
".": "0.5.0"
33
}

.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 46
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/contextual-ai%2Fsunrise-f43814080090927ee22816c5c7f517d8a7eb7f346329ada67915608e32124321.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/contextual-ai%2Fsunrise-194878b194cd507d7c5418ff38cc0fc53441ef618f991990d334b4b75775cd8f.yml

CHANGELOG.md

+16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# Changelog
22

3+
## 0.5.0 (2025-03-11)
4+
5+
Full Changelog: [v0.4.0...v0.5.0](https://github.com/ContextualAI/contextual-client-node/compare/v0.4.0...v0.5.0)
6+
7+
### Features
8+
9+
* add SKIP_BREW env var to ./scripts/bootstrap ([#35](https://github.com/ContextualAI/contextual-client-node/issues/35)) ([bb0faca](https://github.com/ContextualAI/contextual-client-node/commit/bb0faca1da1cc716197e02d3a5e9b6614f2204b0))
10+
* **api:** update via SDK Studio ([#37](https://github.com/ContextualAI/contextual-client-node/issues/37)) ([1cc7907](https://github.com/ContextualAI/contextual-client-node/commit/1cc7907b119cb40734c3da6040feb6b999e70191))
11+
* **api:** update via SDK Studio ([#38](https://github.com/ContextualAI/contextual-client-node/issues/38)) ([b23a2e2](https://github.com/ContextualAI/contextual-client-node/commit/b23a2e2fa6bfcf37b61754eeb134d165c61e8d9d))
12+
* **client:** accept RFC6838 JSON content types ([#36](https://github.com/ContextualAI/contextual-client-node/issues/36)) ([5178d1d](https://github.com/ContextualAI/contextual-client-node/commit/5178d1ddbc4c67f035113faafcc292c0dc05f014))
13+
14+
15+
### Chores
16+
17+
* **internal:** codegen related update ([#33](https://github.com/ContextualAI/contextual-client-node/issues/33)) ([7608b02](https://github.com/ContextualAI/contextual-client-node/commit/7608b02fa3f51ef345da11be72b90fba5018ed68))
18+
319
## 0.4.0 (2025-03-03)
420

521
Full Changelog: [v0.3.0...v0.4.0](https://github.com/ContextualAI/contextual-client-node/compare/v0.3.0...v0.4.0)

api.md

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Methods:
1919

2020
Types:
2121

22+
- <code><a href="./src/resources/datastores/documents.ts">CompositeMetadataFilter</a></code>
2223
- <code><a href="./src/resources/datastores/documents.ts">DocumentMetadata</a></code>
2324
- <code><a href="./src/resources/datastores/documents.ts">IngestionResponse</a></code>
2425
- <code><a href="./src/resources/datastores/documents.ts">ListDocumentsResponse</a></code>

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "contextual-client",
3-
"version": "0.4.0",
3+
"version": "0.5.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",

scripts/bootstrap

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -e
44

55
cd "$(dirname "$0")/.."
66

7-
if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then
7+
if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ]; then
88
brew bundle check >/dev/null 2>&1 || {
99
echo "==> Installing Homebrew dependencies…"
1010
brew bundle

src/core.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ async function defaultParseResponse<T>(props: APIResponseProps): Promise<T> {
4848
}
4949

5050
const contentType = response.headers.get('content-type');
51-
const isJSON =
52-
contentType?.includes('application/json') || contentType?.includes('application/vnd.api+json');
51+
const mediaType = contentType?.split(';')[0]?.trim();
52+
const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
5353
if (isJSON) {
5454
const json = await response.json();
5555

src/pagination.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export class DatastoresPage<Item> extends AbstractPage<Item> implements Datastor
5353

5454
return {
5555
params: {
56-
cursor: cursor,
56+
cursor,
5757
},
5858
};
5959
}
@@ -110,7 +110,7 @@ export class DocumentsPage<Item> extends AbstractPage<Item> implements Documents
110110

111111
return {
112112
params: {
113-
cursor: cursor,
113+
cursor,
114114
},
115115
};
116116
}
@@ -167,7 +167,7 @@ export class UsersPage<Item> extends AbstractPage<Item> implements UsersPageResp
167167

168168
return {
169169
params: {
170-
cursor: cursor,
170+
cursor,
171171
},
172172
};
173173
}
@@ -219,7 +219,7 @@ export class Page<Item> extends AbstractPage<Item> implements PageResponse<Item>
219219

220220
return {
221221
params: {
222-
cursor: cursor,
222+
cursor,
223223
},
224224
};
225225
}

src/resources/agents/agents.ts

+38
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ export class Agents extends APIResource {
4141
* If no `datastore_id` is provided in the configuration, this API automatically
4242
* creates an empty `Datastore` and configures the `Agent` to use the newly created
4343
* `Datastore`.
44+
*
45+
* > Note that self-serve users are currently required to create agents through our
46+
* > UI. Otherwise, they will receive the following message: "This endpoint is
47+
* > disabled as you need to go through checkout. Please use the UI to make this
48+
* > request."
4449
*/
4550
create(body: AgentCreateParams, options?: Core.RequestOptions): Core.APIPromise<CreateAgentOutput> {
4651
return this._client.post('/agents', { body, ...options });
@@ -132,6 +137,12 @@ export interface AgentMetadata {
132137
*/
133138
description?: string;
134139

140+
/**
141+
* The prompt to an LLM which determines whether retrieved chunks are relevant to a
142+
* given query and filters out irrelevant chunks. This prompt is applied per chunk.
143+
*/
144+
filter_prompt?: string;
145+
135146
/**
136147
* The model ID to use for generation. Tuned models can only be used for the agents
137148
* on which they were tuned. If no model is specified, the default model is used.
@@ -195,6 +206,11 @@ export namespace AgentMetadata {
195206
* Parameters that affect response generation
196207
*/
197208
export interface GenerateResponseConfig {
209+
/**
210+
* This parameter controls generation of groundedness scores.
211+
*/
212+
calculate_groundedness?: boolean;
213+
198214
/**
199215
* This parameter adjusts how the model treats repeated tokens during text
200216
* generation.
@@ -327,6 +343,12 @@ export interface AgentCreateParams {
327343
*/
328344
description?: string;
329345

346+
/**
347+
* The prompt to an LLM which determines whether retrieved chunks are relevant to a
348+
* given query and filters out irrelevant chunks.
349+
*/
350+
filter_prompt?: string;
351+
330352
/**
331353
* These queries will show up as suggestions in the Contextual UI when users load
332354
* the agent. We recommend including common queries that users will ask, as well as
@@ -383,6 +405,11 @@ export namespace AgentCreateParams {
383405
* Parameters that affect response generation
384406
*/
385407
export interface GenerateResponseConfig {
408+
/**
409+
* This parameter controls generation of groundedness scores.
410+
*/
411+
calculate_groundedness?: boolean;
412+
386413
/**
387414
* This parameter adjusts how the model treats repeated tokens during text
388415
* generation.
@@ -466,6 +493,12 @@ export interface AgentUpdateParams {
466493
*/
467494
datastore_ids?: Array<string>;
468495

496+
/**
497+
* The prompt to an LLM which determines whether retrieved chunks are relevant to a
498+
* given query and filters out irrelevant chunks.
499+
*/
500+
filter_prompt?: string;
501+
469502
/**
470503
* The model ID to use for generation. Tuned models can only be used for the agents
471504
* on which they were tuned. If no model is specified, the default model is used.
@@ -529,6 +562,11 @@ export namespace AgentUpdateParams {
529562
* Parameters that affect response generation
530563
*/
531564
export interface GenerateResponseConfig {
565+
/**
566+
* This parameter controls generation of groundedness scores.
567+
*/
568+
calculate_groundedness?: boolean;
569+
532570
/**
533571
* This parameter adjusts how the model treats repeated tokens during text
534572
* generation.

src/resources/agents/query.ts

+112-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { APIResource } from '../../resource';
44
import { isRequestOptions } from '../../core';
55
import * as Core from '../../core';
6+
import * as DocumentsAPI from '../datastores/documents';
67

78
export class Query extends APIResource {
89
/**
@@ -96,6 +97,11 @@ export interface QueryResponse {
9697
*/
9798
attributions?: Array<QueryResponse.Attribution>;
9899

100+
/**
101+
* Groundedness scores for the response
102+
*/
103+
groundedness_scores?: Array<QueryResponse.GroundednessScore>;
104+
99105
/**
100106
* Response to the query request
101107
*/
@@ -130,7 +136,7 @@ export namespace QueryResponse {
130136
/**
131137
* Format of the content, such as `pdf` or `html`
132138
*/
133-
format: 'pdf' | 'html' | 'htm';
139+
format: 'pdf' | 'html' | 'htm' | 'mhtml' | 'doc' | 'docx' | 'ppt' | 'pptx';
134140

135141
/**
136142
* Source type of the content. Will be `file` for any docs ingested through
@@ -180,6 +186,26 @@ export namespace QueryResponse {
180186
start_idx: number;
181187
}
182188

189+
/**
190+
* Groundedness scores in a generated message`.
191+
*/
192+
export interface GroundednessScore {
193+
/**
194+
* End index of the span in the generated message
195+
*/
196+
end_idx: number;
197+
198+
/**
199+
* Groundedness score for the span
200+
*/
201+
score: number;
202+
203+
/**
204+
* Start index of the span in the generated message
205+
*/
206+
start_idx: number;
207+
}
208+
183209
/**
184210
* Response to the query request
185211
*/
@@ -308,6 +334,44 @@ export interface QueryCreateParams {
308334
*/
309335
conversation_id?: string;
310336

337+
/**
338+
* Body param: Defines an Optional custom metadata filter, which can be a list of
339+
* filters or nested filters. The expected input is a nested JSON object that can
340+
* represent a single filter or a composite (logical) combination of filters.
341+
*
342+
* Unnested Example:
343+
*
344+
* ```json
345+
* {
346+
* "operator": "AND",
347+
* "filters": [{ "field": "status", "operator": "equals", "value": "active" }]
348+
* }
349+
* ```
350+
*
351+
* Nested example:
352+
*
353+
* ```json
354+
* {
355+
* "operator": "AND",
356+
* "filters": [
357+
* { "field": "status", "operator": "equals", "value": "active" },
358+
* {
359+
* "operator": "OR",
360+
* "filters": [
361+
* {
362+
* "field": "category",
363+
* "operator": "containsany",
364+
* "value": ["policy", "HR"]
365+
* },
366+
* { "field": "tags", "operator": "exists" }
367+
* ]
368+
* }
369+
* ]
370+
* }
371+
* ```
372+
*/
373+
documents_filters?: QueryCreateParams.BaseMetadataFilter | DocumentsAPI.CompositeMetadataFilter;
374+
311375
/**
312376
* Body param: Model ID of the specific fine-tuned or aligned LLM model to use.
313377
* Defaults to base model if not specified.
@@ -335,6 +399,43 @@ export namespace QueryCreateParams {
335399
*/
336400
role: 'user' | 'system' | 'assistant' | 'knowledge';
337401
}
402+
403+
/**
404+
* Defines a custom metadata filter. The expected input is a dict which can have
405+
* different operators, fields and values. For example:
406+
*
407+
* {"field": "title", "operator": "startswith", "value": "hr-"}
408+
*
409+
* For document_id and date_created the query is built using direct query without
410+
* nesting.
411+
*/
412+
export interface BaseMetadataFilter {
413+
/**
414+
* Field name to search for in the metadata
415+
*/
416+
field: string;
417+
418+
/**
419+
* Operator to be used for the filter.
420+
*/
421+
operator:
422+
| 'equals'
423+
| 'containsany'
424+
| 'exists'
425+
| 'startswith'
426+
| 'gt'
427+
| 'gte'
428+
| 'lt'
429+
| 'lte'
430+
| 'notequals'
431+
| 'between';
432+
433+
/**
434+
* The value to be searched for in the field. In case of exists operator, it is not
435+
* needed.
436+
*/
437+
value?: string | number | boolean | Array<string | number | boolean> | null;
438+
}
338439
}
339440

340441
export interface QueryFeedbackParams {
@@ -362,6 +463,11 @@ export interface QueryFeedbackParams {
362463
}
363464

364465
export interface QueryMetricsParams {
466+
/**
467+
* Filter messages by conversation ids.
468+
*/
469+
conversation_ids?: Array<string>;
470+
365471
/**
366472
* Filters messages that are created after the specified timestamp.
367473
*/
@@ -381,6 +487,11 @@ export interface QueryMetricsParams {
381487
* Offset for pagination.
382488
*/
383489
offset?: number;
490+
491+
/**
492+
* Filter messages by users.
493+
*/
494+
user_emails?: Array<string>;
384495
}
385496

386497
export interface QueryRetrievalInfoParams {

src/resources/agents/tune/jobs.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export interface TuneJobMetadata {
6666
/**
6767
* Metadata about the model evaluation, including status and results if completed.
6868
*/
69-
evaluation_metadata?: unknown | null;
69+
evaluation_metadata?: Array<unknown>;
7070

7171
/**
7272
* ID of the tuned model. Omitted if the tuning job failed or is still in progress.

src/resources/datastores/datastores.ts

+7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { isRequestOptions } from '../../core';
55
import * as Core from '../../core';
66
import * as DocumentsAPI from './documents';
77
import {
8+
CompositeMetadataFilter,
89
DocumentDeleteResponse,
910
DocumentIngestParams,
1011
DocumentListParams,
@@ -31,6 +32,11 @@ export class Datastores extends APIResource {
3132
* relevant data. This flexible many-to-many relationship allows `Agents` to draw
3233
* from multiple sources of information. This linkage of `Datastore` to `Agent` is
3334
* done through the `Create Agent` or `Edit Agent` APIs.
35+
*
36+
* > Note that self-serve users are currently required to create datastores through
37+
* > our UI. Otherwise, they will receive the following message: "This endpoint is
38+
* > disabled as you need to go through checkout. Please use the UI to make this
39+
* > request."
3440
*/
3541
create(
3642
body: DatastoreCreateParams,
@@ -180,6 +186,7 @@ export declare namespace Datastores {
180186

181187
export {
182188
Documents as Documents,
189+
type CompositeMetadataFilter as CompositeMetadataFilter,
183190
type DocumentMetadata as DocumentMetadata,
184191
type IngestionResponse as IngestionResponse,
185192
type ListDocumentsResponse as ListDocumentsResponse,

0 commit comments

Comments
 (0)