DSH HUB
HomePlugin StorePlugin PacksCommunityRankingsResourcesPublish Guide
Plugin source
Back to catalog

Adachi-Hougetsu /

dsh-api-tools

Topic repository only

dsh API usage metering and one-click refresh plugins for DeepSeek Harness

★ 0 Stars0 Forks0 IssuesN/A Community rating0 Confirmed installs
View on GitHub
READMESource: main@bcb5a4d1

dsh-api-tools

为 DeepSeek Harness(dsh)Web 界面打造的两个实用插件:

  1. API 用量统计(dsh-api-meter + dsh-ui-api-meter)——按模型、按对话统计 token 用量
  2. 一键刷新(dsh-refresh + dsh-ui-refresh)——设置面板里的灰色刷新按钮,重启 dsh web

截图提示:可自行将面板截图放入 docs/api-meter.png 后显示在这里。

功能

API 用量统计

  • 侧边栏底部入口,点击打开大窗口
  • 顶部四项总量:总 Tokens、缓存命中率、调用次数、推理 Tokens
  • 每日堆叠柱状图(x 轴日期):未命中输入(蓝)/ 输出(深蓝)/ 缓存命中(浅蓝),可切换 7 / 14 / 30 天 / 全部
  • 按模型分类、按对话(会话)明细(点击展开该会话的模型用量)
  • 数据每 5 秒自动刷新

一键刷新

  • 设置面板内容列头部(关闭按钮旁)的小圆形刷新按钮
  • 点击确认后自动重启 dsh web(约 30 秒),无需手动操作终端
  • 重启时保留原始启动参数(profile / 端口 / 标志),并写日志到 <cwd>/data/refresh.log 供排查
  • 重启反馈:点击后显示「正在重启…」→ 服务恢复后「刷新完成」并自动重载 页面;60 秒未恢复则红色提示失败原因,按钮可重试

安装

git clone https://github.com/Adachi-Hougetsu/dsh-api-tools.git
cd dsh-api-tools

# 逐个安装四个插件包(顺序:先 host 再 UI)
dsh plugin --profile web add ./dsh-api-meter
dsh plugin --profile web add ./dsh-ui-api-meter
dsh plugin --profile web add ./dsh-refresh
dsh plugin --profile web add ./dsh-ui-refresh

--profile web 换成你实际使用的 profile 名;没有指定过 profile 时,默认 web 界面使用 web。

使用

安装后重启 dsh web:

  • 侧边栏底部出现「API 用量」图标 → 点击打开用量面板
  • 打开「设置」→ 内容列头部(右上角)出现灰色圆形刷新按钮 → 点击刷新

历史数据自动回算

插件升级前(旧版本没有按会话统计)的调用记录,会在首次启动时自动回算:

  • 自动读取 ~/.dsh/sessions 下的会话日志,重建按会话的用量明细

  • 无需任何手动操作,日志里会显示 backfilled N historical calls

  • 如果你希望强制重建,可以手动运行:

    node dsh-api-meter/scripts/backfill-sessions.mjs
    

    (需 dsh web 处于停止状态;脚本会先备份现有 usage.json)

配置

插件数据保存在 ~/.dsh/storages/api-meter/usage.json,可在 profile 的 cordis.patch.yml 中覆盖:

- id: api-meter
  config:
    persistIntervalMs: 30000   # 快照保存间隔(毫秒),0 关闭定时保存
    persistPath: 'C:\path\to\usage.json'   # 快照文件路径
    sessionsRoot: 'C:\path\to\sessions'    # 会话日志目录(回算用)

- id: refresh
  config:
    port: 3080                # 服务端口(缺省自动从启动参数解析,再回退 3080)
    killDelayMs: 800          # 响应后退出延迟
    timeoutMs: 30000          # 重启健康探测超时
    logPath: 'C:\path\to\refresh.log'   # 重启序列日志(缺省 <cwd>/data/refresh.log)

卸载

dsh plugin --profile web remove dsh-ui-refresh
dsh plugin --profile web remove dsh-refresh
dsh plugin --profile web remove dsh-ui-api-meter
dsh plugin --profile web remove dsh-api-meter

常见问题

重启后历史会话数据没出现? 确认 dsh web 完整重启过一次(首次启动时自动回算),并检查日志中是否有 api-meter: backfilled 字样。

总量与会话明细数字不一致? 总量按 provider/model 统计,会话明细按对话统计;同一调用会计入两者,但旧版本无会话信息的调用只计入总量。

刷新按钮点击后页面没反应? 确认 dsh-refresh 已安装;若重启后页面仍打不开, 查看 <cwd>/data/refresh.log 中的重启序列结果(拉起命令 / 端口状态 / 健康探测)。

许可

MIT

相关链接

  • DeepSeek Harness
  • 插件打包与安装指南(官方)
  • dsh-plugin 主题
DSH HUB

A community index for DSH plugins. Not an official GitHub or DeepSeek AI product.

CommunityResourcesAPIAbout
—/ 5

No ratings yet

Manifest verification required

Commit bcb5a4d12637

Community comments

No comments yet. Be the first to write one.