Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -210,7 +210,7 @@ def load_kpis() -> Dict[str, Any]:
|
|
| 210 |
# AI DASHBOARD -- LLM picks what to display
|
| 211 |
# =========================================================
|
| 212 |
|
| 213 |
-
DASHBOARD_SYSTEM = """You are an AI dashboard assistant for a
|
| 214 |
The user asks questions or requests about their data. You have access to pre-computed
|
| 215 |
artifacts from a Python analysis pipeline.
|
| 216 |
|
|
@@ -381,7 +381,7 @@ def _keyword_fallback(msg: str, idx: Dict, kpis: Dict) -> Tuple[str, Dict]:
|
|
| 381 |
if kpis:
|
| 382 |
total = kpis.get("total_units_sold", 0)
|
| 383 |
kpi_text = (
|
| 384 |
-
f"Quick summary: **{kpis.get('n_titles', '?')}**
|
| 385 |
f"**{kpis.get('n_months', '?')}** months, with **{total:,.0f}** total units sold."
|
| 386 |
)
|
| 387 |
|
|
@@ -393,7 +393,7 @@ def _keyword_fallback(msg: str, idx: Dict, kpis: Dict) -> Tuple[str, Dict]:
|
|
| 393 |
|
| 394 |
if any(w in msg_lower for w in ["sentiment", "review", "positive", "negative"]):
|
| 395 |
return (
|
| 396 |
-
f"Here is the sentiment distribution across sampled
|
| 397 |
{"show": "figure", "chart": "sentiment"},
|
| 398 |
)
|
| 399 |
|
|
@@ -465,7 +465,7 @@ def render_kpi_cards() -> str:
|
|
| 465 |
</div>"""
|
| 466 |
|
| 467 |
kpi_config = [
|
| 468 |
-
("n_titles", "π", "
|
| 469 |
("n_months", "π
", "Time Periods", "#7aa6f8"),
|
| 470 |
("total_units_sold", "π¦", "Units Sold", "#6ee7c7"),
|
| 471 |
("total_revenue", "π°", "Revenue", "#3dcba8"),
|
|
@@ -575,7 +575,7 @@ def build_sentiment_chart() -> go.Figure:
|
|
| 575 |
))
|
| 576 |
fig.update_layout(**_styled_layout(
|
| 577 |
height=max(400, len(df) * 28), barmode="stack",
|
| 578 |
-
title=dict(text="Sentiment Distribution by
|
| 579 |
))
|
| 580 |
fig.update_xaxes(title="Number of Reviews")
|
| 581 |
fig.update_yaxes(autorange="reversed")
|
|
@@ -621,11 +621,11 @@ def load_css() -> str:
|
|
| 621 |
with gr.Blocks(title="AIBDM 2026 Workshop App") as demo:
|
| 622 |
|
| 623 |
gr.Markdown(
|
| 624 |
-
"#
|
| 625 |
-
"*
|
| 626 |
elem_id="escp_title",
|
| 627 |
)
|
| 628 |
-
|
| 629 |
# ===========================================================
|
| 630 |
# TAB 1 -- Pipeline Runner
|
| 631 |
# ===========================================================
|
|
|
|
| 210 |
# AI DASHBOARD -- LLM picks what to display
|
| 211 |
# =========================================================
|
| 212 |
|
| 213 |
+
DASHBOARD_SYSTEM = """You are an AI dashboard assistant for a wine-sales analytics app.
|
| 214 |
The user asks questions or requests about their data. You have access to pre-computed
|
| 215 |
artifacts from a Python analysis pipeline.
|
| 216 |
|
|
|
|
| 381 |
if kpis:
|
| 382 |
total = kpis.get("total_units_sold", 0)
|
| 383 |
kpi_text = (
|
| 384 |
+
f"Quick summary: **{kpis.get('n_titles', '?')}** wine titles across "
|
| 385 |
f"**{kpis.get('n_months', '?')}** months, with **{total:,.0f}** total units sold."
|
| 386 |
)
|
| 387 |
|
|
|
|
| 393 |
|
| 394 |
if any(w in msg_lower for w in ["sentiment", "review", "positive", "negative"]):
|
| 395 |
return (
|
| 396 |
+
f"Here is the sentiment distribution across sampled wine titles. {kpi_text}",
|
| 397 |
{"show": "figure", "chart": "sentiment"},
|
| 398 |
)
|
| 399 |
|
|
|
|
| 465 |
</div>"""
|
| 466 |
|
| 467 |
kpi_config = [
|
| 468 |
+
("n_titles", "π", "wine Titles", "#a48de8"),
|
| 469 |
("n_months", "π
", "Time Periods", "#7aa6f8"),
|
| 470 |
("total_units_sold", "π¦", "Units Sold", "#6ee7c7"),
|
| 471 |
("total_revenue", "π°", "Revenue", "#3dcba8"),
|
|
|
|
| 575 |
))
|
| 576 |
fig.update_layout(**_styled_layout(
|
| 577 |
height=max(400, len(df) * 28), barmode="stack",
|
| 578 |
+
title=dict(text="Sentiment Distribution by wine"),
|
| 579 |
))
|
| 580 |
fig.update_xaxes(title="Number of Reviews")
|
| 581 |
fig.update_yaxes(autorange="reversed")
|
|
|
|
| 621 |
with gr.Blocks(title="AIBDM 2026 Workshop App") as demo:
|
| 622 |
|
| 623 |
gr.Markdown(
|
| 624 |
+
"# Wine Pricing Analytics\n"
|
| 625 |
+
"*AI-enhanced wine pricing optimization dashboard*",
|
| 626 |
elem_id="escp_title",
|
| 627 |
)
|
| 628 |
+
,
|
| 629 |
# ===========================================================
|
| 630 |
# TAB 1 -- Pipeline Runner
|
| 631 |
# ===========================================================
|