Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't upload a file with AskFileMessage when features.spontaneous_file_upload.enabled == False #1658

Closed
pmercier opened this issue Jan 9, 2025 · 3 comments
Labels
bug Something isn't working frontend Pertains to the frontend. needs-triage

Comments

@pmercier
Copy link
Contributor

pmercier commented Jan 9, 2025

Describe the bug
When Spontaneous file upload is disabled we can't upload a file with AskFileMessage.

To Reproduce

  1. Set features.spontaneous_file_upload.enabled = false in config.toml
  2. use this basic code for file upload :
import json
import chainlit as cl  
@cl.on_chat_start
async def start():
    resp = await cl.AskFileMessage(content="Gimme a file", accept=["text/plain"]).send()
    await cl.Message(json.dumps(resp[0].__dict__)).send()
  1. Run the code and upload a text file

Expected behavior
The config features.spontaneous_file_upload.enabled should impact only the file uploaded using the user message bar.

Screenshots
When trying to upload we are given this message in the GUI :

Capture d’écran du 2025-01-09 15-06-43

Desktop (please complete the following information):

Affect all browser

Smartphone (please complete the following information):
Affect all smartphone

Additional context
The GUI message is not clear. But the content found in the dev tool have more details :

Capture d’écran du 2025-01-09 15-14-36

detail: "File upload is not enabled"

Diving in the code we can see that the upload button use the same api endpoint (POST /project/file) than the spontaneaous upload.

This endpoint use the method chainlit.server.validate_file_upload() that check if the spontaneous_file_upload is enabled.

image

@dosubot dosubot bot added bug Something isn't working frontend Pertains to the frontend. labels Jan 9, 2025
@willydouhard
Copy link
Collaborator

Nice catch, we are using the same method for both upload method. Will think about fixing this properly

@willydouhard
Copy link
Collaborator

Fixed in today's release. This is partial fix as the spontaneous file upload limits (like mime type or size) will also apply on top of the AskFileMessage limits.

@pmercier
Copy link
Contributor Author

Thank you !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working frontend Pertains to the frontend. needs-triage
Projects
None yet
Development

No branches or pull requests

2 participants