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

File Upload not recognizing mime #975

Open
hayescode opened this issue May 8, 2024 · 0 comments
Open

File Upload not recognizing mime #975

hayescode opened this issue May 8, 2024 · 0 comments

Comments

@hayescode
Copy link
Contributor

hayescode commented May 8, 2024

Describe the bug
When uploading certain file types the mime types are not recognized.

Incorrect:

  • Markdown .md
    • ERROR: defaults to application/octect-stream
  • Python .py
    • ERROR: App crashes
  File "C:\Users\haze\CheersGPT\.venv\Lib\site-packages\engineio\base_server.py", line 229, in _get_socket
    raise KeyError('Session is disconnected')
KeyError: 'Session is disconnected'

Correct:

  • .csv, .xlsx, docx, .pdf, .pptx

config.toml

[features.spontaneous_file_upload]
    enabled = true
    accept = ["*/*"]
    max_files = 20
    max_size_mb = 500

app.py

@cl.on_message
async def message(message_from_ui: cl.Message):
    for file in message_from_ui.elements:
        for key, value in file.to_dict().items():
            print(f"{key}: {value}")

terminal (Markdown error)

id: ca004f97-1820-4eb2-a47a-f10c66351fbd
threadId: 09c34591-df77-4ede-aab1-4ab016503365
type: file
url: None
chainlitKey: ca004f97-1820-4eb2-a47a-f10c66351fbd
name: README.md
display: inline
forId: be404f8a-f1f1-4eb5-99d0-7dc9f7ca5176
mime: application/octet-stream

To Reproduce
Steps to reproduce the behavior:

Markdown:

  1. Copy the README.md to your local computer.
  2. Configure Chainlit with above settings.
  3. Start app.py
  4. Add local README.md to chat and ask "Summarize This"

Python:

  1. Copy the user.py to your local computer
  2. Configure Chainlit with above settings.
  3. Start app.py
  4. Add local user.py to chat and ask "Summarize This"

Expected behavior
Mime type is correct and app doesn't crash. Maybe if mime.guess returns the default application/octet-stream it can then infer based on the file extension in some cases?

Desktop (please complete the following information):

  • OS: Windows 11
  • Browser Microsoft Edge
  • Version Chainlit 1.1.0rc1

Additional context
Add any other context about the problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant