"""RAG source list rendering (used by Retrieve stage).""" import html as _html from data.demo import SOURCES as DEMO_SOURCES TYPE_COLORS = { "medical": "#3B82F6", "research": "#A78BFA", "forum": "#F59E0B", "reference": "#06B6D4", "news": "#F97316", "educational": "#34D399", } def _render_source_rows(sources): rows = [] for i, s in enumerate(sources): label = _html.escape(str(s.get("label", ""))) stype = str(s.get("type", "reference")) color = TYPE_COLORS.get(stype, "#64748B") try: relevance = float(s.get("relevance", 0)) except (TypeError, ValueError): relevance = 0.0 pct = int(round(relevance * 100)) bar_width = max(5, pct) delay = 150 + i * 120 rows.append(f"""
Each source lives near your prompt in vector space. Proximity = relevance.