Skip to content

feat: add acceptedFileMimetypes to model config#2189

Open
tessaherself wants to merge 1 commit intohuggingface:mainfrom
tessaherself:feat/accepted-file-mimetypes
Open

feat: add acceptedFileMimetypes to model config#2189
tessaherself wants to merge 1 commit intohuggingface:mainfrom
tessaherself:feat/accepted-file-mimetypes

Conversation

@tessaherself
Copy link

Summary

  • Adds acceptedFileMimetypes field to model config schema, allowing models to declare which file MIME types they accept (e.g. ["application/pdf", "image/*"])
  • Plumbs the field through the API response and frontend type so the upload UI adapts per model
  • Frontend merges acceptedFileMimetypes with existing multimodalAcceptedMimetypes to build the active MIME list

This is the foundation for native file handling per provider — models declare what they support, and endpoint adapters deliver files in the appropriate format.

Example config:

{
  "name": "gpt-4o",
  "multimodal": true,
  "acceptedFileMimetypes": ["application/pdf"]
}

Related: #2188, #482, #609, #1505, #1652

Test plan

  • Verify model without acceptedFileMimetypes behaves as before (text + images only)
  • Verify model with acceptedFileMimetypes: ["application/pdf"] shows PDF in file picker
  • Verify MIME types merge correctly (no duplicates) when both multimodal and file types set

🤖 Generated with Claude Code

Allow models to declare which file MIME types they accept (e.g.
"application/pdf", "image/*") via a new `acceptedFileMimetypes` field.
The frontend merges these with existing multimodal MIME types to
determine which upload options to show.

This enables per-model file type support without coupling to a
specific provider's file handling implementation.

Refs: huggingface#482, huggingface#609, huggingface#1505, huggingface#1652

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
tessaherself added a commit to tessaherself/chat-ui that referenced this pull request Mar 16, 2026
When a model declares `acceptedFileMimetypes` including
"application/pdf", PDFs are now sent as OpenAI `file` content parts
with base64 data instead of being wrapped in XML tags. This lets
OpenAI (and compatible providers) process PDFs natively.

Non-PDF files and models without `acceptedFileMimetypes` are
unaffected — existing text extraction behavior is preserved.

Depends on: huggingface#2189

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 182ee28286

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

...(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 👍 / 👎.

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.

1 participant