spontaneous_file_upload in cl.ChatProfile features is not respected
Setting spontaneous_file_upload = SpontaneousFileUploadFeature(enabled=False) within the features argument of a cl.ChatProfile does not disable the file upload feature in the UI. However, disabling file uploads globally by setting the value manually in config.toml works as expected.
To Reproduce Steps to reproduce the behavior:
- Create a Chainlit app with the @cl.set_chat_profiles decorator.
- Define a cl.ChatProfile that includes the features argument, as shown in the code snippet below.
- Set spontaneous_file_upload = SpontaneousFileUploadFeature(enabled=False) within the FeaturesSettings.
- Run the application.
- See that the file upload button is still active in the chat interface.
Expected behavior The file upload button and functionality should be disabled as specified by enabled=False.
Screenshots N/A, but the UI incorrectly continues to show the file upload (paperclip) icon as active.
Additional context This issue seems specific to disabling features at the chat profile level. The relevant code block is:
Python
async def chat_profile(current_user: cl.User):
return [
cl.ChatProfile(
name="Sample app",
#icon="public/logo_light.png",
logo="public/logo_light.png",
layout = "wide",
features = FeaturesSettings(
spontaneous_file_upload = SpontaneousFileUploadFeature(enabled=False)
)
),
]```
Hi @datasherlock! I'm Dosu and I’m helping the chainlit team.
This is a known limitation: disabling spontaneous_file_upload in a cl.ChatProfile does not currently disable the file upload button in the UI. Only the global config.toml setting is respected for this feature. The backend does check the global flag and will block uploads if disabled, but the UI does not hide the button based on the chat profile's feature settings. This has been discussed and partially addressed for global settings, but not for per-profile settings yet. See related discussions and maintainer comments for more details: issue 1658.
At this time, there isn't a built-in workaround to disable file uploads per chat profile in the UI. You may need to enforce upload restrictions in your app logic or wait for future updates that add support for per-profile feature flags.
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other
Thanks - I am containerizing and hosting the app on Cloud Run. Given that the config.toml is created at runtime, how should I modify this setting while deploying?
@dosubot
To disable file uploads globally when deploying on Cloud Run, you’ll want to ensure your config.toml contains spontaneous_file_upload = false before Chainlit starts. In containerized/cloud setups, this is usually handled by either building the config.toml into your image, or generating it at container startup using an entrypoint script.
A common approach is to template config.toml and fill in values from environment variables at runtime. For example, you can use a shell script as your container entrypoint:
#!/bin/sh
cat <<EOF > /app/config.toml
[features]
spontaneous_file_upload = false
EOF
exec chainlit run your_app.py
You can expand this to pull values from environment variables if you want more flexibility. Just make sure the config.toml is present and correct before Chainlit starts, as there’s no built-in support for overriding these settings via environment variables alone.
This pattern works well for Cloud Run and other container platforms where you can control the startup process.
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other
This issue is stale because it has been open for 14 days with no activity.
This issue was closed because it has been inactive for 7 days since being marked as stale.