Laya Tool Router

在 DSH 的 Standard preset 中,模型在输出第一个单词前需要处理包含 26 个工具模式的系统提示,导致 prefill tokens 达到 6,559 个。这消耗了大量上下文预算,并增加了首字延迟。Laya Tool Router 通过隐藏所有工具模式,仅在需要时通过 Laya decision endpoint 揭示一个工具来解决这个问题。

核心功能

该插件实现了 lazy tool discovery,将 prefill tokens 从 6,559 减少到 283。它采用 3 阶段决策过程:

  1. 词汇排序:过滤停用词,选出 ≤ 8 个候选。
  2. 决策请求:向 Laya endpoint 发送 POST 请求,获取 bestTool 和 usable noul 问题。
  3. 置信度检查:仅当 confidence >= 0.30 且 p(noul) <= 0.30 时接受选择。

对于精确的工具名称请求,插件会跳过 Laya 并立即揭示工具。

安装与启用

使用 CLI 安装:

dsh plugin --profile <profile> add git+https://github.com/residenthiago2011/DSH-Laya-Tool-Router.git

安装后,在 Plugins 页面选择该 bundle,并使用 no-prefill preset。

配置

需要一个运行在 http://127.0.0.1:8081/v1/systemone 的 Laya endpoint。在 index.js 中配置 LAYA_BASE 以更改地址。

文件

  • index.js:注册 find_tool,隐藏其他工具,运行 3 阶段决策。
  • cordis.patch.yml:preset 声明和 host tool enablement。
  • tool-registry.json:Stage-0 标签和 Stage-1 标准。

注意事项

  • 需要 DSH 0.2.0-rc.2。
  • 需要主机上的 pnpm。
  • find_tool 注册标准 JSON Schema;必须始终编译。
  • 存在空请求目录提示和精确名称快速路径,适用于小模型。
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

小夜