streamlit

Provide expert guidance for Streamlit — a framework for building interactive data apps and dashboards using pure Python. Help developers create web apps for data exploration, ML model demos, and internal tools without front-end skills.

Last repository push
GitHub Stars
219
Forks
38
Issues / PRs
7

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "streamlit" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-706ac1ab52455996ec48094e019b4541acb765a3fb7fcfee333e62c125e1d48e. Verify the upstream source and version against https://github.com/TerminalSkills/skills before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

github.com

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Provide expert guidance for Streamlit — a framework for building interactive data apps and dashboards using pure Python. Help developers create web apps for data exploration, ML model demos, and internal tools without front-end skills.

0 Downloads

Introduction source: third_party · TerminalSkills · 1.0.0 Reference

SkillPi interpretation

Tasks
Expert guidance for Streamlit, the Python framework for building interactive data applications and dashboards. Helps developers create web apps for data exploration, ML model demos, and internal tools using pure Python — no frontend skills required.
Inputs and outputs
```python
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: streamlit
description: Expert guidance for Streamlit, the Python framework for building interactive data applications and dashboards. Helps developers create web apps for data exploration, ML model demos, and internal tools using pure Python — no frontend skills required.
license: Apache-2.0
compatibility: No special requirements
metadata:
  author: terminal-skills
  version: 1.0.0
  category: data-ai
  tags:
  - dashboards
  - python
  - data-apps
  - visualization
  - prototyping

Streamlit — Python Data Apps

Overview

Streamlit, the Python framework for building interactive data applications and dashboards. Helps developers create web apps for data exploration, ML model demos, and internal tools using pure Python — no frontend skills required.

Instructions

Basic App Structure

# app.py — Complete Streamlit data dashboard
import streamlit as st
import pandas as pd
import plotly.express as px

st.set_page_config(
    page_title="Sales Dashboard",
    page_icon="📊",
    layout="wide",
)

st.title("📊 Sales Dashboard")
st.markdown("Real-time view of sales performance across all regions.")

# Sidebar filters
with st.sidebar:
    st.header("Filters")
    date_range = st.date_input(
        "Date Range",
        value=(pd.Timestamp("2026-01-01"), pd.Timestamp("2026-03-01")),
    )
    regions = st.multiselect(
        "Regions",
        ["North America", "Europe", "Asia Pacific", "Latin America"],
        default=["North America", "Europe"],
    )
    min_revenue = st.slider("Minimum Revenue", 0, 10000, 0, step=100)

# Load and filter data
@st.cache_data(ttl=600)                    # Cache for 10 minutes
def load_data():
    return pd.read_parquet("data/sales.parquet")

df = load_data()
filtered = df[
    (df["date"].between(*date_range)) &
    (df["region"].isin(regions)) &
    (df["revenue"] >= min_revenue)
]

# KPI metrics row
col1, col2, col3, col4 = st.columns(4)
with col1:
    st.metric("Total Revenue", f"${filtered['revenue'].sum():,.0f}",
              delta=f"{filtered['revenue'].pct_change().mean():.1%}")
with col2:
    st.metric("Orders", f"{len(filtered):,}")
with col3:
    st.metric("Avg Order Value", f"${filtered['revenue'].mean():,.2f}")
with col4:
    st.metric("Unique Customers", f"{filtered['customer_id'].nunique():,}")

# Charts
tab1, tab2, tab3 = st.tabs(["📈 Trends", "🗺️ Regions", "📋 Data"])

with tab1:
    monthly = filtered.groupby(filtered["date"].dt.to_period("M")).agg(
        revenue=("revenue", "sum"),
        orders=("order_id", "count"),
    ).reset_index()
    monthly["date"] = monthly["date"].dt.to_timestamp()

    fig = px.line(monthly, x="date", y="revenue",
                  title="Monthly Revenue Trend",
                  labels={"revenue": "Revenue ($)", "date": "Month"})
    st.plotly_chart(fig, use_container_width=True)

with tab2:
    by_region = filtered.groupby("region")["revenue"].sum().reset_index()
    fig = px.bar(by_region, x="region", y="revenue",
                 title="Revenue by Region", color="region")
    st.plotly_chart(fig, use_container_width=True)

with tab3:
    st.dataframe(
        filtered.head(100),
        use_container_width=True,
        column_config={
            "revenue": st.column_config.NumberColumn("Revenue", format="$%.2f"),
            "date": st.column_config.DateColumn("Date"),
        },
    )

Forms and User Input

# pages/submit_feedback.py — Multi-page app with form input
import streamlit as st

st.title("📝 Customer Feedback")

with st.form("feedback_form"):
    name = st.text_input("Your Name")
    email = st.text_input("Email")
    category = st.selectbox("Category", ["Bug", "Feature Request", "General"])
    rating = st.slider("Satisfaction (1-10)", 1, 10, 5)
    feedback = st.text_area("Your Feedback", height=150)
    file = st.file_uploader("Attach Screenshot", type=["png", "jpg"])

    submitted = st.form_submit_button("Submit Feedback")

    if submitted:
        if not name or not email:
            st.error("Please fill in all required fields.")
        else:
            # Save to database
            save_feedback(name, email, category, rating, feedback, file)
            st.success("✅ Thank you for your feedback!")
            st.balloons()

Caching and Performance

# Caching strategies for fast dashboards
import streamlit as st

# Cache data loading (survives reruns, clears on TTL or input change)
@st.cache_data(ttl=3600)                    # 1-hour cache
def load_large_dataset(path: str) -> pd.DataFrame:
    """Load and preprocess a large dataset.
    Cached result is serialized — safe for DataFrames."""
    df = pd.read_parquet(path)
    df["month"] = df["date"].dt.to_period("M")
    return df

# Cache resource objects (database connections, ML models)
@st.cache_resource                           # Persists across all users/sessions
def get_db_connection():
    """Create a shared database connection.
    Cached as a resource — not serialized, shared by reference."""
    return create_engine(st.secrets["database"]["url"])

@st.cache_resource
def load_ml_model():
    """Load a trained ML model (shared across all sessions)."""
    import joblib
    return joblib.load("models/classifier.pkl")

# Session state for per-user data
if "cart" not in st.session_state:
    st.session_state.cart = []

def add_to_cart(item):
    st.session_state.cart.append(item)

Chat Interface

# pages/ai_chat.py — AI chatbot interface
import streamlit as st
from openai import OpenAI

st.title("🤖 AI Assistant")

client = OpenAI(api_key=st.secrets["openai"]["api_key"])

# Initialize chat history in session state
if "messages" not in st.session_state:
    st.session_state.messages = []

# Display chat history
for msg in st.session_state.messages:
    with st.chat_message(msg["role"]):
        st.markdown(msg["content"])

# Chat input
if prompt := st.chat_input("Ask me anything..."):
    # Add user message
    st.session_state.messages.append({"role": "user", "content": prompt})
    with st.chat_message("user"):
        st.markdown(prompt)

    # Generate AI response
    with st.chat_message("assistant"):
        stream = client.chat.completions.create(
            model="gpt-4o",
            messages=st.session_state.messages,
            stream=True,
        )
        response = st.write_stream(stream)

    st.session_state.messages.append({"role": "assistant", "content": response})

Deployment

# Run locally
streamlit run app.py

# Deploy to Streamlit Community Cloud (free)
# 1. Push to GitHub
# 2. Go to share.streamlit.io
# 3. Connect repo → Deploy

# Deploy with Docker
# Dockerfile
FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
EXPOSE 8501
CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]
# .streamlit/config.toml — Streamlit configuration
[theme]
primaryColor = "#6366f1"
backgroundColor = "#0e1117"
secondaryBackgroundColor = "#1e1e2e"
textColor = "#ffffff"

[server]
maxUploadSize = 200    # MB
enableCORS = false

Examples

Example 1: Setting up an evaluation pipeline for a RAG application

User request:

I have a RAG chatbot that answers questions from our docs. Set up Streamlit to evaluate answer quality.

The agent creates an evaluation suite with appropriate metrics (faithfulness, relevance, answer correctness), configures test datasets from real user questions, runs baseline evaluations, and sets up CI integration so evaluations run on every prompt or retrieval change.

Example 2: Comparing model performance across prompts

User request:

We're testing GPT-4o vs Claude on our customer support prompts. Set up a comparison with Streamlit.

The agent creates a structured experiment with the existing prompt set, configures both model providers, defines scoring criteria specific to customer support (accuracy, tone, completeness), runs the comparison, and generates a summary report with statistical significance indicators.

Guidelines

  1. Cache everything expensive — Use @st.cache_data for data, @st.cache_resource for connections and models
  2. Wide layout for dashboards — Set layout="wide" in set_page_config for data-heavy pages
  3. Sidebar for filters — Keep filters in st.sidebar; main area for results and visualizations
  4. Columns for KPIs — Use st.columns(4) with st.metric() for a dashboard-style KPI row
  5. Tabs for sections — Use st.tabs() instead of scrolling; organize related content together
  6. Session state for interactivity — Use st.session_state for per-user data (carts, selections, chat history)
  7. Secrets management — Use .streamlit/secrets.toml locally; Streamlit Cloud manages secrets in the dashboard
  8. Multi-page apps — Create a pages/ directory; each Python file becomes a sidebar navigation item

Current listing version

1.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value92/100

Highlights

  • 提供 Streamlit 框架的完整开发指南,覆盖从基础应用到高级部署的全流程
  • 针对数据科学家和开发者的高频刚需场景,显著提升交互式数据应用开发效率
Trigger Precision95/100

Highlights

  • 触发描述精准,明确界定目标用户(无前端技能的开发者)和核心能力(纯 Python 构建数据应用)
  • 覆盖多种典型使用场景(数据探索、ML 演示、内部工具),边界清晰无歧义
Structure and Standards94/100

Areas to improve

  • description 内容重复 Reported severity: Minor

    顶层 frontmatter 和 skill_body 内部均包含相同 description 内容

    Recommendation: 建议移除 skill_body 开头的重复 description,保持信息唯一性

  • 缺少显式 When to Use 章节 Reported severity: Minor

    文档未设置独立的 'When to Use' 章节说明适用场景

    Recommendation: 建议在 Overview 后增加 'When to Use' 章节,明确列出典型使用时机

Highlights

  • 文档结构清晰,分模块讲解基础结构、表单、缓存、聊天界面和部署
  • 提供完整端到端代码示例,便于用户直接复用和测试
Execution Reliability93/100

Highlights

  • 代码示例完整且可运行,涵盖错误处理、缓存优化和会话状态管理
  • 部署方案详尽,支持本地运行、Streamlit Cloud 和 Docker 多种方式
Evidence Verifiability (mean of the first four)94/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

  • Install or fetch external dependencies

    Use official sources and pin versions. Check install scripts in an isolated environment. This document check does not cover code downloaded later.

    Mentioned in main document · lines 235
  • Accounts, secrets or authorization

    Use a dedicated least-privilege account. Keep secrets out of public content and command logs; verify the receiving service and tenant.

    Mentioned in main document · lines 189

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.