infinite-memory
Version:
Infinite context windows for Claude via OpenMemory semantic retrieval
27 lines • 1.13 kB
JavaScript
import { OpenMemoryClient } from './OpenMemoryClient.js';
import { ContextManager } from './ContextManager.js';
import { createAnthropic } from '@ai-sdk/anthropic';
export function createInfiniteMemory(config) {
const openMemoryClient = new OpenMemoryClient({
baseUrl: config.openMemoryUrl,
apiKey: config.openMemoryApiKey,
timeout: config.openMemoryTimeout,
});
const anthropic = createAnthropic({
apiKey: config.anthropicApiKey,
});
const contextManager = new ContextManager(openMemoryClient, config.anthropicApiKey);
return {
async getRelevantContext(conversationId, userId, messages, modelId) {
return contextManager.getRelevantContext({ conversationId, userId }, messages, modelId);
},
async storeMessage(conversationId, userId, role, content, messageId) {
return contextManager.storeMessage({ conversationId, userId }, role, content, messageId);
},
getModel(modelId) {
return anthropic(modelId);
},
openMemory: openMemoryClient,
};
}
//# sourceMappingURL=index.js.map