Skip to content

fix(prompt+removeBg): native endpoint + critique + max-preview (T-121) - #11

Open
DaleXiao wants to merge 1 commit into
mainfrom
fix/T-121-removebg-native-endpoint
Open

fix(prompt+removeBg): native endpoint + critique + max-preview (T-121)#11
DaleXiao wants to merge 1 commit into
mainfrom
fix/T-121-removebg-native-endpoint

Conversation

@DaleXiao

Copy link
Copy Markdown
Owner

Closes #10. Refs T-121.

Changes (3 surgical, all in worker/src/index.ts)

A. removeBackground → native endpoint (真根因)

  • COMPAT_API_URLDASHSCOPE_SUBMIT_URL (/api/v1/services/aigc/multimodal-generation/generation)
  • body: OpenAI-compat messages[].content[{type:image_url,...}] → native input.messages[].content[{image},{text}]
  • 解析: data.choices[0].message.contentdata.output.choices[0].message.content[0].image
  • 失败兜底(原图)保留;retry/2s backoff 保留
  • prompt 文本未变
  • 离线证据:compat-mode 0/6 → native 8/10。prod try{}catch{} 静默吞错,所以用户看到的「白底」=原图

B. PROMPT_MODEL → qwen3.6-max-preview

  • qwen3.6-plusqwen3.6-max-preview
  • enable_thinking: true 已在(line 324),无需改动

C. critique pass (新增反例库)

  • synthesizePrompts 解析校验完后追加第二次 LLM 调用
  • SYSTEM_PROMPT_CRITIQUE:仅检测 4 类 drift(D1 subject_replacement / D2 keyword_omission / D3 style_inversion / D4 topic_drift)
  • verdict=fix 且 fixed 校验通过 → 替换 parsed;否则保留原版
  • best-effort:任意失败(HTTP/parse/校验)都 silent fallback 到原版
  • 不动 SYSTEM_PROMPT 主提示的正例
  • 离线命中率:2/5 (40%)

不做

  • ❌ vl-plus 视觉验收(延迟代价 + 收益边际)
  • ❌ 重抠 retry(一次没成就用原图)
  • ❌ 换 birefnet / 第三方抠图

验证

  • npx tsc --noEmit ✅(仅遗留的 state unused warning,main 上已存在)
  • 上线后看:(1) removeBg 成功率 ≥ 70% (2) critique fix 命中率 ≥ 30% (3) P50 延迟增量 ≤ 50%

清理

  • 删掉未引用的 COMPAT_API_URL 常量

…#10)

Three small surgical fixes backed by 5-case offline evidence (10 images):

A. removeBackground: COMPAT_API_URL -> DASHSCOPE_SUBMIT_URL (native endpoint)
   wan2.7-image-pro image-edit ability is NOT exposed via OpenAI compat layer.
   Prod silently swallowed errors and returned the original white-bg image.
   Offline: compat-mode 0/6, native 8/10. Real root cause for the 'all-white'
   user complaints.

B. PROMPT_MODEL: qwen3.6-plus -> qwen3.6-max-preview
   enable_thinking already on. One-line change.

C. critique pass: second LLM call detects 4 drift classes
   (D1 subject_replacement / D2 keyword_omission / D3 style_inversion /
   D4 topic_drift) and emits a fixed pair when verdict=fix. Adds the
   counterexample reasoning only; SYSTEM_PROMPT positive examples untouched.
   Offline hit rate: 2/5 (40%). Best-effort: any failure falls back silently
   to the original variants.

Out of scope (deliberately not done):
  - vl-plus visual verification (latency vs. marginal gain)
  - retry on failed cut (one-shot, fall back to original)
  - alternative cut backends (birefnet etc.)

Closes #10
Refs T-121
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(prompt+removeBg): native endpoint + critique-with-counterexamples (one-shot, no vl)

1 participant