|
| 1 | +// Pre-calculated Queryless answers used to simulate an AI response for the |
| 2 | +// home-page suggested-question chips. Clicking one of these chips opens the |
| 3 | +// assistant, shows the "Thinking..." indicator for a moment, and then renders |
| 4 | +// the matching canned answer below — no real API request is made. |
| 5 | +// |
| 6 | +// The map is keyed by the exact prompt text shown on the chip, so |
| 7 | +// QUERYLESS_SUGGESTED_PROMPTS is the single source of truth: the home page |
| 8 | +// renders these strings as chips and the assistant looks the answer up by the |
| 9 | +// same string. |
| 10 | + |
| 11 | +const TEMPERATURE_ANSWER = `Global surface temperatures have warmed markedly since 1980. Compared with the 20th-century average, the annual temperature anomaly has risen from roughly **+0.3 °C** in 1980 to about **+1.2 °C** in 2023 — a gain of nearly a full degree in just over four decades, with the steepest warming after 2000. |
| 12 | +
|
| 13 | +\`\`\`chart |
| 14 | +{ |
| 15 | + "title": "Global temperature anomaly since 1980", |
| 16 | + "mark": {"type": "line", "point": true, "color": "#e11d48"}, |
| 17 | + "data": { |
| 18 | + "values": [ |
| 19 | + {"year": 1980, "anomaly": 0.28}, |
| 20 | + {"year": 1985, "anomaly": 0.14}, |
| 21 | + {"year": 1990, "anomaly": 0.45}, |
| 22 | + {"year": 1995, "anomaly": 0.46}, |
| 23 | + {"year": 2000, "anomaly": 0.42}, |
| 24 | + {"year": 2005, "anomaly": 0.69}, |
| 25 | + {"year": 2010, "anomaly": 0.72}, |
| 26 | + {"year": 2015, "anomaly": 0.90}, |
| 27 | + {"year": 2020, "anomaly": 1.02}, |
| 28 | + {"year": 2023, "anomaly": 1.17} |
| 29 | + ] |
| 30 | + }, |
| 31 | + "encoding": { |
| 32 | + "x": {"field": "year", "type": "quantitative", "title": "Year", "axis": {"format": "d"}}, |
| 33 | + "y": {"field": "anomaly", "type": "quantitative", "title": "Temp anomaly (°C)"} |
| 34 | + } |
| 35 | +} |
| 36 | +\`\`\` |
| 37 | +
|
| 38 | +The warming is not steady year to year, but the long-term trend is unmistakable and accelerating. |
| 39 | +
|
| 40 | +[[QUERYLESS_METHOD]] |
| 41 | +Values are global land–ocean temperature anomalies relative to the 1901–2000 mean, sampled at five-year intervals (plus the latest year). Figures are illustrative of the widely reported GISTEMP/HadCRUT records. |
| 42 | +[[/QUERYLESS_METHOD]]`; |
| 43 | + |
| 44 | +const CO2_ANSWER = `Atmospheric CO₂ has risen steadily since 2000. Measured at Mauna Loa, the annual mean climbed from about **369 ppm** in 2000 to roughly **421 ppm** in 2023 — an increase of more than **50 ppm** (about 14%) in a little over two decades, with the yearly rise itself getting faster. |
| 45 | +
|
| 46 | +\`\`\`chart |
| 47 | +{ |
| 48 | + "title": "Atmospheric CO₂ concentration since 2000 (ppm)", |
| 49 | + "mark": {"type": "line", "point": true, "color": "#0f766e"}, |
| 50 | + "data": { |
| 51 | + "values": [ |
| 52 | + {"year": 2000, "ppm": 369.5}, |
| 53 | + {"year": 2003, "ppm": 375.8}, |
| 54 | + {"year": 2006, "ppm": 381.9}, |
| 55 | + {"year": 2009, "ppm": 387.4}, |
| 56 | + {"year": 2012, "ppm": 393.8}, |
| 57 | + {"year": 2015, "ppm": 400.8}, |
| 58 | + {"year": 2018, "ppm": 408.5}, |
| 59 | + {"year": 2021, "ppm": 416.4}, |
| 60 | + {"year": 2023, "ppm": 421.1} |
| 61 | + ] |
| 62 | + }, |
| 63 | + "encoding": { |
| 64 | + "x": {"field": "year", "type": "quantitative", "title": "Year", "axis": {"format": "d"}}, |
| 65 | + "y": {"field": "ppm", "type": "quantitative", "title": "CO₂ (ppm)", "scale": {"zero": false}} |
| 66 | + } |
| 67 | +} |
| 68 | +\`\`\` |
| 69 | +
|
| 70 | +The trend line is remarkably smooth — annual growth has averaged around 2 ppm per year and shows no sign of slowing. |
| 71 | +
|
| 72 | +[[QUERYLESS_METHOD]] |
| 73 | +Values are annual mean atmospheric CO₂ concentrations in parts per million, in the style of the NOAA Mauna Loa (Keeling Curve) record, sampled at three-year intervals plus the latest year. Figures are illustrative. |
| 74 | +[[/QUERYLESS_METHOD]]`; |
| 75 | + |
| 76 | +const PHARMA_ANSWER = `Pharmaceutical spending per capita is highest in the United States by a wide margin, followed by other high-income economies. On a per-person basis, the **United States** spends roughly **$1,430 per year** on pharmaceuticals — well ahead of Switzerland, Germany and Japan. |
| 77 | +
|
| 78 | +\`\`\`chart |
| 79 | +{ |
| 80 | + "title": "Pharmaceutical spending per capita (USD/year)", |
| 81 | + "mark": {"type": "bar", "color": "#4f46e5"}, |
| 82 | + "data": { |
| 83 | + "values": [ |
| 84 | + {"country": "United States", "spend": 1432}, |
| 85 | + {"country": "Switzerland", "spend": 963}, |
| 86 | + {"country": "Germany", "spend": 884}, |
| 87 | + {"country": "Japan", "spend": 817}, |
| 88 | + {"country": "Canada", "spend": 790}, |
| 89 | + {"country": "France", "spend": 646}, |
| 90 | + {"country": "Italy", "spend": 592}, |
| 91 | + {"country": "United Kingdom", "spend": 497} |
| 92 | + ] |
| 93 | + }, |
| 94 | + "encoding": { |
| 95 | + "y": {"field": "country", "type": "nominal", "title": null, "sort": "-x"}, |
| 96 | + "x": {"field": "spend", "type": "quantitative", "title": "USD per capita"} |
| 97 | + } |
| 98 | +} |
| 99 | +\`\`\` |
| 100 | +
|
| 101 | +The gap between the US and the next-highest spenders is striking — reflecting both higher drug prices and higher utilisation. |
| 102 | +
|
| 103 | +[[QUERYLESS_METHOD]] |
| 104 | +Values are illustrative annual pharmaceutical expenditure per capita in US dollars, in the style of OECD Health Statistics. Countries are sorted from highest to lowest spend. |
| 105 | +[[/QUERYLESS_METHOD]]`; |
| 106 | + |
| 107 | +export const QUERYLESS_CANNED_RESPONSES: Record<string, string> = { |
| 108 | + "How has global temperature changed since 1980?": TEMPERATURE_ANSWER, |
| 109 | + "Compare atmospheric CO2 trends since 2000": CO2_ANSWER, |
| 110 | + "Which countries spend most on pharmaceuticals?": PHARMA_ANSWER, |
| 111 | +}; |
| 112 | + |
| 113 | +// Order matters: this is the exact list rendered as home-page chips. |
| 114 | +export const QUERYLESS_SUGGESTED_PROMPTS = Object.keys(QUERYLESS_CANNED_RESPONSES); |
| 115 | + |
| 116 | +export function getCannedResponse(prompt: string): string | null { |
| 117 | + return QUERYLESS_CANNED_RESPONSES[prompt.trim()] ?? null; |
| 118 | +} |
0 commit comments