记忆
定义于:.build/typescript/packages/core/src/memory/memory.ts:49
TAdapters
Section titled “TAdapters”TAdapters 扩展 Record<string, MessageAdapter<unknown, TMessageOptions>> = Record<string, never>
TMessageOptions
Section titled “TMessageOptions”TMessageOptions extends object = object
新建内存<
TAdapters,TMessageOptions>(messages,options):Memory<TAdapters,TMessageOptions>
定义于:.build/typescript/packages/core/src/memory/memory.ts:90
MemoryMessage<TMessageOptions>[] = []
MemoryOptions<TMessageOptions> = {}
Memory<TAdapters, TMessageOptions>
add(
message):Promise<void>
定义于:.build/typescript/packages/core/src/memory/memory.ts:123
向记忆中添加一条消息
unknown
要添加到记忆中的消息
Promise<void>
获取<
K>(options):Promise<K继承 keyofTAdapters| keyof BuiltinAdapters? ReturnType<TAdapters&BuiltinAdapters<TMessageOptions>[K<K>]["fromMemory"]>[] :never>
定义于:.build/typescript/packages/core/src/memory/memory.ts:151
从记忆中获取特定类型的消息
K 继承 string | number | symbol = "llamaindex"
get 方法的选项
K
transientMessages?
Section titled “transientMessages?”ChatMessage<TMessageOptions>[]
Promise<K 扩展 keyof TAdapters | keyof BuiltinAdaptersReturnType<TAdapters & BuiltinAdapters<TMessageOptions>[K<K>]["fromMemory"]>[] : never>
特定类型的消息
getLLM()
Section titled “getLLM()”getLLM(
llm,transientMessages?):Promise<ChatMessage[]>
定义于:.build/typescript/packages/core/src/memory/memory.ts:200
从记忆中获取消息,可选择性地包含临时消息。 仅返回位于LLM上下文窗口内的消息
大语言模型
Section titled “llm”为了将结果消息适配到LLM的上下文窗口(如果未提供则回退到默认LLM)。 如果在构造函数和方法中均未指定llm,则将使用默认的令牌限制。
undefined | LLM<object, object>
transientMessages?
Section titled “transientMessages?”ChatMessage<TMessageOptions>[]
可选包含的临时消息。
Promise<ChatMessage[]>
来自记忆的消息,可选择性地包含临时消息。
manageMemoryBlocks()
Section titled “manageMemoryBlocks()”manageMemoryBlocks():
Promise<void>
定义于:.build/typescript/packages/core/src/memory/memory.ts:338
管理内存块 当短期记忆超过其令牌限制时,此方法将新消息处理成内存块。 它使用游标系统来跟踪哪些消息已被处理到长期记忆中。
Promise<void>
clear()
Section titled “clear()”clear():
Promise<void>
定义于:.build/typescript/packages/core/src/memory/memory.ts:409
清除内存中的所有消息
Promise<void>
snapshot()
Section titled “snapshot()”snapshot():
string
定义于:.build/typescript/packages/core/src/memory/memory.ts:420
创建当前记忆状态的快照 注意:内存块不包含在快照中,因为它们可能包含不可序列化的内容。 从快照加载时,内存块应当重新创建。
string
一个包含内存状态的JSON可序列化对象