PageSourceSearch

https://artineducation.ai/assets/DecisionsCard-CPp-9muo.js

js artineducation.ai collected 2026-10-05 15:28:07 UTC 4,584 bytes, 1 lines download raw bytes

1import{r as S,a as l,j as e,C as $,o as G,B as J,N as K,k as b,E as Y,F as C}from"./index-DykHQTdy.js";import{a as n}from"./react-ai5N7DV-.js";import{m as P,S as M,R as x,a as U}from"./shared-BozaAQX4.js";import"./motion-BDgCEaEF.js";function V({canAsk:_}){const[s,E]=n.useState(null),[c,y]=n.useState(null),[p,d]=n.useState(""),[u,j]=n.useState(!1),[i,h]=n.useState(null),[m,R]=n.useState(""),[f,T]=n.useState(""),[r,A]=n.useState(null),w=n.useRef(null),[F,D]=n.useState(0);n.useEffect(()=>{let a=!0;return d(""),S(l.decisions.status).then(t=>{a&&E(t)}).catch(t=>{a&&d(P(t))}),S(l.decisions.usage).then(t=>{a&&y(t)}).catch(()=>{}),()=>{var t;a=!1,(t=w.current)==null||t.abort()}},[F]);async function k(a){const t=new AbortController;w.current=t;const L=window.setTimeout(()=>t.abort(),45e3);d(""),j(!0),h(null);try{let o;if(a)o=await l.decisions.probe(t.signal);else{let N=m;if(r){if(!["image/png","image/jpeg","image/webp"].includes(r.type)||r.size>((s==null?void 0:s.max_image_mib)??12)*1024*1024)throw new Error(`Choose a PNG, JPEG or WebP image up to ${(s==null?void 0:s.max_image_mib)??12} MiB.`);const B=await new Promise((q,I)=>{const g=new FileReader;g.onload=()=>q(String(g.result)),g.onerror=()=>I(new Error("The image could not be read.")),g.readAsDataURL(r)});if(t.signal.aborted)return;N=[m,{type:"image_url",image_url:{url:B}}]}o=await l.decisions.ask({state:N,questions:{answer:{type:"noul",instructions:f}},tag:"settings.test"},t.signal)}t.signal.aborted||(h(o),l.decisions.usage().then(y).catch(()=>{}))}catch(o){d(t.signal.aborted?"The decision took too long. Please try again.":P(o))}finally{window.clearTimeout(L),j(!1)}}const v=i&&Object.values(i.answers)[0];return e.jsxs($,{id:"perplexity-decisions",className:M,children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsx(G,{eyebrow:"Perplexity Decisions",children:"Decisions from text and images"}),s&&e.jsx(J,{tone:s.configured?"success":"warning",children:s.configured?"Key configured":"Key needed"})]}),e.jsx("p",{className:"text-sm text-fg-muted",children:"Available alongside Jev. Quick capture and note checks continue to use Jev."}),e.jsx(K,{tone:"danger",children:p}),!s&&!p&&e.jsx("p",{role:"status",className:"text-sm text-fg-muted",children:"Checking connection…"}),!s&&p&&e.jsx(b,{variant:"secondary",onClick:()=>D(a=>a+1),children:"Retry connection check"}),s&&e.jsxs(e.Fragment,{children:[e.jsxs("dl",{className:"space-y-2 text-sm",children:[e.jsx(x,{k:"Model",children:s.model}),e.jsxs(x,{k:"Key",children:[s.configured?`From ${s.key_source==="vault"?"Vault":"the server environment"}`:"Not configured"," · ",e.jsx(U,{name:"PERPLEXITY_API_KEY"})]}),e.jsx(x,{k:"Supports",children:"Yes/no probabilities, choices and rubric scores · text, PNG, JPEG and WebP"}),c&&e.jsxs(x,{k:"Last 7 days",children:[c.calls," calls · ",c.input_tokens.toLocaleString()," input tokens · estimated $",c.est_usd.toFixed(6)]})]}),e.jsx(b,{variant:"secondary",disabled:u||!s.configured,onClick:()=>void k(!0),children:u?"Asking…":"Check Perplexity connection"}),_&&e.jsxs("details",{className:"border-t border-line pt-4",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium",children:"Try a text or image decision"}),e.jsxs("form",{className:"mt-4 space-y-4",onSubmit:a=>{a.preventDefault(),k(!1)},children:[e.jsx(Y,{label:"Content (optional with an image)",maxLength:2e4,value:m,onChange:a=>R(a.target.value),placeholder:"Paste the content you want to check."}),e.jsx(C,{label:"Image (optional)",type:"file",accept:"image/png,image/jpeg,image/webp",onChange:a=>{var t;A(((t=a.target.files)==null?void 0:t[0])??null),h(null)},hint:`Up to ${s.max_image_mib} MiB. Images are resized if needed and sent to Perplexity when you ask. The portal does not save them.`}),e.jsx(C,{label:"Yes/no question",value:f,required:!0,maxLength:2e3,onChange:a=>T(a.target.value),placeholder:"e.g. Does this page contain handwritten notes?"}),e.jsx(b,{type:"submit",disabled:u||!s.configured||!m.trim()&&!r||!f.trim(),children:u?"Asking…":"Ask Perplexity"})]})]}),i&&e.jsxs("div",{role:"status",className:"surface p-4",children:[e.jsx("p",{className:"font-medium",children:typeof v=="number"?`${(v*100).toFixed(1)}% probability of yes`:"Decision received"}),e.jsxs("p",{className:"mt-1 text-sm text-fg-muted",children:[i.model," · ",i.latency_ms,"ms · ",i.images," image",i.images===1?"":"s"]}),e.jsx("p",{className:"mt-1 text-xs text-fg-muted",children:"A model estimate for review; this test does not change portal records."})]})]})]})}export{V as DecisionsCard};

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.