from __future__ import annotations import streamlit as st from src.charts import demand_chart, retrieval_mode_donut from src.data import schema_report from src.ui import callout, section_title class OverviewViewMixin: """Overview and dataset-health page.""" def _page_overview(self) -> None: section_title("Overview", "Fast read for quality posture, data coverage, and immediate investigation targets.") left, right = st.columns([1.12, 0.88], gap="large") with left: self._plot(demand_chart(self.ctx.demand_coverage), "overview_demand") with right: self._plot(retrieval_mode_donut(self.ctx.retrieval_outcomes), "overview_outcomes") section_title("Top risk slices", "Ranked by error, hallucination exposure, and retrieval weakness.") if self.ctx.risk_slices.empty: callout("warn", "No eligible risk slices", "Try lowering the minimum slice size in the sidebar.") else: show_cols = [ c for c in ["domain", "scenario_type", "difficulty", "n", "correct_rate", "hallucination_rate", "recall_at_10", "risk_score"] if c in self.ctx.risk_slices.columns ] st.dataframe(self.ctx.risk_slices[show_cols].head(15), use_container_width=True, hide_index=True) section_title("Dataset health", "Schema coverage and table inventory.") st.dataframe(schema_report(self.data), use_container_width=True, hide_index=True)