// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../core/resource'; import { APIPromise } from '../core/api-promise'; import { type Uploadable } from '../core/uploads'; import { buildHeaders } from '../internal/headers'; import { RequestOptions } from '../internal/request-options'; import { path } from '../internal/utils/path'; export class Memories extends APIResource { /** * Update the content of a specific memory by its ID. */ update( memoryID: string, params: MemoryUpdateParams, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat, ...body } = params; return this._client.put(path`/memories/${memoryID}`, { body, ...options, headers: buildHeaders([ { 'Content-Type': 'application/x-www-form-urlencoded', ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } /** * Retrieve all memories for a user based on the provided identifier. Returns a * paginated list of memory chunks with their content, metadata, and scores. */ list( params: MemoryListParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat } = params ?? {}; return this._client.get('/memories', { ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } /** * Delete multiple memories by their IDs. Only memories belonging to the * authenticated user can be deleted. */ delete(params: MemoryDeleteParams, options?: RequestOptions): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat, ...body } = params; return this._client.delete('/memories', { body, ...options, headers: buildHeaders([ { Accept: '*/*', ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } /** * Delete all memories for a specific user. This operation will permanently remove * all memories associated with the provided user ID. */ deleteAll( params: MemoryDeleteAllParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat } = params ?? {}; return this._client.delete('/memories/all', { ...options, headers: buildHeaders([ { Accept: '*/*', ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } /** * Update the important status of a specific memory by its ID. */ mark(memoryID: string, params: MemoryMarkParams, options?: RequestOptions): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat, ...body } = params; return this._client.put(path`/memories/${memoryID}/important`, { body, ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } } /** * Request model for deleting memories. * * Attributes: memory_ids (list[str]): List of memory IDs to delete. */ export interface DeleteMemoryRequest { /** * List of memory IDs to delete */ memory_ids: Array; } /** * Response model for getting memory. * * Attributes: memories (list[Chunk]): List of memory chunks retrieved. */ export interface GetMemoryResponse { /** * List of memory chunks */ memories: Array; } export namespace GetMemoryResponse { /** * Represents a chunk of content retrieved from a vector store. * * Attributes: id (str): A unique identifier for the chunk. Defaults to a random * UUID. content (str | bytes | None): The content of the chunk, either text, * binary, or None. additional_context (list[str | bytes]): Additional content to * be added as context of the chunk. metadata (dict[str, Any]): Additional metadata * associated with the chunk. Defaults to an empty dictionary. score (float | * None): Similarity score of the chunk (if available). Defaults to None. */ export interface Memory { content: string | Uploadable | null; id?: string; additional_context?: Array; metadata?: { [key: string]: unknown }; score?: number | null; } } export interface UpdateMemoryRequest { /** * Updated content for the memory */ content: string; } export type MemoryUpdateResponse = { [key: string]: boolean | string }; export type MemoryMarkResponse = { [key: string]: boolean | string }; export interface MemoryUpdateParams { /** * Body param: Updated content for the memory */ content: string; /** * Header param */ 'Accept-Language'?: string; /** * Header param: Set to `structured` to receive errors in the structured envelope. * Omit it to keep the legacy error body. */ 'X-Error-Format'?: string; } export interface MemoryListParams { 'Accept-Language'?: string; /** * Set to `structured` to receive errors in the structured envelope. Omit it to * keep the legacy error body. */ 'X-Error-Format'?: string; } export interface MemoryDeleteParams { /** * Body param: List of memory IDs to delete */ memory_ids: Array; /** * Header param */ 'Accept-Language'?: string; /** * Header param: Set to `structured` to receive errors in the structured envelope. * Omit it to keep the legacy error body. */ 'X-Error-Format'?: string; } export interface MemoryDeleteAllParams { 'Accept-Language'?: string; /** * Set to `structured` to receive errors in the structured envelope. Omit it to * keep the legacy error body. */ 'X-Error-Format'?: string; } export interface MemoryMarkParams { /** * Body param: Whether the memory should be marked as important */ is_important: boolean; /** * Header param */ 'Accept-Language'?: string; /** * Header param: Set to `structured` to receive errors in the structured envelope. * Omit it to keep the legacy error body. */ 'X-Error-Format'?: string; } export declare namespace Memories { export { type DeleteMemoryRequest as DeleteMemoryRequest, type GetMemoryResponse as GetMemoryResponse, type UpdateMemoryRequest as UpdateMemoryRequest, type MemoryUpdateResponse as MemoryUpdateResponse, type MemoryMarkResponse as MemoryMarkResponse, type MemoryUpdateParams as MemoryUpdateParams, type MemoryListParams as MemoryListParams, type MemoryDeleteParams as MemoryDeleteParams, type MemoryDeleteAllParams as MemoryDeleteAllParams, type MemoryMarkParams as MemoryMarkParams, }; }