Skip to main content

A package for creating rich, multi-component chat messages in Streamlit

Project description

Streamlit Rich Message History

A Python package for creating rich, multi-component chat messages in Streamlit.

Installation

pip install streamlit-rich-message-history

Basic Usage

import streamlit as st
from streamlit_rich_message_history import MessageHistory, UserMessage, AssistantMessage

# Initialize message history
history = MessageHistory()

# Add a simple user message
history.add_user_message_create("👤", "Hello, I need data analysis help")

# Create a rich assistant response
assistant_msg = AssistantMessage("🤖")
assistant_msg.add_text("I'd be happy to help! Here's a sample dataframe:")

import pandas as pd
import numpy as np

# Create a sample dataframe
df = pd.DataFrame({
    'A': np.random.randn(5),
    'B': np.random.randn(5),
    'C': np.random.randn(5)
})

# Add components to the message
assistant_msg.add_dataframe(df, title="Sample Data")
assistant_msg.add_code("import pandas as pd\ndf = pd.read_csv('data.csv')", 
                      language="python", 
                      title="Loading Data Code")

# Add the message to history
history.add_assistant_message(assistant_msg)

# Render all messages
history.render_all()

Features

  • Multi-component chat messages
  • Automatic type detection
  • Support for various content types:
    • Text and Markdown
    • DataFrames and Series
    • Matplotlib and Plotly figures
    • Code blocks with syntax highlighting
    • Error messages
    • Metrics
    • And more!

Documentation

For more examples and detailed documentation, visit our documentation site.

License

MIT

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

streamlit_rich_message_history-0.1.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file streamlit_rich_message_history-0.1.0.tar.gz.

File metadata

File hashes

Hashes for streamlit_rich_message_history-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8b74be72e8a30094a2a2ba4ee0bc85da9767df6b95293b6e382eb6574df1c65e
MD5 61c0eeca05a5245723e5ce503d0d6234
BLAKE2b-256 b05cd7e329996c37eb8656de9ecf99f7cb9b93a16a8585c3867cbe1ee63e83dc

See more details on using hashes here.

File details

Details for the file streamlit_rich_message_history-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_rich_message_history-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 76caba7e94b54ffaa14a181459a52d1942690889618ca04c2f182e74d4b1b6b2
MD5 408025eff0ddf2066ed6cd81e47c25fe
BLAKE2b-256 e10e18f2dedc1c94553aad194fa0517d58609d8ba7cbae3e13a0f754dfac4c98

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