UNPKG

@codai/memorai-core

Version:

Simplified advanced memory engine - no tiers, just powerful semantic search with persistence

81 lines 2.55 kB
/** * High-Performance Memory Engine with Caching and Optimization * Addresses 45GB memory issue and performance problems */ import type { ContextRequest, ContextResponse, MemoryConfig, MemoryResult, MemoryType } from '../types/index.js'; export interface RememberOptions { type?: MemoryType; importance?: number; emotional_weight?: number; tags?: string[]; context?: Record<string, unknown>; ttl?: Date; skipDuplicateCheck?: boolean; } export interface RecallOptions { type?: MemoryType; limit?: number; threshold?: number; include_context?: boolean; time_decay?: boolean; useCache?: boolean; } export interface PerformanceMetrics { totalMemories: number; cacheHitRate: number; averageQueryTime: number; memoryUsage: number; duplicatesFound: number; optimizationSavings: number; } export declare class HighPerformanceMemoryEngine { private config; private embedding; private vectorStore; private optimizer; private cache; private isInitialized; private performanceMetrics; constructor(config?: Partial<MemoryConfig>); initialize(): Promise<void>; /** * High-performance remember with aggressive deduplication */ remember(content: string, tenantId: string, agentId?: string, options?: RememberOptions): Promise<string>; /** * High-performance recall with intelligent caching */ recall(query: string, tenantId: string, agentId?: string, options?: RecallOptions): Promise<MemoryResult[]>; /** * Optimized context loading with pagination and caching */ getContext(request: ContextRequest, useCache?: boolean): Promise<ContextResponse>; /** * Run memory optimization manually */ optimizeMemory(tenantId: string): Promise<void>; /** * Get performance metrics */ getPerformanceMetrics(): PerformanceMetrics; /** * Clear all caches */ clearCaches(): void; /** * Get memory statistics for a tenant */ getMemoryStats(tenantId: string): Promise<unknown>; private generateContentHash; private checkForDuplicate; private updateMemoryAccess; private classifyMemoryType; private calculateImportance; private applyTimeDecay; private getRecentMemoriesOptimized; private generateContextSummary; private calculateRelevanceScore; private updatePerformanceMetrics; private updateCacheHitRate; private startPeriodicOptimization; } //# sourceMappingURL=HighPerformanceMemoryEngine.d.ts.map