Class that manages the memory of a generative agent in LangChain. It extends the BaseMemory class and has methods for adding a memory, formatting memories, getting memories until a token limit is reached, loading memory variables, saving the context of a model run to memory, and clearing memory contents.

Hierarchy

Constructors

Properties

addMemoryKey: string = "addMemory"
memoryChain: GenerativeAgentMemoryChain
mostRecentMemoriesKey: string = "most_recent_memories"
mostRecentMemoriesTokenKey: string = "recent_memories_token"
nowKey: string = "now"
queriesKey: string = "queries"
relevantMemoriesKey: string = "relevant_memories"
relevantMemoriesSimpleKey: string = "relevant_memories_simple"
verbose: boolean
reflectionThreshold?: number

Accessors

  • get memoryKeys(): string[]
  • Returns string[]

  • get memoryVariables(): string[]
  • Returns string[]

Methods

  • Method that adds a memory to the agent's memory.

    Parameters

    • memoryContent: string

      The content of the memory to add.

    • Optional now: Date

      The current date.

    • Optional metadata: Record<string, unknown>

      The metadata for the memory.

    • Optional callbacks: Callbacks

      The Callbacks to use for adding the memory.

    Returns Promise<ChainValues>

    The result of the memory addition.

  • Method that clears the memory contents.

    Returns void

    Nothing.

  • Method that formats the given relevant memories in detail.

    Parameters

    • relevantMemories: Document<Record<string, any>>[]

      The relevant memories to format.

    Returns string

    The formatted memories as a string.

  • Method that formats the given relevant memories in a simple manner.

    Parameters

    • relevantMemories: Document<Record<string, any>>[]

      The relevant memories to format.

    Returns string

    The formatted memories as a string.

  • Method that returns the key for adding a memory.

    Returns string

    The key for adding a memory as a string.

  • Method that returns the key for the current time.

    Returns string

    The key for the current time as a string.

  • Method that retrieves memories until a token limit is reached.

    Parameters

    • consumedTokens: number

      The number of tokens consumed so far.

    Returns Promise<string>

    The memories as a string.

  • Method that returns the key for the most recent memories token.

    Returns string

    The key for the most recent memories token as a string.

  • Method that returns the key for relevant memories.

    Returns string

    The key for relevant memories as a string.

  • Method that loads memory variables based on the given inputs.

    Parameters

    • inputs: InputValues

      The inputs to use for loading memory variables.

    Returns Promise<Record<string, string>>

    An object containing the loaded memory variables.

  • Method that saves the context of a model run to memory.

    Parameters

    Returns Promise<void>

    Nothing.

Generated using TypeDoc