Skip to main content

Streamlit multimodal chat input component with text, image, and voice support

Project description

Streamlit Multimodal Chat Input

A multimodal chat input component for Streamlit that supports text input, image upload, and voice input.

Note: image features require HTTPS or localhost environment to function properly.

Features

  • 📝 Text Input: Same usability as st.chat_input
  • 🖼️ Image File Upload: Supports jpg, png, gif, webp
  • 📸 Screenshot Capture: Capture and share screenshots directly
  • 🎨 Streamlit Standard Theme: Fully compatible design
  • 🔄 Drag & Drop: File drag and drop support
  • ⌨️ Ctrl+V: Paste images from clipboard
  • ⚙️ Customizable: Rich configuration options

Installation

pip install quadis-chat-input-multimodal

Basic Usage

import streamlit as st
from quadis_chat_input import quadis_chat_input

# Basic usage
result = quadis_chat_input()

if result:
    # Display text
    if result['text']:
        st.write(f"Text: {result['text']}")
    
    # Display uploaded files
    if result['files']:
        for file in result['files']:
            import base64
            base64_data = file['data'].split(',')[1]
            image_bytes = base64.b64decode(base64_data)
            st.image(image_bytes, caption=file['name'])
    

Advanced Usage

Screenshot Capture

# Enable screenshot capture (enabled by default)
result = quadis_chat_input(
    enable_screenshot=True
)

# Disable screenshot button
result = quadis_chat_input(
    enable_screenshot=False
)

Custom Configuration

result = quadis_chat_input(
    placeholder="Please enter your message...",
    max_chars=500,
    accepted_file_types=["jpg", "png", "gif", "webp"],
    max_file_size_mb=10,
    disabled=False,
    enable_screenshot=True,  # Control screenshot button visibility
    key="custom_chat_input"
)

Chat Usage

import streamlit as st
import base64
from quadis_chat_input import quadis_chat_input

# Page configuration
st.set_page_config(
    page_title="Multimodal Chat Input Demo",
    page_icon="💬",
)

st.subheader("💭 Multimodal Chat Input Demo")
st.markdown("Simulate a chat application with voice input and file upload.")

# Manage history in session state
if "chat_history" not in st.session_state:
    st.session_state.chat_history = []

# Input for new messages
chat_result = quadis_chat_input(
    placeholder="Enter chat message...",
    key="chat_input"
)
if chat_result:
    st.session_state.chat_history.append(chat_result)

# Display chat history
if st.session_state.chat_history:
    for i, message in enumerate(st.session_state.chat_history):
        with st.chat_message("user"):
            if message.get("text"):
                st.write(message["text"])
            
            if message.get("files"):
                for file in message["files"]:
                    try:
                        base64_data = file['data'].split(',')[1] if ',' in file['data'] else file['data']
                        image_bytes = base64.b64decode(base64_data)
                        st.image(image_bytes, caption=file['name'], width=200)
                    except:
                        st.write(f"📎 {file['name']}")
            
            # Display voice input information
            if message.get("audio_metadata") and message["audio_metadata"]["used_voice_input"]:
                st.caption(f"🎤 Voice input ({message['audio_metadata']['transcription_method']})")


# Clear history
if st.button("Clear History"):
    st.session_state.chat_history = []
    st.rerun()

License

MIT License

Author

Jon Goncalves - Quadis

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

quadis_chat_input-1.0.5.tar.gz (140.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quadis_chat_input-1.0.5-py3-none-any.whl (139.3 kB view details)

Uploaded Python 3

File details

Details for the file quadis_chat_input-1.0.5.tar.gz.

File metadata

  • Download URL: quadis_chat_input-1.0.5.tar.gz
  • Upload date:
  • Size: 140.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for quadis_chat_input-1.0.5.tar.gz
Algorithm Hash digest
SHA256 f4340d2f040b4cfbe4165e76476d138d441950d5053308f366a951c51561a315
MD5 d58dcd2b4ed7482d8addcea2b38d8f6f
BLAKE2b-256 6d8d01953b60add2bdfe0fd826e3abd609bde26ec72cfda4213dd85cf6e286a2

See more details on using hashes here.

File details

Details for the file quadis_chat_input-1.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for quadis_chat_input-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 9981ef068297d935c41c5fc8743451c6019cf74bcf726bd9a529d0df5bd5accf
MD5 d6e8fcdd2cdff2ded48ea995eb21af91
BLAKE2b-256 d7c39f9286262db6978437f4074eabf551b18329ab0b8dd11229ff368e944a51

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page