Class MemoryManager

Constructors

Properties

client: IZepClient

Methods

  • Adds a new memory to a specific session.

    Parameters

    • sessionID: string

      The ID of the session to add the memory to.

    • memory: Memory

      The memory object to add to the session.

    Returns Promise<string>

    A promise that resolves to the added memory.

    Throws

    If the request fails.

  • Adds a session.

    Parameters

    • session: Session

      The session to add.

    Returns Promise<Session>

    The added session.

    Throws

    Will throw an error if the session is not provided.

    Throws

    Will throw an error if the session.session_id is not provided.

    Throws

    Will throw an error if the fetch request fails.

  • Asynchronously classifies a session with the specified ID.

    Parameters

    • sessionId: string

      The ID of the session to classify.

    • name: string

      The name of the classifier. Used to store the classification in session metadata if persist is true.

    • classes: string[]

      The classes to use for classification.

    • Optional lastN: number

      (Optional) The number of session messages to consider for classification. Defaults to 4.

    • persist: boolean = true

      (Optional) Whether to persist the classification to session metadata. Defaults to true.

    • instruction: undefined | string = undefined

      (Optional) Custom instruction for classification.

    Returns Promise<ClassifySessionResponse>

    A promise that resolves to the classification response object.

    Throws

    Error if session ID, name, or classes are not provided or are invalid.

  • Deletes the memory of a specific session.

    Parameters

    • sessionID: string

      The ID of the session for which the memory should be deleted.

    Returns Promise<string>

    • Promise message indicating the memory has been deleted.

    Throws

    • If the request fails.

    Throws

    • If the session is not found.
  • Retrieves memory for a specific session.

    Parameters

    • sessionID: string

      The ID of the session to retrieve memory for.

    • Optional type: MemoryType

      Optional. The type of memory to retrieve. Defaults to perpetual.

    • Optional lastn: number

      Optional. The number of most recent memories to retrieve.

    Returns Promise<null | Memory>

    • A promise that returns a Memory object.

    Throws

    • If the request fails.

    Throws

    • If the session is not found.
  • Retrieves a session with the specified ID.

    Parameters

    • sessionId: string

      The ID of the session to retrieve.

    Returns Promise<Session>

    A promise that resolves to the Session object.

    Throws

    Will throw an error if the sessionId is not provided.

    Throws

    Will throw an error if the fetch request fails.

    Throws

    Will throw an error if the session is not found.

  • Asynchronously retrieve a list of paginated sessions.

    Parameters

    • Optional limit: number

      Limit the number of results returned.

    • Optional cursor: number

      Cursor for pagination.

    Returns Promise<Session[]>

    A list of all sessions paginated.

    Throws

    If the API response format is unexpected.

  • Retrieve all sessions, handling pagination automatically. Yields a generator of lists of sessions.

    Parameters

    • Optional chunkSize: number = 100

      The number of sessions to retrieve at a time.

    Returns AsyncGenerator<Session[], void, unknown>

    The next chunk of sessions from the server.

    Throws

    If the API response format is unexpected.

    Throws

    If the connection to the server fails.

  • Searches memory of a specific session based on search payload provided.

    Parameters

    • sessionID: string

      ID of the session for which the memory should be searched.

    • searchPayload: MemorySearchPayload

      The search payload containing the search criteria.

    • Optional limit: number

      Optional limit on the number of search results returned.

    Returns Promise<MemorySearchResult[]>

    • Promise that resolves to array of search results.

    Throws

    • If the request fails.
  • Parameters

    • sessionId: string
    • lastN: number = 3

    Returns Promise<string>

  • Updates the specified session.

    Parameters

    • session: Session

      The session data to update.

    Returns Promise<Session>

    The updated session.

    Throws

    Will throw an error if the session is not provided.

    Throws

    Will throw an error if the session.session_id is not provided.

    Throws

    Will throw an error if the fetch request fails.

    Throws

    Will throw an error if the session is not found.