mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-09-01 17:10:24 +08:00
supportsImageInput() guessed multimodal capability from the model id string. The heuristic misfired on newer models (e.g. kimi-k3.6, qwen36), either wrongly rejecting images for capable models or letting them through. The AI SDK does not emit a warning when an OpenAI-compatible endpoint silently drops an image, so the guess was the only signal — but an unreliable one. Drop the detection entirely and let the real provider error surface instead (already translated to a friendly message in chat-panel.tsx). Validation falls back to "valid" on any model error. - Remove supportsImageInput() and its pre-send check in chat route - Drop the vision-capability throw in getValidationModel() - Remove the corresponding unit tests
This commit is contained in:
@@ -15,7 +15,6 @@ import { z } from "zod"
|
||||
import {
|
||||
getAIModel,
|
||||
SINGLE_SYSTEM_PROVIDERS,
|
||||
supportsImageInput,
|
||||
supportsPromptCaching,
|
||||
} from "@/lib/ai-providers"
|
||||
import { findCachedResponse } from "@/lib/cached-responses"
|
||||
@@ -266,16 +265,10 @@ async function handleChatRequest(req: Request): Promise<Response> {
|
||||
lastUserMessage?.parts?.filter((part: any) => part.type === "file") ||
|
||||
[]
|
||||
|
||||
// Check if user is sending images to a model that doesn't support them
|
||||
// AI SDK silently drops unsupported parts, so we need to catch this early
|
||||
if (fileParts.length > 0 && !supportsImageInput(modelId)) {
|
||||
return Response.json(
|
||||
{
|
||||
error: `The model "${modelId}" does not support image input. Please use a vision-capable model (e.g., GPT-4o, Claude, Gemini) or remove the image.`,
|
||||
},
|
||||
{ status: 400 },
|
||||
)
|
||||
}
|
||||
// Note: we used to pre-emptively reject images for models we guessed were
|
||||
// text-only (by name matching). That heuristic misfired on newer models
|
||||
// (see issue #874), so we now let the request through and surface the real
|
||||
// provider error if the model genuinely can't accept images.
|
||||
|
||||
// User input only - XML is now in a separate cached system message
|
||||
const formattedUserInput = `User input:
|
||||
|
||||
Reference in New Issue
Block a user