UNPKG

memoer

Version:

Memory management system for LLMs

18 lines 534 B
import { MemoryStrategy } from "../../base"; export class SlidingWindowStrategy extends MemoryStrategy { constructor(options) { super(); this.windowSize = options.windowSize; } shouldTrigger(context) { return context.length > this.windowSize; } optimize(context) { const recentMessages = context.slice(-this.windowSize); return recentMessages; } getOptimizedContext(context) { return this.optimize(context); } } //# sourceMappingURL=sliding-window.js.map