22
33import { APIResource } from '../../../core/resource' ;
44import * as MemoryAPI from './memory' ;
5- import { Memory , MemoryAddParams , MemoryDeleteParams , MemoryUpdateParams } from './memory' ;
5+ import {
6+ Memory ,
7+ MemoryAddParams ,
8+ MemoryAddResponse ,
9+ MemoryDeleteParams ,
10+ MemoryUpdateParams ,
11+ MemoryUpdateResponse ,
12+ } from './memory' ;
613import * as TracesAPI from './traces' ;
7- import { TraceDeleteResponse , TraceListResponse , Traces } from './traces' ;
14+ import { TraceDeleteResponse , TraceListParams , TraceListResponse , Traces } from './traces' ;
815import * as ViewAPI from './view' ;
9- import { View , ViewDocsResponse , ViewRetrieveParams , ViewRetrieveResponse } from './view' ;
16+ import { View , ViewDocsParams , ViewDocsResponse , ViewRetrieveParams , ViewRetrieveResponse } from './view' ;
1017import { APIPromise } from '../../../core/api-promise' ;
1118import { RequestOptions } from '../../../internal/request-options' ;
1219
@@ -16,13 +23,15 @@ export class Context extends APIResource {
1623 memory : MemoryAPI . Memory = new MemoryAPI . Memory ( this . _client ) ;
1724
1825 /**
19- * Deletes context data based on provided parameters
26+ * This endpoint deletes context data based on the provided parameters. It returns
27+ * a success or error response depending on the result from the context processor.
2028 *
2129 * @example
2230 * ```ts
2331 * const context = await client.v1.context.delete({
24- * by_doc: true ,
32+ * organization_id: 'org_01HXYZABC' ,
2533 * source: 'support-inbox',
34+ * by_doc: true,
2635 * });
2736 * ```
2837 */
@@ -47,19 +56,19 @@ export class Context extends APIResource {
4756 * ticketId: 'TCK-1234',
4857 * },
4958 * ],
59+ * scope: 'internal',
60+ * source: 'support-inbox',
5061 * metadata: {
5162 * fileName: 'support_thread_TCK-1234.txt',
5263 * fileType: 'text/plain',
5364 * groupName: ['support', 'pricing'],
5465 * lastModified: '2025-01-10T12:34:56.000Z',
5566 * fileSize: 2048,
5667 * },
57- * scope: 'internal',
58- * source: 'support-inbox',
5968 * });
6069 * ```
6170 */
62- add ( body : ContextAddParams , options ?: RequestOptions ) : APIPromise < unknown > {
71+ add ( body : ContextAddParams , options ?: RequestOptions ) : APIPromise < ContextAddResponse > {
6372 return this . _client . post ( '/api/v1/context/add' , { body, ...options } ) ;
6473 }
6574
@@ -86,7 +95,13 @@ export class Context extends APIResource {
8695
8796export type ContextDeleteResponse = unknown ;
8897
89- export type ContextAddResponse = unknown ;
98+ export interface ContextAddResponse {
99+ context_id : string ;
100+
101+ success : boolean ;
102+
103+ processed_documents ?: number ;
104+ }
90105
91106export interface ContextSearchResponse {
92107 contexts ?: Array < ContextSearchResponse . Context > ;
@@ -111,24 +126,24 @@ export namespace ContextSearchResponse {
111126
112127export interface ContextDeleteParams {
113128 /**
114- * Flag to delete by document
129+ * Organization ID
115130 */
116- by_doc ?: boolean | null ;
131+ organization_id : string ;
117132
118133 /**
119- * Flag to delete by ID
134+ * Source identifier for the context
120135 */
121- by_id ?: boolean | null ;
136+ source : string ;
122137
123138 /**
124- * Optional organization ID
139+ * Flag to delete by document
125140 */
126- organization_id ?: string | null ;
141+ by_doc ?: boolean | null ;
127142
128143 /**
129- * Source identifier for the context
144+ * Flag to delete by ID
130145 */
131- source ?: string ;
146+ by_id ?: boolean | null ;
132147
133148 /**
134149 * @deprecated Optional user ID
@@ -140,27 +155,27 @@ export interface ContextAddParams {
140155 /**
141156 * Type of context being added
142157 */
143- context_type ? : 'resource' | 'conversation' | 'instruction' ;
158+ context_type : 'resource' | 'conversation' | 'instruction' ;
144159
145160 /**
146161 * Array of documents with content and additional metadata
147162 */
148- documents ? : Array < ContextAddParams . Document > ;
163+ documents : Array < ContextAddParams . Document > ;
149164
150165 /**
151- * Additional metadata for the context
166+ * Scope of the context
152167 */
153- metadata ?: ContextAddParams . Metadata ;
168+ scope : 'internal' | 'external' ;
154169
155170 /**
156- * Scope of the context
171+ * The source of the context data
157172 */
158- scope ?: 'internal' | 'external' ;
173+ source : string ;
159174
160175 /**
161- * The source of the context data
176+ * Additional metadata for the context
162177 */
163- source ?: string ;
178+ metadata ?: ContextAddParams . Metadata ;
164179}
165180
166181export namespace ContextAddParams {
@@ -273,17 +288,21 @@ export declare namespace Context {
273288 Traces as Traces ,
274289 type TraceListResponse as TraceListResponse ,
275290 type TraceDeleteResponse as TraceDeleteResponse ,
291+ type TraceListParams as TraceListParams ,
276292 } ;
277293
278294 export {
279295 View as View ,
280296 type ViewRetrieveResponse as ViewRetrieveResponse ,
281297 type ViewDocsResponse as ViewDocsResponse ,
282298 type ViewRetrieveParams as ViewRetrieveParams ,
299+ type ViewDocsParams as ViewDocsParams ,
283300 } ;
284301
285302 export {
286303 Memory as Memory ,
304+ type MemoryUpdateResponse as MemoryUpdateResponse ,
305+ type MemoryAddResponse as MemoryAddResponse ,
287306 type MemoryUpdateParams as MemoryUpdateParams ,
288307 type MemoryDeleteParams as MemoryDeleteParams ,
289308 type MemoryAddParams as MemoryAddParams ,
0 commit comments