Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/lib/components/chat/ChatWindow.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@
providerOverride && providerOverride !== "auto" && !currentModel.isRouter
);

// Always allow common text-like files; add images only when model is multimodal
// Always allow common text-like files; add images when multimodal; add declared file types
import { TEXT_MIME_ALLOWLIST, IMAGE_MIME_ALLOWLIST_DEFAULT } from "$lib/constants/mime";

let activeMimeTypes = $derived(
Expand All @@ -319,6 +319,7 @@
...(modelIsMultimodal
? (currentModel.multimodalAcceptedMimetypes ?? [...IMAGE_MIME_ALLOWLIST_DEFAULT])
: []),
...(currentModel.acceptedFileMimetypes ?? []),

Choose a reason for hiding this comment

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

P1 Badge Prevent advertising file MIME types that are dropped

Including currentModel.acceptedFileMimetypes in the upload allowlist exposes file types (e.g. application/pdf) that the request pipeline does not actually forward to the model: prepareMessagesWithFiles only preserves images and text MIME types from TEXT_MIME_ALLOWLIST (src/lib/server/textGeneration/utils/prepareFiles.ts, prepareFiles). In this scenario users can successfully attach a file in the UI, but that attachment is silently omitted from the model input, leading to incorrect chat behavior.

Useful? React with 👍 / 👎.

])
)
);
Expand Down
1 change: 1 addition & 0 deletions src/lib/server/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export type GETModelsResponse = Array<{
preprompt?: string;
multimodal: boolean;
multimodalAcceptedMimetypes?: string[];
acceptedFileMimetypes?: string[];
supportsTools?: boolean;
unlisted: boolean;
hasInferenceAPI: boolean;
Expand Down
2 changes: 2 additions & 0 deletions src/lib/server/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ const modelConfig = z.object({
.optional(),
multimodal: z.boolean().default(false),
multimodalAcceptedMimetypes: z.array(z.string()).optional(),
/** MIME types the model accepts as file attachments (e.g. ["application/pdf", "image/*"]) */
acceptedFileMimetypes: z.array(z.string()).optional(),
// Aggregated tool-calling capability across providers (HF router)
supportsTools: z.boolean().default(false),
unlisted: z.boolean().default(false),
Expand Down
1 change: 1 addition & 0 deletions src/lib/types/Model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export type Model = Pick<
| "preprompt"
| "multimodal"
| "multimodalAcceptedMimetypes"
| "acceptedFileMimetypes"
| "unlisted"
| "hasInferenceAPI"
| "providers"
Expand Down
1 change: 1 addition & 0 deletions src/routes/api/v2/models/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const GET: RequestHandler = async () => {
preprompt: model.preprompt,
multimodal: model.multimodal,
multimodalAcceptedMimetypes: model.multimodalAcceptedMimetypes,
acceptedFileMimetypes: model.acceptedFileMimetypes,
supportsTools: (model as unknown as { supportsTools?: boolean }).supportsTools ?? false,
unlisted: model.unlisted,
hasInferenceAPI: model.hasInferenceAPI,
Expand Down