UNPKG

@nomyx/assistant

Version:

A powerful assistant library and cli for your AI projects. works with Vertex AI (Claude and Gemini)

32 lines (31 loc) 823 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OpenAICache = void 0; class OpenAICache { constructor() { this.cache = new Map(); } generateCacheKey(key) { return JSON.stringify({ messages: key.messages, options: key.options, tools: key.tools?.map(tool => tool.name) }); } set(key, value) { const cacheKey = this.generateCacheKey(key); this.cache.set(cacheKey, value); } get(key) { const cacheKey = this.generateCacheKey(key); return this.cache.get(cacheKey); } has(key) { const cacheKey = this.generateCacheKey(key); return this.cache.has(cacheKey); } clear() { this.cache.clear(); } } exports.OpenAICache = OpenAICache;