axiom-coding-agent-setup 1.0.9 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/agent-browser/SKILL.md +55 -0
- package/.agents/skills/developing-with-streamlit/SKILL.md +220 -0
- package/.agents/skills/developing-with-streamlit/skills/building-streamlit-chat-ui/SKILL.md +195 -0
- package/.agents/skills/developing-with-streamlit/skills/building-streamlit-custom-components-v2/SKILL.md +233 -0
- package/.agents/skills/developing-with-streamlit/skills/building-streamlit-custom-components-v2/references/packaged-components.md +212 -0
- package/.agents/skills/developing-with-streamlit/skills/building-streamlit-custom-components-v2/references/state-sync.md +149 -0
- package/.agents/skills/developing-with-streamlit/skills/building-streamlit-custom-components-v2/references/theme-css-variables.md +243 -0
- package/.agents/skills/developing-with-streamlit/skills/building-streamlit-custom-components-v2/references/troubleshooting.md +121 -0
- package/.agents/skills/developing-with-streamlit/skills/building-streamlit-dashboards/SKILL.md +147 -0
- package/.agents/skills/developing-with-streamlit/skills/building-streamlit-multipage-apps/SKILL.md +218 -0
- package/.agents/skills/developing-with-streamlit/skills/choosing-streamlit-selection-widgets/SKILL.md +139 -0
- package/.agents/skills/developing-with-streamlit/skills/connecting-streamlit-to-snowflake/SKILL.md +188 -0
- package/.agents/skills/developing-with-streamlit/skills/creating-streamlit-themes/SKILL.md +486 -0
- package/.agents/skills/developing-with-streamlit/skills/displaying-streamlit-data/SKILL.md +199 -0
- package/.agents/skills/developing-with-streamlit/skills/improving-streamlit-design/SKILL.md +191 -0
- package/.agents/skills/developing-with-streamlit/skills/optimizing-streamlit-performance/SKILL.md +323 -0
- package/.agents/skills/developing-with-streamlit/skills/organizing-streamlit-code/SKILL.md +91 -0
- package/.agents/skills/developing-with-streamlit/skills/setting-up-streamlit-environment/SKILL.md +128 -0
- package/.agents/skills/developing-with-streamlit/skills/using-streamlit-cli/SKILL.md +165 -0
- package/.agents/skills/developing-with-streamlit/skills/using-streamlit-custom-components/SKILL.md +170 -0
- package/.agents/skills/developing-with-streamlit/skills/using-streamlit-layouts/SKILL.md +229 -0
- package/.agents/skills/developing-with-streamlit/skills/using-streamlit-markdown/SKILL.md +207 -0
- package/.agents/skills/developing-with-streamlit/skills/using-streamlit-session-state/SKILL.md +144 -0
- package/.agents/skills/developing-with-streamlit/templates/.gitattributes +3 -0
- package/.agents/skills/developing-with-streamlit/templates/apps/README.md +188 -0
- package/.agents/skills/developing-with-streamlit/templates/apps/dashboard-companies/pyproject.toml +12 -0
- package/.agents/skills/developing-with-streamlit/templates/apps/dashboard-companies/streamlit_app.py +365 -0
- package/.agents/skills/developing-with-streamlit/templates/apps/dashboard-compute/pyproject.toml +12 -0
- package/.agents/skills/developing-with-streamlit/templates/apps/dashboard-compute/streamlit_app.py +461 -0
- package/.agents/skills/developing-with-streamlit/templates/apps/dashboard-compute-snowflake/.streamlit/secrets.toml.example +20 -0
- package/.agents/skills/developing-with-streamlit/templates/apps/dashboard-compute-snowflake/pyproject.toml +11 -0
- package/.agents/skills/developing-with-streamlit/templates/apps/dashboard-compute-snowflake/snowflake.yml +18 -0
- package/.agents/skills/developing-with-streamlit/templates/apps/dashboard-compute-snowflake/streamlit_app.py +527 -0
- package/.agents/skills/developing-with-streamlit/templates/apps/dashboard-feature-usage/pyproject.toml +12 -0
- package/.agents/skills/developing-with-streamlit/templates/apps/dashboard-feature-usage/streamlit_app.py +307 -0
- package/.agents/skills/developing-with-streamlit/templates/apps/dashboard-metrics/pyproject.toml +12 -0
- package/.agents/skills/developing-with-streamlit/templates/apps/dashboard-metrics/streamlit_app.py +426 -0
- package/.agents/skills/developing-with-streamlit/templates/apps/dashboard-metrics-snowflake/.streamlit/secrets.toml.example +20 -0
- package/.agents/skills/developing-with-streamlit/templates/apps/dashboard-metrics-snowflake/pyproject.toml +11 -0
- package/.agents/skills/developing-with-streamlit/templates/apps/dashboard-metrics-snowflake/snowflake.yml +18 -0
- package/.agents/skills/developing-with-streamlit/templates/apps/dashboard-metrics-snowflake/streamlit_app.py +463 -0
- package/.agents/skills/developing-with-streamlit/templates/apps/dashboard-seattle-weather/pyproject.toml +12 -0
- package/.agents/skills/developing-with-streamlit/templates/apps/dashboard-seattle-weather/streamlit_app.py +252 -0
- package/.agents/skills/developing-with-streamlit/templates/apps/dashboard-stock-peers/pyproject.toml +12 -0
- package/.agents/skills/developing-with-streamlit/templates/apps/dashboard-stock-peers/streamlit_app.py +342 -0
- package/.agents/skills/developing-with-streamlit/templates/apps/dashboard-stock-peers-snowflake/.streamlit/secrets.toml.example +20 -0
- package/.agents/skills/developing-with-streamlit/templates/apps/dashboard-stock-peers-snowflake/pyproject.toml +11 -0
- package/.agents/skills/developing-with-streamlit/templates/apps/dashboard-stock-peers-snowflake/snowflake.yml +18 -0
- package/.agents/skills/developing-with-streamlit/templates/apps/dashboard-stock-peers-snowflake/streamlit_app.py +384 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/README.md +128 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/_configs/dracula.toml +39 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/_configs/github.toml +37 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/_configs/minimal.toml +39 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/_configs/nord.toml +39 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/_configs/snowflake.toml +42 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/_configs/solarized-light.toml +38 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/_configs/spotify.toml +34 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/_configs/stripe.toml +35 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/_shared/streamlit_app.py +336 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/_templates/pyproject.toml.tmpl +12 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/dracula/.streamlit/config.toml +39 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/dracula/pyproject.toml +10 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/dracula/streamlit_app.py +337 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/github/.streamlit/config.toml +37 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/github/pyproject.toml +10 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/github/streamlit_app.py +337 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/manage.py +332 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/minimal/.streamlit/config.toml +39 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/minimal/pyproject.toml +10 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/minimal/streamlit_app.py +337 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/nord/.streamlit/config.toml +39 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/nord/pyproject.toml +10 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/nord/streamlit_app.py +337 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/snowflake/.streamlit/config.toml +42 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/snowflake/pyproject.toml +10 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/snowflake/streamlit_app.py +337 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/solarized-light/.streamlit/config.toml +38 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/solarized-light/pyproject.toml +10 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/solarized-light/streamlit_app.py +337 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/spotify/.streamlit/config.toml +34 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/spotify/pyproject.toml +10 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/spotify/streamlit_app.py +337 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/stripe/.streamlit/config.toml +35 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/stripe/pyproject.toml +10 -0
- package/.agents/skills/developing-with-streamlit/templates/themes/stripe/streamlit_app.py +337 -0
- package/.agents/skills/fastapi/SKILL.md +436 -0
- package/.agents/skills/fastapi/references/dependencies.md +142 -0
- package/.agents/skills/fastapi/references/other-tools.md +76 -0
- package/.agents/skills/fastapi/references/streaming.md +105 -0
- package/.agents/skills/frontend-design/LICENSE.txt +177 -0
- package/.agents/skills/frontend-design/SKILL.md +42 -0
- package/.agents/skills/gradio/SKILL.md +84 -0
- package/.agents/skills/gradio/references/api-signatures.md +115 -0
- package/.agents/skills/gradio/references/event-listeners.md +130 -0
- package/.agents/skills/gradio/references/examples.md +613 -0
- package/.agents/skills/ui-ux-pro-max/SKILL.md +659 -0
- package/.agents/skills/ui-ux-pro-max/data +1 -0
- package/.agents/skills/ui-ux-pro-max/scripts +1 -0
- package/.agents/stack.md +187 -187
- package/.env.axiom +8 -0
- package/AGENTS.md +2 -1
- package/README.md +19 -3
- package/bin/cli.js +11 -1
- package/opencode.json +12 -4
- package/package.json +1 -1
- package/skills-lock.json +36 -0
- package/.agents/skills/n8n-patterns/SKILL.md +0 -272
package/.agents/skills/developing-with-streamlit/templates/apps/dashboard-companies/streamlit_app.py
ADDED
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Company Analytics Dashboard Template
|
|
3
|
+
|
|
4
|
+
A company leaderboard dashboard demonstrating:
|
|
5
|
+
- Interactive dataframe with sparkline columns
|
|
6
|
+
- Segmented control for ranking (top spenders, gainers, shrinkers)
|
|
7
|
+
- Multi-select pills for account type filtering
|
|
8
|
+
- Time window filtering
|
|
9
|
+
- Growth score calculation
|
|
10
|
+
- Dialog popup for company details
|
|
11
|
+
|
|
12
|
+
This template uses synthetic data. Replace generate_company_data()
|
|
13
|
+
with your actual data source (e.g., Snowflake queries, CRM APIs, etc.)
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from datetime import date, timedelta
|
|
17
|
+
import numpy as np
|
|
18
|
+
import pandas as pd
|
|
19
|
+
import streamlit as st
|
|
20
|
+
import altair as alt
|
|
21
|
+
|
|
22
|
+
st.set_page_config(
|
|
23
|
+
page_title="Company Analytics",
|
|
24
|
+
page_icon=":material/business:",
|
|
25
|
+
layout="wide",
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# =============================================================================
|
|
30
|
+
# Synthetic Data Generation (Replace with your data source)
|
|
31
|
+
# =============================================================================
|
|
32
|
+
|
|
33
|
+
COMPANY_NAMES = [
|
|
34
|
+
"Acme Corp", "TechFlow Inc", "DataDriven Co", "CloudFirst Ltd",
|
|
35
|
+
"InnovateTech", "ScaleUp Systems", "PrimeData Inc", "FutureStack",
|
|
36
|
+
"ByteWise Corp", "StreamLine Co", "Quantum Labs", "NexGen Solutions",
|
|
37
|
+
"AlphaMetrics", "BetaAnalytics", "GammaInsights", "DeltaData",
|
|
38
|
+
"OmegaTech", "SigmaSoft", "ThetaCloud", "ZetaDigital",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
ACCOUNT_TYPES = ["Enterprise", "Growth", "Startup", "Trial", "Internal"]
|
|
42
|
+
REGIONS = ["North America", "EMEA", "APAC", "LATAM"]
|
|
43
|
+
SEGMENTS = ["Technology", "Finance", "Healthcare", "Retail", "Manufacturing"]
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@st.cache_data(ttl=3600)
|
|
47
|
+
def generate_company_data(days: int = 90) -> pd.DataFrame:
|
|
48
|
+
"""Generate synthetic company usage data.
|
|
49
|
+
|
|
50
|
+
Replace this function with your actual data source.
|
|
51
|
+
"""
|
|
52
|
+
np.random.seed(42)
|
|
53
|
+
|
|
54
|
+
end_date = date.today() - timedelta(days=1)
|
|
55
|
+
start_date = end_date - timedelta(days=days)
|
|
56
|
+
dates = pd.date_range(start=start_date, end=end_date, freq="D")
|
|
57
|
+
|
|
58
|
+
records = []
|
|
59
|
+
|
|
60
|
+
for company in COMPANY_NAMES:
|
|
61
|
+
# Assign static attributes
|
|
62
|
+
account_type = np.random.choice(ACCOUNT_TYPES, p=[0.3, 0.25, 0.2, 0.15, 0.1])
|
|
63
|
+
region = np.random.choice(REGIONS)
|
|
64
|
+
segment = np.random.choice(SEGMENTS)
|
|
65
|
+
|
|
66
|
+
# Generate usage pattern
|
|
67
|
+
base_usage = np.random.randint(100, 10000)
|
|
68
|
+
growth = np.random.uniform(-0.005, 0.01) # Some companies shrink
|
|
69
|
+
|
|
70
|
+
for i, dt in enumerate(dates):
|
|
71
|
+
# Base trend
|
|
72
|
+
trend = base_usage * (1 + growth) ** i
|
|
73
|
+
|
|
74
|
+
# Weekly seasonality
|
|
75
|
+
if dt.dayofweek >= 5:
|
|
76
|
+
trend *= 0.3
|
|
77
|
+
|
|
78
|
+
# Random noise
|
|
79
|
+
daily_credits = max(0, trend * np.random.uniform(0.7, 1.3))
|
|
80
|
+
|
|
81
|
+
records.append({
|
|
82
|
+
"company_name": company,
|
|
83
|
+
"date": dt,
|
|
84
|
+
"daily_credits": daily_credits,
|
|
85
|
+
"account_type": account_type,
|
|
86
|
+
"region": region,
|
|
87
|
+
"segment": segment,
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
return pd.DataFrame(records)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@st.cache_data(ttl=3600)
|
|
94
|
+
def load_company_data() -> pd.DataFrame:
|
|
95
|
+
"""Load all company data."""
|
|
96
|
+
return generate_company_data(days=90)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def aggregate_companies(
|
|
100
|
+
df: pd.DataFrame,
|
|
101
|
+
days: int | None = None,
|
|
102
|
+
account_types: list[str] | None = None,
|
|
103
|
+
sort_by: str = "total_credits",
|
|
104
|
+
) -> pd.DataFrame:
|
|
105
|
+
"""Filter and aggregate company data."""
|
|
106
|
+
result = df.copy()
|
|
107
|
+
|
|
108
|
+
# Filter by time window
|
|
109
|
+
if days:
|
|
110
|
+
cutoff = pd.Timestamp.now() - pd.Timedelta(days=days)
|
|
111
|
+
result = result[result["date"] >= cutoff]
|
|
112
|
+
|
|
113
|
+
# Filter by account type
|
|
114
|
+
if account_types:
|
|
115
|
+
result = result[result["account_type"].isin(account_types)]
|
|
116
|
+
|
|
117
|
+
if result.empty:
|
|
118
|
+
return pd.DataFrame()
|
|
119
|
+
|
|
120
|
+
# Aggregate to company level
|
|
121
|
+
agg = result.groupby("company_name").agg(
|
|
122
|
+
total_credits=("daily_credits", "sum"),
|
|
123
|
+
active_days=("date", "nunique"),
|
|
124
|
+
account_type=("account_type", "first"),
|
|
125
|
+
region=("region", "first"),
|
|
126
|
+
segment=("segment", "first"),
|
|
127
|
+
).reset_index()
|
|
128
|
+
|
|
129
|
+
# Calculate daily average
|
|
130
|
+
agg["daily_avg"] = agg["total_credits"] / agg["active_days"]
|
|
131
|
+
|
|
132
|
+
# Build sparkline data (list of daily values)
|
|
133
|
+
sparklines = (
|
|
134
|
+
result.groupby("company_name")
|
|
135
|
+
.apply(lambda x: x.sort_values("date")["daily_credits"].tolist())
|
|
136
|
+
.reset_index()
|
|
137
|
+
)
|
|
138
|
+
sparklines.columns = ["company_name", "usage_trend"]
|
|
139
|
+
agg = agg.merge(sparklines, on="company_name")
|
|
140
|
+
|
|
141
|
+
# Calculate growth score (second half vs first half)
|
|
142
|
+
def calc_growth(trend):
|
|
143
|
+
if not trend or len(trend) < 2:
|
|
144
|
+
return 0
|
|
145
|
+
mid = len(trend) // 2
|
|
146
|
+
first_half = sum(trend[:mid]) if mid > 0 else 0
|
|
147
|
+
second_half = sum(trend[mid:])
|
|
148
|
+
return second_half - first_half
|
|
149
|
+
|
|
150
|
+
agg["growth_score"] = agg["usage_trend"].apply(calc_growth)
|
|
151
|
+
|
|
152
|
+
# Sort
|
|
153
|
+
if sort_by == "growth_asc":
|
|
154
|
+
agg = agg.sort_values("growth_score", ascending=True)
|
|
155
|
+
elif sort_by == "growth_desc":
|
|
156
|
+
agg = agg.sort_values("growth_score", ascending=False)
|
|
157
|
+
else:
|
|
158
|
+
agg = agg.sort_values("total_credits", ascending=False)
|
|
159
|
+
|
|
160
|
+
return agg
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
def render_company_dialog(company_name: str, company_row: pd.Series, df: pd.DataFrame):
|
|
164
|
+
"""Render company details inside a dialog."""
|
|
165
|
+
company_data = df[df["company_name"] == company_name].sort_values("date")
|
|
166
|
+
|
|
167
|
+
if company_data.empty:
|
|
168
|
+
st.warning("No data available for this company.")
|
|
169
|
+
return
|
|
170
|
+
|
|
171
|
+
# Company info badges - extract from list format back to single value
|
|
172
|
+
account_type = company_row["account_type"][0] if company_row["account_type"] else "Unknown"
|
|
173
|
+
region = company_row["region"][0] if company_row["region"] else "Unknown"
|
|
174
|
+
segment = company_row["segment"][0] if company_row["segment"] else "Unknown"
|
|
175
|
+
total_credits = company_row["total_credits"]
|
|
176
|
+
|
|
177
|
+
st.markdown(
|
|
178
|
+
f":blue-badge[{account_type}] "
|
|
179
|
+
f":violet-badge[{region}] "
|
|
180
|
+
f":orange-badge[{segment}] "
|
|
181
|
+
f":green-badge[{total_credits:,.0f} credits]"
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
# Summary metrics
|
|
185
|
+
col1, col2, col3 = st.columns(3)
|
|
186
|
+
with col1:
|
|
187
|
+
st.metric("Total Credits", f"{total_credits:,.0f}")
|
|
188
|
+
with col2:
|
|
189
|
+
st.metric("Active Days", f"{company_row['active_days']:,}")
|
|
190
|
+
with col3:
|
|
191
|
+
growth = company_row["growth_score"]
|
|
192
|
+
st.metric("Growth Score", f"{growth:+,.0f}")
|
|
193
|
+
|
|
194
|
+
# Charts
|
|
195
|
+
col1, col2 = st.columns(2)
|
|
196
|
+
|
|
197
|
+
with col1:
|
|
198
|
+
with st.container(border=True):
|
|
199
|
+
st.markdown("**Daily usage**")
|
|
200
|
+
st.line_chart(company_data, x="date", y="daily_credits", height=250)
|
|
201
|
+
|
|
202
|
+
with col2:
|
|
203
|
+
with st.container(border=True):
|
|
204
|
+
st.markdown("**Cumulative usage**")
|
|
205
|
+
chart_data = company_data.copy()
|
|
206
|
+
chart_data["cumulative"] = chart_data["daily_credits"].cumsum()
|
|
207
|
+
st.area_chart(chart_data, x="date", y="cumulative", height=250)
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
# =============================================================================
|
|
211
|
+
# Page Layout
|
|
212
|
+
# =============================================================================
|
|
213
|
+
|
|
214
|
+
# Load data
|
|
215
|
+
all_data = load_company_data()
|
|
216
|
+
|
|
217
|
+
st.markdown("# :material/business: Company Analytics")
|
|
218
|
+
st.caption("Track company adoption - usage, growth trends, and account details.")
|
|
219
|
+
|
|
220
|
+
# Filters
|
|
221
|
+
with st.container(border=True):
|
|
222
|
+
st.markdown("**Filters**")
|
|
223
|
+
|
|
224
|
+
# Company selection mode
|
|
225
|
+
sort_mode = st.segmented_control(
|
|
226
|
+
"Sort by",
|
|
227
|
+
options=[
|
|
228
|
+
"All companies",
|
|
229
|
+
":material/military_tech: Top spenders",
|
|
230
|
+
":material/trending_down: Top shrinkers",
|
|
231
|
+
":material/trending_up: Top gainers",
|
|
232
|
+
],
|
|
233
|
+
default="All companies",
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
# Time window
|
|
237
|
+
timeframe_options = {
|
|
238
|
+
"All time": None,
|
|
239
|
+
"Last 28 days": 28,
|
|
240
|
+
"Last 7 days": 7,
|
|
241
|
+
}
|
|
242
|
+
timeframe = st.segmented_control(
|
|
243
|
+
"Time window",
|
|
244
|
+
options=list(timeframe_options.keys()),
|
|
245
|
+
default="Last 28 days",
|
|
246
|
+
)
|
|
247
|
+
days_filter = timeframe_options.get(timeframe)
|
|
248
|
+
|
|
249
|
+
# Account types
|
|
250
|
+
account_types = st.pills(
|
|
251
|
+
"Account types",
|
|
252
|
+
options=ACCOUNT_TYPES,
|
|
253
|
+
default=["Enterprise", "Growth", "Startup"],
|
|
254
|
+
selection_mode="multi",
|
|
255
|
+
)
|
|
256
|
+
|
|
257
|
+
# Determine sort order
|
|
258
|
+
if "Top shrinkers" in (sort_mode or ""):
|
|
259
|
+
sort_by = "growth_asc"
|
|
260
|
+
elif "Top gainers" in (sort_mode or ""):
|
|
261
|
+
sort_by = "growth_desc"
|
|
262
|
+
else:
|
|
263
|
+
sort_by = "total_credits"
|
|
264
|
+
|
|
265
|
+
# Get filtered data
|
|
266
|
+
leaderboard = aggregate_companies(
|
|
267
|
+
all_data,
|
|
268
|
+
days=days_filter,
|
|
269
|
+
account_types=account_types,
|
|
270
|
+
sort_by=sort_by,
|
|
271
|
+
)
|
|
272
|
+
|
|
273
|
+
if leaderboard.empty:
|
|
274
|
+
st.warning("No company data found for the selected filters.")
|
|
275
|
+
st.stop()
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
def _to_list(val):
|
|
279
|
+
"""Convert a single value to a list for MultiselectColumn display."""
|
|
280
|
+
return [val] if pd.notna(val) else []
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
# Convert columns to lists for MultiselectColumn display (shows nice colored chips)
|
|
284
|
+
for col in ["account_type", "region", "segment"]:
|
|
285
|
+
leaderboard[col] = leaderboard[col].apply(_to_list)
|
|
286
|
+
|
|
287
|
+
# Companies dataframe
|
|
288
|
+
with st.container(border=True):
|
|
289
|
+
timeframe_text = timeframe.lower() if timeframe != "All time" else "all time"
|
|
290
|
+
st.markdown(f"**Companies — {timeframe_text}**")
|
|
291
|
+
|
|
292
|
+
# Selection dataframe with cell-click support
|
|
293
|
+
selection = st.dataframe(
|
|
294
|
+
leaderboard,
|
|
295
|
+
column_config={
|
|
296
|
+
"company_name": st.column_config.TextColumn(
|
|
297
|
+
"Company (👋 click to view details)",
|
|
298
|
+
width="medium",
|
|
299
|
+
),
|
|
300
|
+
"account_type": st.column_config.MultiselectColumn(
|
|
301
|
+
"Type",
|
|
302
|
+
options=ACCOUNT_TYPES,
|
|
303
|
+
color="auto",
|
|
304
|
+
width="small",
|
|
305
|
+
),
|
|
306
|
+
"total_credits": st.column_config.NumberColumn(
|
|
307
|
+
"Credits",
|
|
308
|
+
format="%.0f",
|
|
309
|
+
),
|
|
310
|
+
"growth_score": st.column_config.NumberColumn(
|
|
311
|
+
"Growth",
|
|
312
|
+
format="%+.0f",
|
|
313
|
+
help="Credit change: second half vs first half of period",
|
|
314
|
+
),
|
|
315
|
+
"usage_trend": st.column_config.LineChartColumn(
|
|
316
|
+
"Trend",
|
|
317
|
+
width="medium",
|
|
318
|
+
),
|
|
319
|
+
"daily_avg": st.column_config.NumberColumn(
|
|
320
|
+
"Daily Avg",
|
|
321
|
+
format="%.1f",
|
|
322
|
+
),
|
|
323
|
+
"active_days": st.column_config.NumberColumn(
|
|
324
|
+
"Active Days",
|
|
325
|
+
format="%d",
|
|
326
|
+
),
|
|
327
|
+
"region": st.column_config.MultiselectColumn(
|
|
328
|
+
"Region",
|
|
329
|
+
options=REGIONS,
|
|
330
|
+
color="auto",
|
|
331
|
+
),
|
|
332
|
+
"segment": st.column_config.MultiselectColumn(
|
|
333
|
+
"Segment",
|
|
334
|
+
options=SEGMENTS,
|
|
335
|
+
color="auto",
|
|
336
|
+
),
|
|
337
|
+
},
|
|
338
|
+
column_order=[
|
|
339
|
+
"company_name", "account_type", "total_credits", "growth_score",
|
|
340
|
+
"usage_trend", "daily_avg", "region", "segment",
|
|
341
|
+
],
|
|
342
|
+
hide_index=True,
|
|
343
|
+
on_select="rerun",
|
|
344
|
+
selection_mode="single-cell",
|
|
345
|
+
key="company_leaderboard",
|
|
346
|
+
)
|
|
347
|
+
|
|
348
|
+
# Company drill-down via dialog when Company column cell is clicked
|
|
349
|
+
if selection.selection.cells:
|
|
350
|
+
cell = selection.selection.cells[0] # tuple: (row_index, column_name)
|
|
351
|
+
row_idx, col_name = cell
|
|
352
|
+
# Check if the clicked cell is in the company_name column
|
|
353
|
+
if col_name == "company_name":
|
|
354
|
+
selected_company = leaderboard.iloc[row_idx]["company_name"]
|
|
355
|
+
company_row = leaderboard.iloc[row_idx]
|
|
356
|
+
|
|
357
|
+
@st.dialog(f"{selected_company}", width="large")
|
|
358
|
+
def show_company_dialog():
|
|
359
|
+
render_company_dialog(
|
|
360
|
+
selected_company,
|
|
361
|
+
company_row=company_row,
|
|
362
|
+
df=all_data,
|
|
363
|
+
)
|
|
364
|
+
|
|
365
|
+
show_company_dialog()
|
package/.agents/skills/developing-with-streamlit/templates/apps/dashboard-compute/pyproject.toml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "dashboard-compute"
|
|
3
|
+
version = "1.0.0"
|
|
4
|
+
description = "A compute/resource consumption dashboard with multiple metric breakdowns"
|
|
5
|
+
requires-python = ">=3.11"
|
|
6
|
+
dependencies = [
|
|
7
|
+
"altair>=5.5.0",
|
|
8
|
+
"numpy>=1.26.0",
|
|
9
|
+
"pandas>=2.2.3",
|
|
10
|
+
"snowflake-connector-python>=3.3.0",
|
|
11
|
+
"streamlit[snowflake]>=1.54.0",
|
|
12
|
+
]
|