loomy 0.1.4: DeepSeek-V4.1-Flash keeps its image_url parts (#811)

prefersTagFormat() sent every model id containing "deepseek" through
rewriteImagesToTags(), which turns data-URI image_url parts into
<image_base64> text. That rule came with the plugin (6a9c528a, from
agent2api's images.rs) for the DeepSeek models of the time; the test
fixture's model is "deepseek-v4-flash", listed as "DeepSeek V4 Flash 0731".
The reporter's direct calls show DeepSeek-V4.1-Flash now reads OpenAI
image_url parts (prompt 244 tokens, right answer on two accounts) and
reads the marker as plain text (prompt 10,533, all output spent on
reasoning, empty reply). deepseek-v4-flash-0731 reads neither shape, so
it keeps the marker as before; nothing here makes it worse.

Now a deepseek id with v4.1 / v4-1 in it keeps its parts as sent; every
other deepseek id is rewritten as before.

Run (on mote, via mote-run):
- bun test packages/loomy: 30 pass, 0 fail
- bun scripts/check.mjs loomy: registry.json and loomy ok
- HOME=$(mktemp -d) bun test (whole repo, as CI runs it): 6499 pass,
  1 fail. The fail is sap-aicore's "late failure does not delete a
  newer candidate" under load; it passes 3 of 3 alone, filed as #812.
  (A first run without a sandbox HOME failed devin and zcode tests that
  refuse to run under a real HOME; not a red.)
Broken by hand:
- prefersTagFormat back to "every deepseek": the two new tests (the
  reporter's DeepSeek-V4.1-Flash request through the loader, and the id
  table) go red, 28 pass / 2 fail.
- prefersTagFormat always false: the original 0731 marker test and the id
  table go red, 28 pass / 2 fail.
Not tried: a real Loomy account; the ids and token counts are the
reporter's.

Reported-by: gcq909893267
This commit is contained in:
yetone
2026-11-07 02:11:17 +08:00
parent 1d4edc39b7
commit 7a2599bdae
4 changed files with 37 additions and 6 deletions
+1 -1
View File
@@ -15,7 +15,7 @@ magpie plugin login loomy # 选「短信验证码登录」或「手动粘贴
- **登录**:`短信验证码登录`(发码 → 输入 6 位码完成,session **14 天**)或 `手动粘贴 session`。
- **无续期接口**:session 过期(业务码 `020002`/`100002`)需重新登录(短信或粘贴)。
- **聊天**:`POST {modelBase}/chat/completions`,OpenAI 形态基本透传,两处适配(参照实现 `reasoning_patch` / `images.rs`):思考档折进 low/medium/high(超档删除)、DeepSeek 系模型的 data-URI 图片转 `<image_base64>` 标记;SSE;请求头必须带 `charset=utf-8`(上游对无 charset 的 body 按 GBK 解码)。
- **聊天**:`POST {modelBase}/chat/completions`,OpenAI 形态基本透传,两处适配(参照实现 `reasoning_patch` / `images.rs`):思考档折进 low/medium/high(超档删除)、旧版 DeepSeek(deepseek-v4-flash-0731)的 data-URI 图片转 `<image_base64>` 标记(DeepSeek-V4.1-Flash 收 OpenAI `image_url`,不转,#811);SSE;请求头必须带 `charset=utf-8`(上游对无 charset 的 body 按 GBK 解码)。
- **画图**:`POST {modelBase}/images/generations`(doubao-seedream-5-lite / qwen-image-3.0-pro / Hy-Image-3.5-preview),body 按 magpie 写的原样透传,`Accept: application/json`(不是 SSE),回答是普通 JSON(`data[].url`、`points_consumed`)。401/403 报登录失效。`/images/edits`(改图)暂不转发:magpie 发给插件的改图是 multipart,Loomy 网关收不收这种改图没有实测过(#609)。
- **模型**:登录前给静态表(2026-10-16 实抓 `/api/v1/models` 的 chat 模型:DeepSeek-V4.1-Flash / deepseek-v4-flash-0731 / MiniMax-M3 / Kimi-k2.6 / qwen-3.8-max / GLM-5.3-Flash / qwen3.8-flash / spark-x / mimo-v2.5 / auto),登录后以 `GET /api/v1/models` 的实时目录为准(能力位读 `capabilities`;展示名尾部倍率 `(x3.0)` 拆为 rate 字段)。
- **余额(usage)**:`GET /api/v2/points/records?...` → 永久积分 + 每日赠送积分两个窗口;每日窗口用厂商自己的 `dailyLimitPoints`/`dailyRemainingPoints` 报「已用/剩余/上限」,厂商未带这一对时按无上限的余额展示(不编造上限)。响应缺余额字段时报 error("未知"不冒充 0)。
+9 -4
View File
@@ -236,11 +236,16 @@ function foldReasoning(body) {
return changed
}
// deepseek models on Loomy read images only as <image_base64> markers, not
// OpenAI image_url parts; data-URI images are turned into the marker and
// merged into the text before them (agent2api images.rs)
// the older deepseek models on Loomy (deepseek-v4-flash-0731) read
// images only as <image_base64> markers, not OpenAI image_url parts; their
// data-URI images are turned into the marker and merged into the text before
// them (agent2api images.rs). DeepSeek-V4.1-Flash takes image_url parts and
// reads the marker as plain text (10k prompt tokens, an empty reply), so it
// keeps the parts as sent (plugins#811)
function prefersTagFormat(model) {
return String(model ?? "").toLowerCase().includes("deepseek")
const m = String(model ?? "").toLowerCase()
if (!m.includes("deepseek")) return false
return !/v4[.-]1(?![0-9])/.test(m)
}
function toTagText(part) {
const kind = String(part?.type ?? "").trim().toLowerCase()
+26
View File
@@ -135,6 +135,32 @@ describe("chat", () => {
expect(content[1].type).toBe("image_url")
})
test("DeepSeek-V4.1-Flash keeps its image_url parts (plugins#811)", async () => {
const loader = await plugin.auth.loader(getAuth)
const parts = [
{ type: "text", text: "图里写的数字是多少" },
{ type: "image_url", image_url: { url: "data:image/png;base64,QUJD" } },
]
await loader.fetch(`${fake.gatewayUrl}/api/v1/chat/completions`, {
method: "POST",
body: JSON.stringify({ model: "DeepSeek-V4.1-Flash", stream: false, messages: [{ role: "user", content: parts }] }),
})
const content = fake.state.chatCalls[0].body.messages[0].content
expect(content).toEqual(parts)
expect(JSON.stringify(content)).not.toContain("<image_base64>")
})
test("which models get the base64 marker", () => {
// the reporter's ids: V4.1 reads image_url parts, 0731 is the model the
// marker was added for
expect(_internal.prefersTagFormat("DeepSeek-V4.1-Flash")).toBe(false)
expect(_internal.prefersTagFormat("deepseek-v4.1-flash")).toBe(false)
expect(_internal.prefersTagFormat("deepseek-v4-flash-0731")).toBe(true)
expect(_internal.prefersTagFormat("deepseek-v4-flash")).toBe(true)
expect(_internal.prefersTagFormat("GLM-5.3-Flash")).toBe(false)
expect(_internal.prefersTagFormat(undefined)).toBe(false)
})
test("a refused session says 401", async () => {
saved = { type: "oauth", access: "gone", expires: 0 }
const loader = await plugin.auth.loader(getAuth)
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@magpie-community/opencode-loomy-auth",
"version": "0.1.3",
"version": "0.1.4",
"description": "OpenCode & Magpie provider plugin for Loomy (讯飞, loomyad.xunfei.cn): SMS sign-in, chat, models, the two point wallets and the daily first-login grant",
"type": "module",
"main": "./opencode.mjs",