dsh-auto-sight 0.4.6 → 0.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +81 -77
- package/README.zh-CN.md +81 -77
- package/client.js +349 -349
- package/cordis.patch.yml +6 -6
- package/icon.svg +6 -6
- package/index.js +672 -627
- package/locale/en.json +6 -6
- package/locale/zh.json +6 -6
- package/package.json +60 -58
- package/test/auto-vision.test.mjs +550 -480
- package/test/client-render.mjs +158 -158
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 thanderming
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 thanderming
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,77 +1,81 @@
|
|
|
1
|
-
# dsh-auto-vision
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
- **
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
- If every vision model fails,
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
1
|
+
# dsh-auto-vision
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/dsh-auto-sight) [](https://www.npmjs.com/package/dsh-auto-sight)
|
|
4
|
+
|
|
5
|
+
**English** | [简体中文](README.zh-CN.md)
|
|
6
|
+
|
|
7
|
+
Let a text-only model see images. When the selected model has no image input, **Auto Vision** asks a vision-capable model on the same provider to read each image, then sends the original request with that description in place of the image.
|
|
8
|
+
|
|
9
|
+
A DSH plugin. No API keys are stored in or sent by the plugin itself — it uses the credential your provider config already points at.
|
|
10
|
+
|
|
11
|
+
## Why this instead of another vision setup
|
|
12
|
+
|
|
13
|
+
- **No second API to configure.** It reuses the provider you are already talking to — no extra key, base URL or proxy to set up.
|
|
14
|
+
- **No model IDs to look up.** It reads that provider's model list and finds an image-capable one by itself; naming one in Settings is optional.
|
|
15
|
+
- **Fixes the rejected drop.** Dragging an image into a text-only model's input box used to be refused. Now the image is read first, and the same model answers.
|
|
16
|
+
|
|
17
|
+
## What it does
|
|
18
|
+
|
|
19
|
+
- Hooks `llm/stream`: if a request carries image blocks and the selected route is text-only, each image is read by a vision model on the **same provider** and replaced with a text block `[Image #n interpreted by <model>] … [/Image #n]`.
|
|
20
|
+
- Only steps in when all three are true: the request has at least one `image` block, the main route does not declare `image`, and a vision target resolves on the same provider. Otherwise it passes through untouched.
|
|
21
|
+
- Target order: the model chosen in Settings → other mounted image-capable models on the same provider → name-matched candidates from the official `/models` list. The next group is tried only when the previous one is unavailable or has failed.
|
|
22
|
+
- If the chosen vision model fails, tries the remaining targets in order; the block is marked `after <failed model> failed`. A system notice asks the main model to tell the user which model failed and which one was used.
|
|
23
|
+
- If every mounted vision model fails, queries the provider's official `/models` list, keeps name-matched candidates, and tries them over the direct endpoint. The official list has no modality metadata, so these candidates are not guaranteed to accept images.
|
|
24
|
+
- Sends a model that is not mounted locally, or is known to the adapter as text-only, to the provider's OpenAI-compatible `/chat/completions` endpoint. This requires `baseURL` and a usable `apiKeyEnv` in the provider config.
|
|
25
|
+
- If every vision model fails, inserts `[Image #n could not be interpreted by any vision model: …]` and still asks the main model to report it; the turn continues, and one failed image does not stop the others in the same message.
|
|
26
|
+
- Advertises image input in the model picker for text routes that have a vision sibling, so you can attach an image to them directly.
|
|
27
|
+
- Session history and the UI keep the real image; only the request going to the text model is rewritten.
|
|
28
|
+
- The first time an image is successfully read by a model that lacks an image declaration, writes `input: [text, image]` back to the provider's `llm-pi-ai` config for future direct routing. It never probes models the user has not used, and a failed or cancelled request writes nothing.
|
|
29
|
+
- Per-image result cache (128 entries) and in-flight de-duplication; 60 s timeout by default.
|
|
30
|
+
|
|
31
|
+
## Install
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
dsh plugin add github:thanderming/dsh-auto-vision
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Or install it from the plugin marketplace.
|
|
38
|
+
|
|
39
|
+
The same code is published to npm as [`dsh-auto-sight`](https://www.npmjs.com/package/dsh-auto-sight) (`npm i dsh-auto-sight`). The npm build is prebuilt — no install-time build step or `allowBuilds` prompt — and its download count is visible on the package page.
|
|
40
|
+
|
|
41
|
+
## Settings
|
|
42
|
+
|
|
43
|
+
**Settings → Auto Vision**: pick the vision model (grouped per provider), or leave it on *Automatic*. The selection is stored in volatile config and applies to the next image request.
|
|
44
|
+
|
|
45
|
+
| Config key | Default | Meaning |
|
|
46
|
+
| --- | --- | --- |
|
|
47
|
+
| `visionProvider` / `visionModel` | empty = auto | Model to read images with. A selection made for another provider is ignored; the plugin discovers a target on the provider handling the request instead. |
|
|
48
|
+
| `timeoutMs` | `60000` | Per-image read timeout. |
|
|
49
|
+
|
|
50
|
+
The picker has three groups:
|
|
51
|
+
|
|
52
|
+
- **Guaranteed**: models whose DSH config declares `input: [text, image]`.
|
|
53
|
+
- **Configured without image input**: models present in the DSH config but not declared as image-capable; shown by name match.
|
|
54
|
+
- **Official candidates**: the `/models` endpoint exposes no modality metadata, so these are name-matched guesses and are collapsed by default.
|
|
55
|
+
|
|
56
|
+
Once a candidate successfully reads a real user image, the plugin writes `input: [text, image]` back to the provider's `llm-pi-ai` config, so it moves into the guaranteed group next time. This only happens after a real image request, never as a background probe; refresh the Settings page to see the change.
|
|
57
|
+
|
|
58
|
+
## Privacy
|
|
59
|
+
|
|
60
|
+
- Images are sent only to the vision model of the **same provider** you are already talking to. Nothing goes to a third-party service.
|
|
61
|
+
- Credentials are read at request time from the credential reference (`apiKeyEnv`) of that provider's config; the key never enters the plugin's config, logs, or the browser UI.
|
|
62
|
+
- Image descriptions are cached in memory for the session only, and are never written to disk.
|
|
63
|
+
|
|
64
|
+
## Limitations
|
|
65
|
+
|
|
66
|
+
- Same provider only: a vision model on a different API is not used.
|
|
67
|
+
- The official list exposes only basic fields such as model IDs, not modality metadata; *candidates* are name-matched and may fail. Direct calls also need `baseURL` and a usable `apiKeyEnv` in the provider config.
|
|
68
|
+
- One extra model call per uncached image.
|
|
69
|
+
- Auto-marking modifies the `llm-pi-ai` model config; if several Settings pages edit config concurrently, a revision conflict is possible. That attempt only logs a warning and does not retry, and it does not affect the answer.
|
|
70
|
+
- Image content is treated as untrusted data in the vision prompt (the model is told not to follow instructions found in the image), but the resulting text still flows into your model's context as evidence.
|
|
71
|
+
|
|
72
|
+
## Development
|
|
73
|
+
|
|
74
|
+
```sh
|
|
75
|
+
node --test test/auto-vision.test.mjs # 16 tests, no network
|
|
76
|
+
node test/client-render.mjs # client Settings-page smoke test
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## License
|
|
80
|
+
|
|
81
|
+
MIT
|
package/README.zh-CN.md
CHANGED
|
@@ -1,77 +1,81 @@
|
|
|
1
|
-
# dsh-auto-vision
|
|
2
|
-
|
|
3
|
-
[
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
1
|
+
# dsh-auto-vision
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/dsh-auto-sight) [](https://www.npmjs.com/package/dsh-auto-sight)
|
|
4
|
+
|
|
5
|
+
[English](README.md) | **简体中文**
|
|
6
|
+
|
|
7
|
+
让纯文本模型也能看图。当所选模型不支持图片输入时,**自动视觉**会调用同一 API 下可识别图片的模型读图,再把图片替换成那段描述,交给原模型完成这一次请求。
|
|
8
|
+
|
|
9
|
+
这是一个 DSH 插件。插件本身不保存、也不转发任何 API 密钥——它用的就是你 provider 配置里已经指向的那份凭据。
|
|
10
|
+
|
|
11
|
+
## 为什么用它
|
|
12
|
+
|
|
13
|
+
- **不用再配一套 API。** 直接复用你正在用的 provider,不新增密钥、不填新的 base URL、不搭代理。
|
|
14
|
+
- **不用自己找模型 ID。** 自动从该 provider 的官方 `/models` 清单和 DSH 配置里挑出能识图的模型;想指定时再去设置里填。
|
|
15
|
+
- **专治「拖图片被拒」。** 往常把图片拖进纯文本模型的输入框会直接被拒绝,现在先用视觉模型读图,再由同一个模型回答。
|
|
16
|
+
|
|
17
|
+
## 它做什么
|
|
18
|
+
|
|
19
|
+
- 挂载 `llm/stream`:请求里带图片、而所选路由只支持文本时,每张图交给**同一 provider** 的视觉模型读取,并替换为文本块 `[Image #n interpreted by <模型名>] … [/Image #n]`。
|
|
20
|
+
- 只有同时满足以下条件才会介入:请求里至少有一个 `image` 块;主模型原生不声明 `image`;同一 provider 下能解析出视觉目标。否则原样放行。
|
|
21
|
+
- 视觉目标按顺序选择:设置里指定的模型 → 同一 provider 下其他已挂载的视觉模型 → 官方 `/models` 清单里按名称筛出的候选。前一组不可用或全部失败,才进入下一组。
|
|
22
|
+
- 指定的视觉模型失败时,按顺序尝试其余目标;成功后在块里标注 `after <失败模型> failed`,并通过 system 提示要求主模型在最终答复中说明「哪个失败、改用了哪个」。
|
|
23
|
+
- 如果已挂载的视觉模型都失败,再查该 provider 的官方 `/models` 清单,按名称筛出候选并逐个直连尝试。官方清单不返回模态信息,候选不保证真的接受图片。
|
|
24
|
+
- 本地 adapter 没挂载、或把它当成纯文本模型的候选,走该 provider 的 OpenAI 兼容 `/chat/completions` 端点直连;需要 provider 配置里有 `baseURL` 和可用的 `apiKeyEnv`。
|
|
25
|
+
- 所有视觉模型都失败时,插入 `[Image #n could not be interpreted by any vision model: …]` 并同样在最终答复中说明,不会中断整轮对话;一张图失败不影响同一条消息里的其他图片。
|
|
26
|
+
- 对有视觉兄弟模型的文本路由,在模型选择器里宣告「支持图片输入」,因此可以直接给它附图片。
|
|
27
|
+
- 会话历史和界面里保留原图,只有发往文本模型的那次请求被改写。
|
|
28
|
+
- 未声明图像输入的模型在第一次成功读图后,自动把 `input: [text, image]` 写回 `llm-pi-ai` 配置,供下次直接路由;不会预先测试用户没用过的模型,失败或取消也不会写。
|
|
29
|
+
- 单图结果缓存(128 条)+ 并发去重;默认 60 秒超时。
|
|
30
|
+
|
|
31
|
+
## 安装
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
dsh plugin add github:thanderming/dsh-auto-vision
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
也可以在插件市场里安装。
|
|
38
|
+
|
|
39
|
+
同一份代码已发布到 npm:[`dsh-auto-sight`](https://www.npmjs.com/package/dsh-auto-sight)(`npm i dsh-auto-sight`)。npm 上是预构建产物——安装时不需要构建步骤,也不会触发 `allowBuilds` 授权——下载量可以在包页面看到。
|
|
40
|
+
|
|
41
|
+
## 设置
|
|
42
|
+
|
|
43
|
+
**设置 → 自动视觉**:选择视觉模型(按 provider 分组),或保持「自动」。选择写入 volatile 配置,对下一次图片请求生效。
|
|
44
|
+
|
|
45
|
+
| 配置键 | 默认值 | 含义 |
|
|
46
|
+
| --- | --- | --- |
|
|
47
|
+
| `visionProvider` / `visionModel` | 空 = 自动 | 用哪个模型读图。为别的 provider 做的选择会被忽略,自动改用在当前请求的 provider 上发现的目标。 |
|
|
48
|
+
| `timeoutMs` | `60000` | 单张图的读取超时。 |
|
|
49
|
+
|
|
50
|
+
选择器分三组:
|
|
51
|
+
|
|
52
|
+
- **保证可用**:DSH 配置里明确声明了 `input: [text, image]` 的模型。
|
|
53
|
+
- **已配置但未声明图像输入**:模型在 DSH 配置里,但没声明能看图;按名称匹配展示。
|
|
54
|
+
- **官方候选**:官方 `/models` 接口不返回模态信息,只有按名称猜出的候选,默认折叠、不保证能调用。
|
|
55
|
+
|
|
56
|
+
候选模型第一次成功读图后,插件会把 `input: [text, image]` 写回 `llm-pi-ai` 配置,下次它就会进入「保证可用」组。这不会主动逐个探测模型,只在用户实际发图并成功读取后发生;刷新设置页即可看到配置变化。
|
|
57
|
+
|
|
58
|
+
## 隐私
|
|
59
|
+
|
|
60
|
+
- 图片只发给你**正在使用的同一个 provider** 的视觉模型,不经过任何第三方服务。
|
|
61
|
+
- 密钥在请求时从该 provider 配置的凭据引用(`apiKeyEnv`)读取,永远不进入插件配置、日志或浏览器界面。
|
|
62
|
+
- 图片描述只在内存里缓存,随会话结束消失,绝不落盘。
|
|
63
|
+
|
|
64
|
+
## 局限
|
|
65
|
+
|
|
66
|
+
- 仅限同一 provider:另一个 API 上的视觉模型不会被使用。
|
|
67
|
+
- 官方清单只有模型 ID 等基础字段,没有模态元数据;「候选」是按名称猜的,可能调用失败。直连还需要 provider 配置里有 `baseURL` 和可用的 `apiKeyEnv`。
|
|
68
|
+
- 每张未命中缓存的图片会多一次模型调用。
|
|
69
|
+
- 自动标记会修改 `llm-pi-ai` 的模型配置;如果多个设置页同时改配置,可能遇到 revision 冲突,本次只记录警告、不重试,且不影响本轮回答。
|
|
70
|
+
- 视觉提示中把图片内容当作不可信数据(明确要求模型不要执行图片里出现的指令),但生成的描述仍会作为素材进入你的模型上下文。
|
|
71
|
+
|
|
72
|
+
## 开发
|
|
73
|
+
|
|
74
|
+
```sh
|
|
75
|
+
node --test test/auto-vision.test.mjs # 16 个测试,不联网
|
|
76
|
+
node test/client-render.mjs # 客户端设置页 smoke test
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## 许可
|
|
80
|
+
|
|
81
|
+
MIT
|