dsh-decision-tools:用本地 Ollama 做概率判断,不把材料塞进对话

前言

在 DSH 里让智能体做分类、过滤、打分或「等到某条件成立」,常见做法是反复调用大模型,每次把整段日志或列表塞进上下文,既费 token,又让主对话被噪声占满。另一种做法是自己写规则脚本,维护成本高,语义边界也不好表达。

dsh-decision-tools 把判断拆成两个专用工具:一次调用里用本地 Ollama 的 System One 接口输出概率与置信度,材料可通过文件、glob 或其它工具的原始输出传入,不必进入你的会话上下文;需要等待时则用 monitor 轮询来源,只观察、不代为执行操作。

这是什么

dsh-decision-tools 是 DSH 社区插件,维护者为 Dinosaur-MC,在目录中归类为工作流。它向智能体注册 decision 与 monitor 两个工具:前者在一次调用内对最多 64 条条目或 64 个不同问题做有界判断;后者按间隔对文件、命令、后台任务或任务事件重复采样,直到 rubric 判定命中或超时。判断走本机 Ollama(/v1/systemone),README 写明 judgement 本身不向云厂商发请求,也无需 API key。

核心功能

decision:一次调用,一种模式

decision 需要 material,且只能选下面两种模式之一。

Batch:rubric + items(1–64 条)+ type。同一标准独立评判每条。type 为 choice(多选一)、noul(是/否,布尔 value,概率在 probabilities.true)、或 score(0..N-1 刻度)。choice / score 需配合 criteria 提供标签。

Mixed:questions(1–64 个),对同一 material 问不同问题,每项含 name、type、instructions,可选 criteria。

material 支持:内联字符串;{ file: { path, startLine?, endLine? } };{ glob: { pattern, limit? } };{ images: [...] } 或 { text, images };{ tool: { name, arguments? } }。工具输出不会进入上下文,完整文本会落到 material.spillPath。tool 不能与其它 material 形式混用,且会拒绝插件自身工具。图片为工作区内 PNG/JPEG/WebP(1–8 张,单张 ≤16 MiB,合计 raw ≤24 MiB),需具备视觉能力的模型(如 clef / clef-flash);默认的 tev1 / nimble 会返回不支持视觉。

可选参数包括 depth(quick / normal / deep)、model(固定模型并关闭容量选择与升级)。返回结构含 results[]、coverage(是否截断、失败等)、cost(模型、token、耗时等)和 notes(首行常为模型选择说明)。confidence 表示集中度,不是准确率;低置信时应看 probabilities。

设计要点(README Why):评分标准(rubric)只发送一次,单次最多判 64 项,避免「每项一次调用」的反模式;材料与工具输出可留在工作区侧,主对话只读答案。

monitor:轮询直到条件成立

monitor 对单一 source 按 intervalMs(默认 5000)采样,每次用同一 rubric 询问,累计命中次数。mode 为 once 时在达到 countThreshold 或 timeoutMs(默认 120000)后返回;continuous 则跑到截止时间并返回累计 count。插件不杀进程、不重试、不取消任何外部任务;后台 monitor 可流式进度,并在触发时发一行通知。

source 类型包括:job(后台任务输出)、file、glob、command(通过上游管道重跑 argv)、events(任务事件环缓冲)。必填还有 description(用于标识)。type 目前为 noul;hitThreshold 默认 0.5;background 与 notify 等用于后台与通知(如 Quick start 中的 notify: "inbox")。

环境与依赖

  • 启用本插件的 DSH 桌面端(见安装)。
  • 本机 Ollama 提供 decision 模型,默认 tev1:0.8b,可在单次调用用 model 覆盖。
  • package.json 要求 Node ^22.19.0 || >=24.0.0,DSH >=0.2.0-rc.2。
  • 图片判断需视觉模型;无 API key。

默认配置快照:baseUrl = http://localhost:11434,defaultModel = tev1:0.8b,以及四档 ladder;可通过 defaultModel、baseUrl、ladder: [{ model, numCtx }] 调整。仓库提供 node scripts/list-models.mjs 查看已安装模型与可粘贴的 ladder。

安装与启用

npm 包发布后,在 web profile 下安装:

dsh plugin --profile web add dsh-decision-tools

从本地 checkout 开发时,可 link 到 profile:

dsh plugin --profile web add link:/absolute/path/to/dsh-decision-tools

确认工具已注册:

cordis_inspect_query(platform="host", provider="Tool", method="listTools")

插件会注册配套 skill decision-usage,按需加载并文档化各参数。当前 package 版本为 0.4.0,许可证 MIT。

典型用法

下面示例均来自项目 README Quick start,可直接作为工具调用的参数形状参考。

1)用同一 rubric 过滤列表(batch / noul)

{ "material": "<the list or its context>", "rubric": "Is this a bug report?",
  "items": ["app crashes on save", "please add dark mode"], "type": "noul" }

2)对单个文件问多个不同问题(mixed)

{ "material": { "file": { "path": "build.log", "startLine": 1, "endLine": 200 } },
  "questions": [
    { "name": "ok", "type": "noul", "instructions": "Did the build succeed?" },
    { "name": "why", "type": "choice", "instructions": "What failed?",
      "criteria": { "compile": "compile error", "test": "a test failed", "env": "missing dependency" } }
  ] }

3)评判其它工具输出而不把输出读进对话

{ "material": { "tool": { "name": "git_bash", "arguments": { "command": "npm test" } } },
  "rubric": "Did the test suite pass?", "items": ["the test suite output"], "type": "noul" }

4)截图判断(需 vision 模型)

{ "material": { "images": ["screenshots/checkout-error.png"] },
  "model": "clef-flash:latest",
  "questions": [ { "name": "has_error", "type": "noul", "instructions": "Does this screenshot show an error state?" } ] }

5)后台等待任务结束并收到通知

{ "source": { "kind": "job", "id": "<jobId>" },
  "rubric": "Did the job finish successfully?", "background": true, "notify": "inbox" }

适用场景与注意

适合需要在 DSH 工作流里做本地、可重复的语义判断的场景:工单分类、请求路由、候选排序、日志是否表示失败、构建是否成功等。monitor 适合等构建结束、某行日志出现、任务失败等「等到条件成立再通知」的流程;它只观测,不会替你杀任务或改系统状态。

使用前请在本机准备好 Ollama 与合适模型;视觉与纯文本模型不要混用默认可用项。插件以当前 DSH 进程权限运行,command 类 source 会重跑主机命令,tool material 会调用其它工具——安装前建议阅读仓库源码与 MIT 许可证,确认符合你的安全策略。

DSH 生态强调「一切皆插件」;社区目录 skillhub.cn 为独立站点,与 DeepSeek / 幻方无官方从属关系,本文介绍的是社区维护的 dinosaur-mc/dsh-decision-tools。

结尾

dsh-decision-tools 把「要概率、不要长文」的判断和「轮询直到命中」的等待,收敛到两个与 Ollama System One 对接的 DSH 工具,并尽量让原始材料留在工作区侧。目录页与源码可从这里继续查看:

  • 目录页:https://www.skillhub.cn/plugins/Dinosaur-MC/dsh-decision-tools
  • GitHub:https://github.com/Dinosaur-MC/dsh-decision-tools
羽毛球分组比赛记分
小程序二维码

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

Xiaoye