het-25 / st-multimodal-chatinput

Streamlit component that allows you to accept multi-modal inputs through a chat interface.
MIT License
42 stars 8 forks source link
streamlit streamlit-component streamlit-components

Streamlit Multimodal Chat Input

A Streamlit component that enables a rich multimodal chat interface, allowing users to input text and upload images within Streamlit applications. Demo video at Streamlit Community Forum.

Features

Installation Instructions

To install the component, run the following command:

pip install st-multimodal-chatinput

Usage instructions

import streamlit as st

from st_multimodal_chatinput import multimodal_chatinput

chatinput = multimodal_chatinput()

uploaded_files = chatinput["uploadedFiles"] ##list of ALL uploaded files (including images) along with type, name, and content.
uploaded_images = chatinput["uploadedImages"] ## list of base 64 encoding of uploaded images
text = chatinput["textInput"] ##submitted text
for file in uploaded_files:
    filename = file["name"]
    filetype = file["type"] ## MIME type of the uploaded file
    filecontent = file["content"] ## base 64 encoding of the uploaded file

Common MIME types

File Extension MIME Type
.pdf application/pdf
.doc application/msword
.csv text/csv

You can find other common types here.

Contributing

Pull requests for some of the to-dos are more than welcome.