mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-01-02 22:32:27 +08:00
fix: show user-friendly error when model doesn't support images (#55)
When models like DeepSeek (deepseek-chat, deepseek-reasoner) receive image inputs, they return a cryptic error about 'unknown variant image_url'. This change detects such errors and shows a clear message asking users to remove the image or switch to a vision-capable model. Fixes #42
This commit is contained in:
@@ -331,15 +331,20 @@ IMPORTANT: Keep edits concise:
|
|||||||
return 'unknown error';
|
return 'unknown error';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof error === 'string') {
|
const errorString = typeof error === 'string'
|
||||||
return error;
|
? error
|
||||||
|
: error instanceof Error
|
||||||
|
? error.message
|
||||||
|
: JSON.stringify(error);
|
||||||
|
|
||||||
|
// Check for image not supported error (e.g., DeepSeek models)
|
||||||
|
if (errorString.includes('image_url') ||
|
||||||
|
errorString.includes('unknown variant') ||
|
||||||
|
(errorString.includes('image') && errorString.includes('not supported'))) {
|
||||||
|
return 'This model does not support image inputs. Please remove the image and try again, or switch to a vision-capable model.';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error instanceof Error) {
|
return errorString;
|
||||||
return error.message;
|
|
||||||
}
|
|
||||||
|
|
||||||
return JSON.stringify(error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.toUIMessageStreamResponse({
|
return result.toUIMessageStreamResponse({
|
||||||
|
|||||||
Reference in New Issue
Block a user