PageSourceSearch

https://askakil.ai/assets/SchoolChat-Cb4Dkbon.js

js askakil.ai collected 2026-10-05 11:52:33 UTC 15,630 bytes, 13 lines download raw bytes

1import{r as n,j as e}from"./index-Dpy3xW5J.js";import{G as pe,x as fe,s as ce,z as me,C as be}from"./discovery-Du8vmb5T.js";import{r as le}from"./SchoolExplorer-BUn40l-5.js";import{M as xe,r as ge}from"./index-2zZQYxaQ.js";import"./useSchoolDataset-Dqu-P8-H.js";import"./storyData-CO7nDpmC.js";const de="/mcp#connect",ye="https://mcp.askakil.ai/mcp",ve="This question needs NYC records beyond this school explorer. Connect Akil to your own AI assistant to check the available sources and continue your research.",je=[/\b(?:city\s+)?council\s*(?:member|woman|man|person|district|funding|representative)s?\b/i,/\b(?:community\s+(?:board|district)s?|borough\s+president|mayor|elected\s+(?:official|representative)s?)\b/i,/\b(?:311|3-1-1|nypd|police\s+(?:chief|commissioner|commander|precinct|captain)|precincts?|crime\s+(?:data|rates?|reports?|statistics))\b/i,/\b(?:housing|zoning|rezoning|land\s+use|evictions?|property\s+(?:tax|values?|records?|owners?)|building\s+(?:permits?|violations?)|hpd|dob\s+permits?)\b/i,/\b(?:restaurants?|liquor\s+licenses?|business\s+(?:openings?|licenses?)|nonprofits?|lobbying|campaign\s+(?:finance|contributions?)|city\s+(?:budget|contracts?|spending)|government\s+grants?)\b/i,/\b(?:connect|use|access|set\s*up)\b.{0,60}\b(?:mcp|my\s+(?:own\s+)?(?:ai|claude|chatgpt))\b/i];function U(c){const S=c.normalize("NFKC").replace(/[’‘]/g,"'").replace(/\b(?:(?:p\.?\s*s\.?|m\.?\s*s\.?|j\.?\s*h\.?\s*s\.?|school|grade)\s*0?311|0?311\s+(?:students|pupils|schools))\b/gi,"school");return je.some(u=>u.test(S))}function ke(c,o){return`Help me explore this question using Akil's NYC public records.
2
3Question: ${c}
4
5School explorer context (not evidence of a civic boundary or cause):
6${o}
7
8Akil MCP endpoint: ${ye}
9If Akil is not connected, help me configure it in a supported client and let me complete authorization. Verify a real read-only request before saying it is connected. Check available sources and dates before answering. School districts, Council districts, community boards, and precincts are different boundaries. Cite records and distinguish findings from possible explanations.`}function Ae({question:c,context:o,noAiCall:S=!1}){const[u,k]=n.useState(""),g=n.useRef(null),l=n.useRef(null),h=n.useId(),y=ke(c,o);async function v(){try{await navigator.clipboard.writeText(y),k("Copied. Paste into your AI assistant after connecting Akil.")}catch{g.current&&(g.current.open=!0),l.current?.focus(),l.current?.select(),k("Copy is unavailable. Select and copy the prompt below.")}}return e.jsxs("section",{className:"sc-handoff","aria-label":"Continue with your own AI",children:[e.jsx("h3",{children:"Explore more NYC data with your own AI"}),e.jsx("p",{children:"Use Akil MCP in a supported AI app to explore Council districts, community boards, housing, 311, and other public records. Available answers depend on source coverage."}),e.jsxs("div",{className:"sc-handoff-actions",children:[e.jsx("a",{href:de,target:"_blank",rel:"noopener noreferrer",children:"Connect your AI ↗"}),e.jsx("button",{type:"button",onClick:()=>void v(),children:"Copy question & context"})]}),e.jsx("p",{className:"sc-note",children:"Your AI app’s plan and usage limits apply. Continuing there does not use this school chat’s AI allowance."}),S&&e.jsx("p",{className:"sc-note",children:"This handoff did not use an AI request."}),e.jsx("p",{role:"status",className:"sc-copy-status",children:u}),e.jsxs("details",{ref:g,children:[e.jsx("summary",{children:"Review the prompt before copying"}),e.jsx("label",{htmlFor:h,children:"Question and public school context"}),e.jsx("textarea",{id:h,ref:l,readOnly:!0,value:y,rows:7})]})]})}const ue="https://akil-school-chat.jiewhoon.workers.dev",Ce=["Compare enrollment across all five boroughs.","What changed at MS74 in Queens?","Which schools in this area gained the most students?"];function we(c){try{const o=new URL(c);return o.protocol==="https:"&&!o.username&&!o.password}catch{return!1}}function Re({data:c,state:o,onNavigate:S}){const u=n.useRef(null),k=n.useRef(null),g=n.useRef(null),l=n.useRef(null),h=n.useRef(null),y=n.useRef(!0),v=n.useRef(!1),[d,F]=n.useState(!1),[p,q]=n.useState(""),[i,R]=n.useState([]),[A,H]=n.useState(!1),[P,f]=n.useState(""),[W,$]=n.useState(""),[K,D]=n.useState(""),[m,M]=n.useState(null),[L,Q]=n.useState(""),[b,C]=n.useState(""),[G,J]=n.useState(!1),V=n.useRef(null),X=n.useRef(!1);n.useEffect(()=>{X.current&&!d&&k.current?.focus({preventScroll:!0}),X.current=d},[d]),n.useEffect(()=>()=>h.current?.abort(),[]),n.useEffect(()=>{if(!d)return;const s=new AbortController;return M(null),fetch(`${ue}/health`,{signal:s.signal}).then(t=>{if(!t.ok)throw Error();return t.json()}).then(t=>{M(t.ready===!0),Q(t.model||"")}).catch(t=>{t.name!=="AbortError"&&M(!1)}),()=>s.abort()},[d]),n.useEffect(()=>{!d||!u.current?.open||!b||m===null&&!U(b)||(C(""),m||U(b)?I(b):le({kind:"chat_attempt",text:b},o))},[d,m,b]),n.useEffect(()=>{d&&i.length&&y.current&&l.current&&(l.current.scrollTop=l.current.scrollHeight)},[i,P,d,W]);const O=c.schools.find(s=>s.id===o.school),Z=`${O?.name||fe(c,o)} · School years ${ce(o.start)} to ${ce(o.end)} · ${pe[o.grade]} · ${me(o.sector)}${o.population==="small"?" · small schools (under 200 students)":""}`,ee=`${Z}${O?`
10School ID: ${O.id}; borough: ${O.borough}`:""}
11Snapshot: ${c.version}
12Explorer: https://askakil.ai/schools?${be(o)}`;function B(){C(""),u.current?.close()}function se(s=!1){C(s&&!v.current?p.trim():""),M(null),u.current?.showModal(),F(!0),requestAnimationFrame(()=>{!i.length&&l.current&&(l.current.scrollTop=0),g.current?.focus({preventScroll:!0})})}function te(){h.current?.abort(),v.current=!1,H(!1),f("Stopped. You can ask another question.")}function he(){te(),C(""),R([]),$(""),D(""),q(""),f(""),g.current?.focus()}async function I(s){const t=s.trim();if(!t||v.current)return;if(U(t)){le({kind:"handoff",text:t},o),y.current=!0,R(r=>[...r,{id:crypto.randomUUID(),role:"user",content:t},{id:crypto.randomUUID(),role:"assistant",content:ve,complete:!0,handoff:!0,noAiCall:!0,question:t,context:ee}]),q(""),$(""),D(""),f("Connection guide ready. No AI request used.");return}if(m!==!0)return;v.current=!0,y.current=!0;const j=[];for(let r=0;r<i.length-1;r++)i[r].role==="user"&&i[r+1].role==="assistant"&&i[r+1].complete&&!i[r+1].handoff&&(j.push({role:"user",content:i[r].content}
12,{role:"assistant",content:i[r+1].content.slice(0,7900)}),r++);const Y=j.slice(-10);for(;Y.reduce((r,x)=>r+x.content.length,0)>14e3;)Y.splice(0,2);const z={id:crypto.randomUUID(),role:"user",content:t},ne={id:crypto.randomUUID(),role:"assistant",content:"",sources:[],actions:[],question:t,context:ee};R(r=>[...r,z,ne]),q(""),H(!0),$(""),D(""),f("Looking at your question…");const E=new AbortController;h.current=E;let re=!1;const T=r=>R(x=>x.map(w=>w.id===ne.id?{...w,...r}:w));try{const r=await fetch(`${ue}/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:[...Y,{role:"user",content:t}],context:o}),signal:E.signal});if(!r.ok){const a=await r.json().catch(()=>({}));throw Error(a.error||"The chat is temporarily unavailable. Please try again.")}const x=r.body?.getReader();if(!x)throw Error("The answer stream is unavailable.");const w=new TextDecoder;let N="",oe="";const ae=a=>{if(a.type==="text"&&typeof a.text=="string"&&(oe+=a.text,T({content:oe}),f("Writing the answer…")),a.type==="status"&&f(a.message||"Checking the data…"),a.type==="evidence"&&T({sources:(a.sources||[]).filter(_=>we(_.url)),actions:a.actions||[]}),a.type==="handoff"&&T({handoff:!0,noAiCall:a.noAiCall===!0}),a.type==="error")throw Error(a.message||"The answer could not be completed.");a.type==="done"&&(re=!0,T({complete:!0}),f("Answer ready."),Q(a.model||L))};try{for(;;){const a=await x.read();if(a.done)break;N+=w.decode(a.value,{stream:!0});const _=N.split(`
13`);N=_.pop()||"";for(const ie of _)ie.trim()&&ae(JSON.parse(ie))}N+=w.decode(),N.trim()&&ae(JSON.parse(N))}finally{await x.cancel().catch(()=>{}),x.releaseLock()}if(!re)throw Error("The connection ended before the answer was complete. Please retry.")}catch(r){E.signal.aborted?(T({complete:!1}),h.current===E&&f("Stopped. You can ask another question.")):($(r instanceof Error?r.message:"The answer could not be completed."),D(t),f(""))}finally{h.current===E&&(v.current=!1,H(!1),h.current=null)}}return e.jsxs(e.Fragment,{children:[e.jsxs("aside",{className:"sc-dock","aria-label":"Ask Akil",hidden:d,children:[e.jsxs("button",{ref:V,className:"sc-restore",type:"button",hidden:!G,"aria-label":"Expand Ask Akil question box","aria-expanded":!1,"aria-controls":"sc-entry",onClick:()=>{J(!1),requestAnimationFrame(()=>k.current?.focus({preventScroll:!0}))},children:[e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8","aria-hidden":"true",children:[e.jsx("path",{d:"M20 11a7 7 0 0 1-7 7H8l-5 3V9a6 6 0 0 1 6-6h4a7 7 0 0 1 7 7Z"}),e.jsx("path",{d:"M7 8h9M7 12h6"})]}),"Ask Akil ",e.jsx("span",{children:"Ask about this page"})]}),e.jsxs("form",{id:"sc-entry",className:"sc-entry",hidden:G,"aria-label":"Ask Akil about this page",onSubmit:s=>{s.preventDefault(),se(!0)},children:[e.jsxs("div",{className:"sc-entry-heading",children:[e.jsxs("label",{htmlFor:"sc-entry-question",children:["Ask Akil ",e.jsx("span",{children:"AI chat"})]}),e.jsx("a",{className:"sc-activity-privacy",href:"/privacy#school-activity",target:"_blank",rel:"noopener noreferrer",title:"Questions and responses are saved privately for 90 days",children:"Privacy"}),e.jsx("button",{type:"button",className:"sc-minimize","aria-label":"Collapse Ask Akil question box","aria-expanded":!0,"aria-controls":"sc-entry",title:"Collapse question box",onClick:()=>{J(!0),requestAnimationFrame(()=>V.current?.focus({preventScroll:!0}))},children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:e.jsx("path",{d:"m6 9 6 6 6-6"})})})]}),e.jsxs("div",{className:"sc-entry-row",children:[e.jsx("textarea",{ref:k,id:"sc-entry-question","aria-label":"Ask about NYC school enrollment",value:p,onChange:s=>q(s.target.value),maxLength:2e3,rows:1,placeholder:"Ask about this page…",onKeyDown:s=>{s.key==="Enter"&&!s.shiftKey&&!s.nativeEvent.isComposing&&(s.preventDefault(),se(!0))}}),e.jsx("button",{type:"submit","aria-haspopup":"dialog","aria-label":A?"Return to chat":p.trim()?"Send question to Ask Akil":"Open Ask Akil chat",title:A?"Return to chat":p.trim()?"Send question":"Open chat",children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:e.jsx("path",{d:"m6 11 6-6 6 6M12 5v14"})})})]})]})]}),e.jsx("dialog",{ref:u,className:"sc-dialog","aria-labelledby":"sc-title",onCancel:()=>{C(""),F(!1)},onClose:()=>{C(""),F(!1)},onClick:s=>{if(s.target===u.current){const t=u.current.getBoundingClientRect();(s.clientX<t.left||s.clientX>t.right||s.clientY<t.top||s.clientY>t.bottom)&&B()}},children:e.jsxs("div",{className:"sc-frame",children:[e.jsxs("header",{className:"sc-header",children:[e.jsxs("div",{children:[e.jsx("p",{className:"sc-eyebrow",children:"AKILNYC / EDUCATION"}),e.jsx("h2",{id:"sc-title",children:"Ask Akil"})]}),e.jsxs("div",{className:"sc-header-actions",children:[e.jsx("button",{onClick:he,disabled:A,"aria-label":"Start a new conversation",children:"New chat"}),e.jsx("button",{className:"sc-close",onClick:B,"aria-label":"Close Ask Akil chat",children:"×"})]})]}),e.jsxs("div",{className:"sc-context",children:[e.jsx("strong",{children:"Exploring"}),e.jsx("span",{children:Z})]}),e.jsxs("div",{className:"sc-body",ref:l,tabIndex:0,role:"region","aria-label":"Chat messages",onScroll:()=>{const s=l.current;s&&(y.current=s.scrollHeight-s.scrollTop-s.clientHeight<90)},children:[!i.length&&e.jsxs("div",{className:"sc-welcome",children:[e.jsx("h3",{children:"There’s more behind the numbers."}),e.jsx("p",{children:"Ask about a school, compare neighborhoods, or explore what changed. I’ll check the records and show my sources."}),e.jsx("div",{className:"sc-prompts",children:Ce.map(s=>e.jsxs("button",{disabled:m!==!0,onClick:()=>void I(s),children:[s,e.jsx("span",{"aria-hidden":"true",children:"↗"})]},s))}),e.jsx("p",{className:"sc-note",children:"Enrollment can show where changes happened. Understanding why may need additional evidence."})]}),e.jsx("div",{role:"log","aria-label":"Conversation with Ask Akil","aria-live":"off",children:i.map(s=>e.jsxs("article",{className:`sc-message sc-${s.role}`,"aria-label":s.role==="user"?"Your question":"Akil answer",children:[e.jsx("p",{className:"sc-speaker",children:s.role==="user"?"You":"Akil"}),s.role==="user"?e.jsx("p",{children:s.content}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sc-markdown",children:e.jsx(xe,{remarkPlugins:[ge],components:{a:({href:t,children:j})=>s.sources?.some(z=>z.url===t)?e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",children:j}):e.jsx("span",{children:j}),table:({children:t})=>e.jsx("div",{className:"sc-table-scroll",tabIndex:0,children:e.jsx("table",{children:t})}),img:()=>null},children:s.content})}),s.complete&&s.handoff&&e.jsx(Ae,{question:s.question||"",context:s.context||"",noAiCall:s.noAiCall}),s.complete&&!!s.sources?.length&&e.jsxs("details",{className:"sc-sources",children:[e.jsxs("summary",{children:["Sources (",s.sources.length,")"]}),e.jsx("ul",{children:s.sources.map(t=>e.jsxs("li",{children:[e.jsxs("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",children:[t.title," ↗"]}),t.detail&&e.jsx("small",{children:t.detail})]},t.url))})]}),s.complete&&!!s.actions?.length&&e.jsx("div",{className:"sc-result-actions",children:s.actions.map((t,j)=>e.jsxs("button",{onClick:()=>{S(t.state),B()},children:[t.label," →"]},j))}),!A&&!s.complete&&s.content&&e.jsx("p",{className:"sc-note",children:"Incomplete answer"})]})]},s.id))}),W&&e.jsxs("div",{className:"sc-error",role:"alert",children:[e.jsx("p",{children:W}),K&&e.jsx("button",{onClick:()=>void I(K),disabled:A,children:"Try again"})]})]}),e.jsxs("form",{className:"sc-composer",onSubmit:s=>{s.preventDefault(),I(p)},children:[e.jsx("p",{className:"sc-status",role:"status","aria-live":"polite",children:P==="Connection guide ready. No AI request used."?P:m===null?"Connecting to Akil…":m===!1?"The AI connection is temporarily unavailable. Questions have not been sent.":P||"Ask a question or choose a suggestion."}),e.jsx("label",{htmlFor:"sc-question",children:"Your question"}),e.jsxs("div",{className:"sc-input-row",children:[e.jsx("textarea",{ref:g,id:"sc-question",value:p,readOnly:!!b,onChange:s=>q(s.target.value),maxLength:2e3,rows:2,placeholder:"What would you like to understand?",onKeyDown:s=>{s.key==="Enter"&&!s.shiftKey&&!s.nativeEvent.isComposing&&(s.preventDefault(),I(p))}}),A?e.jsx("button",{type:"button",className:"sc-send",onClick:te,children:"Stop"}):e.jsx("button",{className:"sc-send",type:"submit",disabled:!p.trim()||m!==!0&&!U(p
13)||!!b,"aria-label":"Send question",children:"Send ↗"})]}),e.jsx("a",{className:"sc-mcp-link",href:de,target:"_blank",rel:"noopener noreferrer",children:"Broader NYC question? Connect your own AI ↗"}),e.jsxs("p",{className:"sc-privacy",children:[L==="claude-sonnet-5"?"Claude Sonnet 5":"AI chat"," · When AI is used, questions and relevant public data go to Anthropic to generate answers. The on-screen conversation clears on reload. Submitted questions and responses are saved privately for 90 days to improve this tool. Please leave out personal details. ",e.jsx("a",{href:"/privacy",target:"_blank",rel:"noopener noreferrer",children:"Privacy"})]})]})]})})]})}export{Re as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.