Skip to content

fix: filter image_url content from API messages for DeepSeek compatibility#51

Merged
qorzj merged 3 commits into
lessweb:mainfrom
dengmik-commits:main
May 14, 2026
Merged

fix: filter image_url content from API messages for DeepSeek compatibility#51
qorzj merged 3 commits into
lessweb:mainfrom
dengmik-commits:main

Conversation

@dengmik-commits
Copy link
Copy Markdown
Contributor

Summary

DeepSeek API 不支持 image_url 消息内容类型,当消息中包含图片时(粘贴剪贴板图片、Read 工具读取图片文件)会报 400 错误。此修复在发送 API 请求前过滤掉 image_url 类型的内容部分,只保留文本。

Changes

  • src/session.ts - 在构建 API 消息时跳过 type === "image_url" 的内容块

Before

Request failed: 400 Failed to deserialize the JSON body into the target type: messages[58]: unknown variant image_url

After

图片消息仍存储在本地会话中(UI 正常显示 📎),但不发送给 DeepSeek API。

Fixes #50

…ility

DeepSeek API does not support the image_url message content type,
causing 400 errors when messages contain images from clipboard paste
or Read tool. Filter out image_url parts before sending to the API.

Fixes lessweb#50
@qorzj qorzj merged commit 648eb7e into lessweb:main May 14, 2026
@qorzj
Copy link
Copy Markdown
Collaborator

qorzj commented May 14, 2026

我还需要接着改进2点:

  1. read tool的prompt里面有说DeepSeek是多模态模型,目前干脆删掉这句,让LLM自己决定要不要调read tool
  2. if (part && part.type !== "image_url") { ... } 这个判断还要增加仅限deepseek-v4模型,否则README.md举的Doubao的例子就没法玩了

@qorzj qorzj mentioned this pull request May 15, 2026
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.

DeepSeek API 不支持 image_url 消息类型导致 400 错误

2 participants