Skip to main content

streamlit-chat-input-fileupload

GitHub Actions PyPI version Total PyPI downloads Brought To You By KOLOMOLO Donate PayPal

A Streamlit custom component that extends the standard st.chat_input with file upload capability. Drop-in replacement for building chat interfaces that need document and image attachments.

Attaching a file to the chat input

LLM consuming the message with attached file

Features

  • Combined text input and file upload in a single component
  • Paperclip button for file selection with filename indicator
  • Supports images (PNG, JPG, GIF, WebP) and documents (PDF, CSV, TXT, XLSX, DOCX, MD, HTML)
  • Auto-detects light/dark theme from Streamlit's settings
  • Returns message text and file data (as bytes) in a single dict
  • Built with Streamlit Components v2 API

Installation

pip install streamlit-chat-input-fileupload

Usage

import streamlit as st
from streamlit_chat_input_fileupload import chat_input_with_upload

user_input = chat_input_with_upload(placeholder="Send a message...")

if user_input:
    st.write(f"Message: {user_input['text']}")

    if user_input["file"]:
        st.write(f"File: {user_input['file']['name']}")
        # user_input["file"]["data"] contains raw bytes

API

chat_input_with_upload()

chat_input_with_upload(
    placeholder="Send a message...",  # Input placeholder text
    disabled=False,                   # Disable the input
    key=None,                         # Unique component key
)

Returns None or dict:

  • text (str): Message text
  • file (dict or None): {name, type, size, data} where data is bytes

Sending Files to User

Use Streamlit's built-in st.download_button to send files back to the user:

import streamlit as st

# Text file
st.download_button(
    label="Download Report",
    data="Report content here",
    file_name="report.txt",
    mime="text/plain",
)

# Binary file (e.g., generated image, PDF)
st.download_button(
    label="Download Image",
    data=image_bytes,
    file_name="output.png",
    mime="image/png",
)

# CSV data
import pandas as pd
df = pd.DataFrame({"col1": [1, 2], "col2": [3, 4]})
st.download_button(
    label="Download CSV",
    data=df.to_csv(index=False),
    file_name="data.csv",
    mime="text/csv",
)

License

MIT

Metadata

Release files for streamlit-chat-input-fileupload 0.6.17

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for streamlit-chat-input-fileupload 0.6.17
File Interpreter ABI Platform Actions
streamlit_chat_input_fileupload-0.6.17-py3-none-any.whl Python 3 none any Details for streamlit_chat_input_fileupload-0.6.17-py3-none-any.whl

Release files / streamlit_chat_input_fileupload-0.6.17-py3-none-any.whl

Download URL streamlit_chat_input_fileupload-0.6.17-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f3b87e7eb85f18f801c3ff2a5fb497a882881044216ec454974a3b07444f9647
BLAKE2b-256 checksum
How to use checksums
f96331afc518da9c644c0f8d6fd7b7f15cf239072b1f103db6353a8c1be48e61
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Security for streamlit-chat-input-fileupload 0.6.17

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page