sixtysevenlf/dsh-cost-guard

sixtysevenlf★ 1JavaScript最后同步: 2026-08-21

在 GitHub 打开

dsh-cost-guard — DeepSeek 成本守卫插件:会话成本核算(官方峰谷费率)、¥ 预算守卫、收敛引导、峰谷错峰队列;附对比测试报告

README 摘要

dsh-cost-guard — DeepSeek V4-Flash-0731 纯 API 省钱守卫 面向「只用 API、不自部署」场景的成本插件,装配在 router / mode-boost 之上, 不碰 persona (路由归它们),只做「钱」的事。定价口径 = DeepSeek 官方 2026-08-17 峰谷分级(¥/百万 token): Flash-0731 缓存命中 未命中 输出 空闲(每日非高峰时段) ¥0.05 ¥1.5 ¥4.5 高峰(每日 09:00-12:00 / 14:00-18:00) ¥0.10 ¥3.0 ¥9.0 同请求「命中:未命中 = 1:30」;高峰 = 空闲 × 2;Pro 为 Flash 的 3 倍。插件按 model id 自动选档。 启动即生效(运行时热装,免重启) 持久化(重启后自动恢复): dsh plugin --profile web add 或 dev install package 。 工具 工具 作用 cost status 当前项目仪表盘:模型/峰谷/费率/累计用量(输入/输出/缓存命中/缓存写/推理)/已花 ¥/命中率/全命中可省金额/预算/防线阈值/硬上限状态 cost budget {budget} 设当前项目 ¥ 预算(0 清除)。 预算即硬上限 :设了就生效,花到预算由 llm/stream 短路拦截不再计费(到顶即停),无需额外开关 cost peak 当前峰谷状态、下一切换点、错峰建议 cost defer {task, maxTokens?} 把一次 LLM 任务登记进错峰队列;高峰排队、空闲 daemon 自动执行(10 分钟粒度),结果落 /.dsh/cost-guard/results/ .json cost deferred 队列状态:queued/running/done/failed + 结果路径 cost guide {target} 手动注入收敛/深度/错峰/预算引导(近场、前缀缓存中性) 原理(一句话) - 用量 :从 durable assistant/message 事件里 data.usage 折叠( TokenUsage :inputTokens / outputTokens / cacheReadTokens / cacheWriteTokens / reasoningTokens),resume 后仍准确; - 成本 : cached×hit + (input+write)×miss + (output+reasoning)×out (推理按输出价,保守口径); - 缓存纪律 :persona 不碰(保持 30× 前缀缓存红利);引导只走 inbox next-step 近场(离散事件触发, 不刷屏、不改 system 前缀); - 错峰 : isP…

在 GitHub 查看完整 README →
工具/开发cordis-plugindeepseek-harnessdsh-plugin

分类