DSH HUB
HomePlugin StorePlugin PacksCommunityRankingsResourcesPublish Guide
Plugin source
Back to catalog

2228293026 /

2228293026/dsh-model-usage

Verified

在左侧栏加入「模型用量」入口,打开一个按模型统计 Token 消耗与请求次数的面板。

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

dsh-model-usage

DSH 插件:在左侧栏加入「模型用量」入口,打开一个按模型统计 Token 消耗与请求次数的面板。

功能

  • 左侧栏入口:sidebar.panellist(全局面板图标区)新增条形图图标;折叠成轨道时显示 Tooltip,展开时显示文字。按钮、焦点、aria 与选中态由 shell 拥有,插件只提供图标与本地化标签。
  • 整页面板:main 以同一 id 注册,点击栏位即切换到该页。
  • 页面内容:
    • 当前模型(provider / model / 推理强度)
    • 按模型的用量表:请求数、输入、输出、缓存读取、推理 Token、合计、最近使用时间
    • 统计进度(首次扫描历史会话时)
    • 已配置的 provider / model 目录
  • 界面文案与元数据提供中文、英文两套。

安装

本仓库是一个标准 DSH bundle(dsh.bundle.patch + dsh.client)。把本目录作为 bundle 装进当前 profile:

plugin_manager  action=install_bundle  target=<本目录绝对路径>

安装后刷新 DSH Web 页面即可看到左侧栏图标。升级 / 卸载:在插件页停用或移除 Model Usage,或对同一 bundle 执行 remove_bundle。

数据来源

  • 用量来自本机会话日志中 assistant/message 事件的 data.usage,模型身份取 data.message.source.{provider,model}。
  • totalTokens 不直接采信(并非所有 provider 都写),改为按输入 + 输出自行计算。
  • 按会话持久化 revision(dev:ino:size:mtimeNs:ctimeNs)缓存结果到 ~/.dsh/plugin-data/dsh-model-usage/usage-cache.json,重启后只重读变更过的会话;新 turn 通过 session/event 实时增量累加。
  • Host 半提供只读的同源接口 GET /api/model-usage(?action=scan 触发重扫),带同源校验。

说明

  • 首次打开需要扫描全部历史会话(本机 435 个会话 / 约 843MB 压缩日志,耗时约 1–2 分钟,带进度条),之后走缓存。
  • 统计范围仅限本机会话日志,不含其它设备或已删除的会话。

结构

文件 作用
index.js Host 半:会话折取、缓存、/api/model-usage 路由
client.js Client 半:左侧栏图标与中央页面(两个 slot 注册)
cordis.patch.yml bundle 插入 model-usage 行
package.json bundle 清单与 dsh.client 声明
locale/*.json 插件管理页显示用标题/描述
icon.svg 插件图标

许可证

本项目基于 MIT 协议开源,Copyright (c) 2026 HitMargin。

—/ 5

No ratings yet

Verified DSH bundle

Commit c644b559f822

Community comments

No comments yet. Be the first to write one.

DSH HUB

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

CommunityResourcesAPIAbout