Skip to content

Conversation

@JoeGlenn1213
Copy link

  • 背景问题:DeepSeek 文本接口不支持图片输入,包含图片消息会触发 unknown variant "image_url"
  • 修复内容:在构造用户消息时,检测当前 modelId ;若是 DeepSeek,不注入 type: "image" 内容
  • 变更位置:服务器路由 app/api/chat/route.ts ,仅影响 DeepSeek,其他视觉模型不受影响
  • 验证步骤:
  • 配置 AI_PROVIDER=deepseek + AI_MODEL=deepseek-chat ,不上传图片能正常生成图
  • 上传图片不会报错(图片被跳过)
  • 切换到视觉模型(如 openai/gpt-4o 、 google/gemini-3-flash-preview )图片能正常传入
  • 风险与兼容性:仅跳过不支持的图片输入,其他 provider 行为不变;后续可抽象为统一的“视觉能力映射”

@vercel
Copy link

vercel bot commented Dec 19, 2025

Someone is attempting to deploy a commit to the dayuanjiang's projects Team on Vercel.

A member of the Team first needs to authorize it.

@DayuanJiang
Copy link
Owner

谢谢贡献。
静默失败的话又会有很多人问为什么图片上传了没效果 e.g. #324
最好是把带Image_url的错误信息转换成更加可读的错误信息,例如:

// Translate image not supported error
if (friendlyMessage.includes("image content block")) {
friendlyMessage = "This model doesn't support image input."
}

@JoeGlenn1213
Copy link
Author

对,感觉只能维护一个 model-capabilities.json,或者 启发式判断了

Copy link
Owner

@DayuanJiang DayuanJiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JoeGlenn1213 Thanks for the fix!
However, this seems like a lot of code change (215 additions) for what could be a one-line fix. How about just updating line 592 to catch the DeepSeek error message?

 if (friendlyMessage.includes("image content block") || friendlyMessage.includes('unknown variant "image_url"')) {
     friendlyMessage = "This model doesn't support image input."                 
 } 

// Translate image not supported error
if (friendlyMessage.includes("image content block")) {
friendlyMessage = "This model doesn't support image input."
}

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.

2 participants