@@ -57,6 +57,26 @@ export class Memory extends APIResource {
5757 headers : buildHeaders ( [ { Accept : '*/*' } , options ?. headers ] ) ,
5858 } ) ;
5959 }
60+
61+ /**
62+ * This endpoint adds memory (chat history) as context.
63+ *
64+ * @example
65+ * ```ts
66+ * const response = await client.v1.context.memory.add({
67+ * contents: [
68+ * {
69+ * content:
70+ * 'Customer asked about pricing for the Scale plan.',
71+ * },
72+ * ],
73+ * sessionId: 'support-thread-TCK-1234',
74+ * });
75+ * ```
76+ */
77+ add ( body : MemoryAddParams , options ?: RequestOptions ) : APIPromise < MemoryAddResponse > {
78+ return this . _client . post ( '/api/v1/context/memory/add' , { body, ...options } ) ;
79+ }
6080}
6181
6282export interface MemoryUpdateResponse {
@@ -67,6 +87,14 @@ export interface MemoryUpdateResponse {
6787 updated_entries : number ;
6888}
6989
90+ export interface MemoryAddResponse {
91+ context_id : string ;
92+
93+ success : boolean ;
94+
95+ processed_documents ?: number ;
96+ }
97+
7098export interface MemoryUpdateParams {
7199 /**
72100 * Array of updated content objects
@@ -135,10 +163,73 @@ export interface MemoryDeleteParams {
135163 user_id ?: string | null ;
136164}
137165
166+ export interface MemoryAddParams {
167+ /**
168+ * Array of content objects. Each object must contain at least the 'content' field.
169+ * Additional properties are allowed.
170+ */
171+ contents : Array < MemoryAddParams . Content > ;
172+
173+ /**
174+ * The ID of the session
175+ */
176+ sessionId : string ;
177+
178+ /**
179+ * Optional metadata for the memory context. Defaults to ["default"] if not
180+ * provided.
181+ */
182+ metadata ?: MemoryAddParams . Metadata ;
183+ }
184+
185+ export namespace MemoryAddParams {
186+ export interface Content {
187+ /**
188+ * The content of the memory message
189+ */
190+ content : string ;
191+
192+ /**
193+ * Additional metadata for the message (optional)
194+ */
195+ metadata ?: Content . Metadata ;
196+
197+ [ k : string ] : unknown ;
198+ }
199+
200+ export namespace Content {
201+ /**
202+ * Additional metadata for the message (optional)
203+ */
204+ export interface Metadata {
205+ /**
206+ * Unique message ID
207+ */
208+ messageId ?: string ;
209+ }
210+ }
211+
212+ /**
213+ * Optional metadata for the memory context. Defaults to ["default"] if not
214+ * provided.
215+ */
216+ export interface Metadata {
217+ /**
218+ * Optional group names for the memory context. Defaults to ["default"] if not
219+ * provided.
220+ */
221+ groupName ?: Array < string > ;
222+
223+ [ k : string ] : unknown ;
224+ }
225+ }
226+
138227export declare namespace Memory {
139228 export {
140229 type MemoryUpdateResponse as MemoryUpdateResponse ,
230+ type MemoryAddResponse as MemoryAddResponse ,
141231 type MemoryUpdateParams as MemoryUpdateParams ,
142232 type MemoryDeleteParams as MemoryDeleteParams ,
233+ type MemoryAddParams as MemoryAddParams ,
143234 } ;
144235}
0 commit comments