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.4.tar.gz (6.0 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.4.tar.gz.

File metadata

  • Download URL: streamlit_rich_message_history-0.1.4.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.11.11 Linux/6.8.0-1021-azure

File hashes

Hashes for streamlit_rich_message_history-0.1.4.tar.gz
Algorithm Hash digest
SHA256 11cbafdad985690a76ccb77014e058dbfcf1d0e170fb8e5ecc61cd09a41ae9c3
MD5 3e2e080987358763a9680af8ee6baeca
BLAKE2b-256 443df2e18c32c726ed14db4fb365f9f4609eadbe2e9dde470b84f51598ec8015

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for streamlit_rich_message_history-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 14c89ac493069a3e7f810e4bde7a0b8c0628370e292bae0b1746a83c8480c97d
MD5 dc8e54118b33e400aa7f00b012d4b92b
BLAKE2b-256 25ffe034c42bfe77f418ef4a7792c6bde8f223e6ba87e564476d51af1f47d0f2

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