UNPKG

@nomyx/assistant

Version:

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

29 lines (28 loc) 745 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.VertexCache = void 0; class VertexCache { constructor() { this.cache = new Map(); } set(key, value) { this.cache.set(this.stringifyKey(key), value); } get(key) { return this.cache.get(this.stringifyKey(key)); } has(key) { return this.cache.has(this.stringifyKey(key)); } clear() { this.cache.clear(); } stringifyKey(key) { return JSON.stringify({ messages: key.messages.map(m => ({ role: m.role, content: m.content })), options: key.options, tools: key.tools?.map(t => t.name) }); } } exports.VertexCache = VertexCache;