UNPKG

manifest

Version:

Self-hosted Manifest LLM router with embedded server, SQLite database, and dashboard

33 lines 1.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.injectOpenRouterCacheControl = injectOpenRouterCacheControl; const CACHE_CONTROL = { type: 'ephemeral' }; function injectOpenRouterCacheControl(body) { const messages = body.messages; if (!messages) return; for (let i = messages.length - 1; i >= 0; i--) { const msg = messages[i]; if (msg.role !== 'system' && msg.role !== 'developer') continue; if (typeof msg.content === 'string') { msg.content = [{ type: 'text', text: msg.content, cache_control: CACHE_CONTROL, }]; } else if (Array.isArray(msg.content)) { const blocks = msg.content; if (blocks.length > 0) { blocks[blocks.length - 1].cache_control = CACHE_CONTROL; } } break; } const tools = body.tools; if (tools && tools.length > 0) { tools[tools.length - 1].cache_control = CACHE_CONTROL; } } //# sourceMappingURL=cache-injection.js.map