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.1.tar.gz (6.1 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.1.tar.gz.

File metadata

File hashes

Hashes for streamlit_rich_message_history-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c0d873ef40673446340509a677721d17b486e63bb27a6bf856b8566979447c58
MD5 46f7f21ab7809e22a899fabf0b7247a8
BLAKE2b-256 450ba6e0319a145ef74873df4c9747d5e34226b13742dd597ccff7da680ad895

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for streamlit_rich_message_history-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d7202623de9ba73cbeba78259914105f82d7cfe1187798d20b1e61c69336279b
MD5 9cae87d3644032700da6997494c283cc
BLAKE2b-256 f7406aa053293f43c8e670e1da6415568866668e792fb8ba699e61e221058b45

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