streamlit
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "streamlit":https://skillpi.com/zh/skills/deepskill-706ac1ab52455996ec48094e019b4541acb765a3fb7fcfee333e62c125e1d48e。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
为 Streamlit 提供专家级指导——一个用纯 Python 构建交互式数据应用和仪表板的框架。帮助开发者无需前端技能即可创建用于数据探索、机器学习模型演示和内部工具的网络应用。
介绍来源: third_party · TerminalSkills · 1.0.0 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 输入和输出
- 翻译待完成,请参阅来源文档。
- 实测状态
- 未测试
文件浏览
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
- prototypingStreamlit — 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
- Cache everything expensive — Use
@st.cache_datafor data,@st.cache_resourcefor connections and models - Wide layout for dashboards — Set
layout="wide"inset_page_configfor data-heavy pages - Sidebar for filters — Keep filters in
st.sidebar; main area for results and visualizations - Columns for KPIs — Use
st.columns(4)withst.metric()for a dashboard-style KPI row - Tabs for sections — Use
st.tabs()instead of scrolling; organize related content together - Session state for interactivity — Use
st.session_statefor per-user data (carts, selections, chat history) - Secrets management — Use
.streamlit/secrets.tomllocally; Streamlit Cloud manages secrets in the dashboard - Multi-page apps — Create a
pages/directory; each Python file becomes a sidebar navigation item
当前收录版本
1.0.0
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供 Streamlit 框架的完整开发指南,覆盖从基础应用到高级部署的全流程
- 针对数据科学家和开发者的高频刚需场景,显著提升交互式数据应用开发效率
亮点
- 触发描述精准,明确界定目标用户(无前端技能的开发者)和核心能力(纯 Python 构建数据应用)
- 覆盖多种典型使用场景(数据探索、ML 演示、内部工具),边界清晰无歧义
待提升项
-
description 内容重复 原报告严重程度:轻微
顶层 frontmatter 和 skill_body 内部均包含相同 description 内容
改进建议:建议移除 skill_body 开头的重复 description,保持信息唯一性
-
缺少显式 When to Use 章节 原报告严重程度:轻微
文档未设置独立的 'When to Use' 章节说明适用场景
改进建议:建议在 Overview 后增加 'When to Use' 章节,明确列出典型使用时机
亮点
- 文档结构清晰,分模块讲解基础结构、表单、缓存、聊天界面和部署
- 提供完整端到端代码示例,便于用户直接复用和测试
亮点
- 代码示例完整且可运行,涵盖错误处理、缓存优化和会话状态管理
- 部署方案详尽,支持本地运行、Streamlit Cloud 和 Docker 多种方式
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
安装或获取外部依赖
使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。
主文档提及 · 第 235 行 -
账号、密钥或授权
使用专用、最小权限账号,不把密钥粘贴到公开内容或命令日志;核对接收数据的服务与租户。
主文档提及 · 第 189 行
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。