Closed mw10013 closed 1 year ago
export interface BaseChatMemoryInput {
chatHistory?: BaseChatMessageHistory;
returnMessages?: boolean;
inputKey?: string;
outputKey?: string;
}
export interface BufferMemoryInput extends BaseChatMemoryInput {
humanPrefix?: string;
aiPrefix?: string;
memoryKey?: string;
}
export abstract class BaseMemory;
export abstract class BaseChatMemory extends BaseMemory;
export class BufferMemory extends BaseChatMemory implements BufferMemoryInput {
humanPrefix = "Human";
aiPrefix = "AI";
memoryKey = "history";
constructor(fields?: BufferMemoryInput) {
super({
chatHistory: fields?.chatHistory,
returnMessages: fields?.returnMessages ?? false,
inputKey: fields?.inputKey,
outputKey: fields?.outputKey,
});
this.humanPrefix = fields?.humanPrefix ?? this.humanPrefix;
this.aiPrefix = fields?.aiPrefix ?? this.aiPrefix;
this.memoryKey = fields?.memoryKey ?? this.memoryKey;
}
get memoryKeys() {
return [this.memoryKey];
}
}