SHA-256 prompt deduplication for LLM and TTS calls — hash normalize prompts, check cache before calling APIs, store results for instant replay. Use when making repeated or similar API calls to avoid redundant spending. Works with any database backend (SQLite, Turso, Postgres).
一个轻量级缓存层,可防止重复生成相同内容。通过在生产环境中拦截重复提示词,节省了约60%的API配额。
python
import prompt_cache
if cached:
return cached # 免费!无需调用API。
sql
CREATE TABLE IF NOT EXISTS prompt_cache (
prompt_hash TEXT NOT NULL,
child_name TEXT NOT NULL,
language TEXT NOT NULL,
story_json TEXT,
createdat DATETIME DEFAULT CURRENTTIMESTAMP,
PRIMARY KEY (prompthash, childname, language)
);
默认实现使用(prompt, child_name, language)作为缓存键。可根据您的领域进行调整:
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 prompt-cache-1776285001 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 prompt-cache-1776285001 技能
skillhub install prompt-cache-1776285001
文件大小: 2.5 KB | 发布时间: 2026-4-16 18:19