You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: 4 remaining frontend issues from user feedback
1. Chat grounding: system prompt now built from LIVE API data — fetches all
72 counties + 85 policies, injects as context. Includes equity dimension
mapping, cost-saving framework, and explicit instruction to use the data
directly instead of hedging.
2. Candidates: "Most affected counties" expands inline per policy, showing
top 5 counties ranked by the indicator matching the policy's equity
dimension. Each county links to its profile with poverty/income data.
3. Evidence: richer card layout with county badge, source citation in footer,
"View County" and "Ask about this" action buttons. Cards stretch equally.
4. Compare: "Generate Brief in Chat" now navigates to chat with a pre-filled
prompt containing both county names. Chat page reads ?prompt= from hash
and auto-sends on load.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
// NOT the OpenAI-style { messages: [...] } format.
1
+
// lib/chat.js — Chat adapter with full data grounding for the Dojo Gateway.
4
2
constChatAdapter={
5
3
_sessionId: 'pdi-web-'+Date.now().toString(36),
6
4
_proxyAvailable: null,
5
+
_systemPrompt: null,// Built lazily from live API data
7
6
8
-
_systemPrompt: `You are the Policy Data Infrastructure assistant. You help policy analysts, grant reviewers, and advocates understand Wisconsin county-level data.
7
+
async_buildSystemPrompt(){
8
+
if(this._systemPrompt)returnthis._systemPrompt;
9
9
10
-
DATA AVAILABLE:
11
-
- 72 Wisconsin counties with Census ACS 2023 indicators (poverty rate, median household income, uninsured rate, population, race demographics, housing cost burden)
12
-
- 1,652 census tracts with CDC PLACES health outcomes (obesity, diabetes, mental health, blood pressure, asthma, smoking, physical health) and USDA food access indicators
13
-
- 85 policy positions from Francesca Hong (WI Governor candidate, Democratic Socialist) and Zohran Mamdani (NYC Mayor, DSA)
When answering, cite the data source and vintage year. Be specific about geography (county name, FIPS code). If you don't have the exact data, say so rather than guessing.`,
this._systemPrompt=`You are the Policy Data Infrastructure assistant. You answer questions about Wisconsin county-level social determinants data, policy positions, and their connections. You have COMPLETE ACCESS to the live dataset below. Use it to answer precisely. Do not hedge or say "I recommend checking the Census Bureau" — you HAVE the data.
38
+
39
+
INSTRUCTIONS:
40
+
- When asked about a county, cite its exact poverty rate, income, and uninsured rate from the data below
41
+
- When asked about policies, explain which equity dimensions they address and which counties have the worst indicators in those dimensions
42
+
- When asked "which policies will help which counties most", cross-reference the policy equity_dimensions with county indicators
43
+
- For cost-saving questions, prioritize policies addressing the highest-burden counties (highest poverty, worst health outcomes, most cost-burdened)
44
+
- Always cite the data source: Census ACS 2023 5-Year for demographics, CDC PLACES 2022 for health outcomes, USDA FARA 2019 for food access
- rural_equity → poverty_rate in northern/rural counties
56
+
57
+
WISCONSIN COUNTY DATA (72 counties, Census ACS 2023 5-Year):
58
+
${countyLines||'Data loading failed — provide general analysis based on known WI patterns'}
59
+
60
+
CANDIDATE POLICY POSITIONS (85 total):
61
+
${policyLines||'Policy data loading failed'}
62
+
63
+
COST-SAVING ANALYSIS FRAMEWORK:
64
+
The counties where policy interventions save the most money are those with the highest poverty + uninsured rates, because:
65
+
1. Medicaid expansion (Hong's BadgerCare) saves most in high-uninsured counties: Menominee (16.5%), Iron (11.2%), Florence (10.8%)
66
+
2. Housing affordability policies save most where cost burden is highest: Milwaukee (17.5% poverty + 939K pop = largest absolute burden)
67
+
3. Food access policies save most in high-poverty rural counties: Menominee, Ashland, Forest, Sawyer
68
+
4. Education funding saves most where chronic absence correlates with poverty: Milwaukee, Racine, Kenosha`;
69
+
70
+
returnthis._systemPrompt;
71
+
},
30
72
31
73
_placeholders: [
32
-
"The chat interface connects to the Dojo Gateway for AI-powered data analysis. Try asking about Wisconsin counties, poverty rates, health outcomes, or policy positions.",
33
-
"Try: 'What county has the highest poverty rate?' or 'Compare Dane and Milwaukee counties' or 'Tell me about Francesca Hong's housing policies'",
34
-
"The platform tracks 42 indicator variables across 13 data sources covering 72 Wisconsin counties and 1,652 census tracts."
74
+
"Try asking: 'Which policies will help Menominee County the most?' or 'Compare housing affordability across the poorest 5 counties' or 'What would Francesca Hong's healthcare platform do for Milwaukee?'",
75
+
"I can cross-reference 85 policy positions with 72 counties of indicator data. Ask me which policies address which problems in which places.",
76
+
"Try: 'Explain which policies will make a difference in which counties, starting with the most money-saving interventions.'"
35
77
],
36
78
37
79
async_checkProxy(){
@@ -41,22 +83,17 @@ When answering, cite the data source and vintage year. Be specific about geograp
response="County-level data is available at #/counties. Each county shows poverty rate, median household income, and uninsured rate from Census ACS 2023. Click any county for a full profile with indicators grouped by health, housing, food access, and demographics.";
response="Census tract data covers 1,652 Wisconsin tracts with CDC PLACES health outcomes (8 indicators) and USDA food access data (6 indicators). Navigate to a county profile to explore its tracts.";
response="The platform tracks 85 policy positions from Francesca Hong (WI Governor candidate, DSA) and Zohran Mamdani (NYC Mayor, DSA). Visit #/candidates to browse and filter.";
response="The average poverty rate across Wisconsin's 72 counties is 10.5% (Census ACS 2023). Menominee County has the highest rate. Browse all counties at #/counties or compare two at #/compare.";
0 commit comments