UNPKG

infinite-memory

Version:

Infinite context windows for Claude via OpenMemory semantic retrieval

27 lines 1.2 kB
import { createAnthropic } from '@ai-sdk/anthropic'; import { OpenMemoryClient } from './OpenMemoryClient.js'; import { ContextManager } from './ContextManager.js'; import { InfiniteMemoryModel } from './InfiniteMemoryModel.js'; export class InfiniteMemoryProvider { openMemory; contextManager; anthropicProvider; constructor(config) { this.openMemory = new OpenMemoryClient({ baseUrl: config.openMemoryUrl, apiKey: config.openMemoryApiKey, timeout: config.openMemoryTimeout || 2000, }); this.contextManager = new ContextManager(this.openMemory, config.anthropicApiKey); this.anthropicProvider = createAnthropic({ apiKey: config.anthropicApiKey, }); console.log('✨ [InfiniteMemory] Provider initialized'); } createModel(modelId, context) { console.log(`🎨 [InfiniteMemory] Creating model: ${modelId} (conv: ${context.conversationId}, user: ${context.userId})`); const baseModel = this.anthropicProvider(modelId); return new InfiniteMemoryModel(baseModel, this.contextManager, context, modelId); } } //# sourceMappingURL=InfiniteMemoryProvider.js.map