timchen0618 commited on
Commit
2b7fb4d
·
verified ·
1 Parent(s): bd51d10

Show selected step indices in header

Browse files
frontend/dist/assets/ExperimentsApp-DY1f3p_l.js ADDED
The diff for this file is too large to render. See raw diff
 
frontend/dist/assets/ModelApp-zTXc-dCH.js ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ import{r as i,p as re,a as le,j as e}from"./index-CJnY-Hdk.js";const U="/api/model",X="/api/presets/model";async function L(t,l){const n=await fetch(t,{headers:{"Content-Type":"application/json"},...l});if(!n.ok){const c=await n.json().catch(()=>({error:n.statusText}));throw new Error(c.error||n.statusText)}return n.json()}const A={loadDataset(t,l,n,c){return L(`${U}/datasets/load`,{method:"POST",body:JSON.stringify({repo:t,column:l,split:n,prompt_column:c})})},listDatasets(){return L(`${U}/datasets/`)},getQuestion(t,l){return L(`${U}/datasets/${t}/question/${l}`)},getSummary(t){return L(`${U}/datasets/${t}/summary`)},unloadDataset(t){return L(`${U}/datasets/${t}`,{method:"DELETE"})},listPresets(){return L(`${X}`)},createPreset(t,l,n,c){return L(`${X}`,{method:"POST",body:JSON.stringify({name:t,repo:l,column:n,split:c})})},updatePreset(t,l){return L(`${X}/${t}`,{method:"PUT",body:JSON.stringify(l)})},deletePreset(t){return L(`${X}/${t}`,{method:"DELETE"})}};function ie(){const t=i.useRef(re().params),[l,n]=i.useState([]),[c,p]=i.useState([]),[s,x]=i.useState("all"),[b,g]=i.useState({}),[h,S]=i.useState({}),[I,j]=i.useState(null),[w,k]=i.useState({}),[o,m]=i.useState(null);i.useEffect(()=>{A.listPresets().then(p).catch(()=>{})},[]),i.useEffect(()=>{const a=re().params,d=parseInt(a.get("q")||"0"),f=parseInt(a.get("s")||"0"),u=a.get("filter")||"all";x(u),(!isNaN(d)||!isNaN(f))&&(window.__initialQ=isNaN(d)?0:d,window.__initialS=isNaN(f)?0:f)},[]);const y=i.useMemo(()=>{const r={};for(const a of l){const d=a.questionFingerprint;r[d]||(r[d]=[]),r[d].push(a)}return r},[l]),P=i.useMemo(()=>Object.keys(y).sort(),[y]);i.useEffect(()=>{if(o&&y[o])return;const r=P.find(a=>y[a].some(d=>d.active));r?m(r):P.length>0?m(P[0]):m(null)},[P,y,o]);const N=i.useMemo(()=>l.filter(r=>r.active&&r.questionFingerprint===o),[l,o]),[F,W]=i.useState([]);i.useEffect(()=>{const r=new Set(N.map(a=>a.id));W(a=>{const d=a.filter(v=>r.has(v)),f=N.map(v=>v.id).filter(v=>!a.includes(v)),u=[...d,...f];return u.length===a.length&&u.every((v,C)=>v===a[C])?a:u})},[N]);const H=i.useMemo(()=>{const r=new Map(N.map(a=>[a.id,a]));return F.map(a=>r.get(a)).filter(a=>a!==void 0)},[N,F]),Y=i.useCallback((r,a)=>{r!==a&&W(d=>{const f=[...d],u=f.indexOf(r),v=f.indexOf(a);return u===-1||v===-1?d:(f.splice(u,1),f.splice(v,0,r),f)})},[]),D=o?w[o]:void 0,E=(D==null?void 0:D.questionIdx)??0,M=(D==null?void 0:D.sampleIdx)??0,G=i.useCallback(r=>{o&&k(a=>{const d=a[o]??{questionIdx:0,sampleIdx:0},f=typeof r=="function"?r(d.questionIdx):r;return{...a,[o]:{...d,questionIdx:f}}})},[o]),B=i.useCallback(r=>{o&&k(a=>{const d=a[o]??{questionIdx:0,sampleIdx:0},f=typeof r=="function"?r(d.sampleIdx):r;return{...a,[o]:{...d,sampleIdx:f}}})},[o]);i.useEffect(()=>{const r=new URLSearchParams,a=l.filter(d=>d.active);a.length>0&&(r.set("repos",a.map(d=>d.repo).join(",")),r.set("cols",a.map(d=>d.column).join(",")),r.set("pcols",a.map(d=>d.promptColumn||"formatted_prompt").join(","))),r.set("q",String(E)),r.set("s",String(M)),s!=="all"&&r.set("filter",s),o&&r.set("group",o),le({params:r})},[l,E,M,s,o]),i.useEffect(()=>{N.forEach(r=>{const a=`${r.id}:${E}`;b[a]||A.getQuestion(r.id,E).then(d=>{g(f=>({...f,[a]:d}))}).catch(()=>{})})},[E,N]);const O=i.useCallback(async(r,a,d,f,u,v)=>{S(C=>({...C,[r]:!0})),j(null);try{const{question_fingerprint:C,...Q}=await A.loadDataset(r,a,d,f),V=C??"",ee={...Q,questionFingerprint:V,active:!0,presetId:u,presetName:v};n(T=>T.some(q=>q.id===ee.id)?T:[...T,ee]),k(T=>{if(T[V])return T;const q=window,ne=typeof q.__initialQ=="number"?q.__initialQ:0,oe=typeof q.__initialS=="number"?q.__initialS:0,te=Object.keys(T).length===0;return{...T,[V]:{questionIdx:te?ne:0,sampleIdx:te?oe:0}}}),m(V)}catch(C){j(C instanceof Error?C.message:"Failed to load dataset")}finally{S(C=>({...C,[r]:!1}))}},[]);i.useEffect(()=>{var u,v,C;const r=t.current,a=((u=r.get("repos"))==null?void 0:u.split(",").filter(Boolean))||[],d=((v=r.get("cols"))==null?void 0:v.split(","))||[],f=((C=r.get("pcols"))==null?void 0:C.split(","))||[];for(let Q=0;Q<a.length;Q++)O(a[Q],d[Q]||void 0,void 0,f[Q]||void 0)},[O]);const R=i.useCallback(async r=>{await A.unloadDataset(r).catch(()=>{}),n(a=>a.filter(d=>d.id!==r))},[]),$=i.useCallback(r=>{n(a=>{const d=a.map(u=>u.id===r?{...u,active:!u.active}:u),f=d.find(u=>u.id===r);return f&&f.active&&m(f.questionFingerprint),d})},[]),_=i.useCallback((r,a)=>{n(d=>d.map(f=>f.id===r?{...f,presetName:a}:f))},[]),J=i.useCallback(r=>{n(a=>a.map(d=>d.id===r?{...d,presetId:void 0,presetName:void 0}:d))},[]),K=Math.min(...N.map(r=>r.n_rows),1/0),z=Math.max(...N.map(r=>r.n_samples),0);return{datasets:l,presets:c,setPresets:p,questionIdx:E,setQuestionIdx:G,sampleIdx:M,setSampleIdx:B,filter:s,setFilter:x,loading:h,error:I,setError:j,activeDatasets:N,orderedActiveDatasets:H,maxQuestions:K,maxSamples:z,addDataset:O,removeDataset:R,toggleDataset:$,updateDatasetPresetName:_,clearDatasetPreset:J,getQuestionData:r=>b[`${r}:${E}`],reorderPanels:Y,groups:y,groupIds:P,currentGroupId:o,setCurrentGroupId:m}}const se=[{bg:"bg-blue-500",border:"border-blue-500",text:"text-blue-400",label:"text-blue-300"},{bg:"bg-emerald-500",border:"border-emerald-500",text:"text-emerald-400",label:"text-emerald-300"},{bg:"bg-amber-500",border:"border-amber-500",text:"text-amber-400",label:"text-amber-300"},{bg:"bg-purple-500",border:"border-purple-500",text:"text-purple-400",label:"text-purple-300"},{bg:"bg-rose-500",border:"border-rose-500",text:"text-rose-400",label:"text-rose-300"},{bg:"bg-cyan-500",border:"border-cyan-500",text:"text-cyan-400",label:"text-cyan-300"}];function ce({datasets:t,presets:l,loading:n,groups:c,groupIds:p,currentGroupId:s,onAddDataset:x,onRemoveDataset:b,onToggleDataset:g,onSetCurrentGroup:h,onLoadPreset:S,onSavePreset:I,onDeletePreset:j,onUpdatePreset:w}){const[k,o]=i.useState(!1),[m,y]=i.useState(""),[P,N]=i.useState(""),[F,W]=i.useState("train"),[H,Y]=i.useState(""),[D,E]=i.useState(""),[M,G]=i.useState(null),[B,O]=i.useState(""),[R,$]=i.useState(null),[_,J]=i.useState(""),K=()=>{m.trim()&&(x(m.trim(),P.trim()||void 0,F.trim()||void 0,H.trim()||void 0),y(""),o(!1))},z=r=>{B.trim()&&(I(B.trim(),r.repo,r.column,r.split),O(""),G(null))},Z=r=>{const a=p.indexOf(r);return se[a%se.length]};return e.jsxs("div",{className:"w-72 min-w-72 bg-gray-900 border-r border-gray-700 flex flex-col h-full",children:[e.jsxs("div",{className:"p-3 border-b border-gray-700",children:[e.jsx("div",{className:"flex items-center justify-between mb-2",children:e.jsx("h3",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wider",children:"Presets"})}),l.length===0?e.jsx("p",{className:"text-xs text-gray-500 italic",children:"No presets saved"}):e.jsxs(e.Fragment,{children:[l.length>6&&e.jsx("input",{type:"text",value:D,onChange:r=>E(r.target.value),placeholder:"Search presets...",className:"w-full px-2 py-1 mb-2 text-xs bg-gray-800 border border-gray-600 rounded text-gray-200 placeholder-gray-500 focus:border-blue-500 focus:outline-none"}),e.jsx("div",{className:"flex flex-wrap gap-1 max-h-32 overflow-y-auto",children:l.filter(r=>!D||r.name.toLowerCase().includes(D.toLowerCase())||r.repo.toLowerCase().includes(D.toLowerCase())).map(r=>e.jsxs("div",{className:"group relative",children:[e.jsx("button",{onClick:()=>S(r),className:"px-2 py-1 text-xs bg-gray-800 hover:bg-gray-700 rounded border border-gray-600 text-gray-300 transition-colors",title:`${r.repo} (${r.column}, ${r.split??"train"})`,children:r.name}),e.jsx("div",{className:"hidden group-hover:flex absolute top-full left-0 mt-1 z-10 gap-1",children:e.jsx("button",{onClick:()=>j(r.id),className:"px-1.5 py-0.5 text-[10px] bg-red-900 hover:bg-red-800 rounded text-red-300",children:"Delete"})})]},r.id))})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-3",children:[e.jsx("h3",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wider mb-2",children:"Loaded Repos"}),t.length===0?e.jsx("p",{className:"text-xs text-gray-500 italic",children:"No repos loaded. Add one below."}):e.jsx("div",{className:"space-y-3",children:p.map(r=>{const a=Z(r),d=c[r],f=r===s;return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>h(r),className:`w-full flex items-center gap-1.5 mb-1 px-1 py-0.5 rounded transition-colors ${f?"bg-gray-800":"hover:bg-gray-800/50"}`,children:[e.jsx("span",{className:`inline-block w-2 h-2 rounded-full ${a.bg} shrink-0`}),e.jsxs("span",{className:`text-[10px] font-semibold uppercase tracking-wider ${f?a.label:"text-gray-500"}`,children:["Group ",p.indexOf(r)+1,e.jsxs("span",{className:"normal-case font-normal ml-1 text-gray-600",children:["(",d.length," repo",d.length!==1?"s":"",")"]})]}),f&&e.jsx("span",{className:"text-[9px] text-gray-600 ml-auto",children:"viewing"})]}),e.jsx("div",{className:`space-y-1 border-l-2 ml-1 pl-2 ${f?a.border:"border-gray-700"}`,children:d.map(u=>e.jsxs("div",{children:[e.jsxs("div",{onClick:()=>{u.presetId&&($(R===u.id?null:u.id),J(u.presetName||""),o(!1))},className:`flex items-center gap-2 px-2 py-1.5 rounded text-sm transition-colors ${u.active?"bg-gray-800":"bg-gray-900 opacity-60"} ${R===u.id?"ring-1 ring-blue-500":""} ${u.presetId?"cursor-pointer":""}`,children:[e.jsx("input",{type:"checkbox",checked:u.active,onChange:()=>g(u.id),onClick:v=>v.stopPropagation(),className:"rounded border-gray-600 bg-gray-800 text-blue-500 focus:ring-blue-500 focus:ring-offset-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-gray-200 truncate text-xs font-medium",title:u.presetName?`${u.presetName}
2
+ ${u.repo}`:u.repo,children:u.presetName||u.name}),e.jsxs("div",{className:"text-[10px] text-gray-500",children:[u.column," | ",u.n_rows," rows | ",u.n_samples," samples"]})]}),e.jsx("button",{onClick:v=>{v.stopPropagation(),G(M===u.id?null:u.id),O("")},className:`transition-colors shrink-0 ${M===u.id?"text-blue-400":"text-gray-600 hover:text-blue-400"}`,title:"Save as preset",children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"})})}),e.jsx("button",{onClick:v=>{v.stopPropagation(),b(u.id)},className:"text-gray-600 hover:text-red-400 transition-colors shrink-0",title:"Remove",children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),M===u.id&&e.jsxs("div",{className:"flex gap-1 mt-1 ml-6",children:[e.jsx("input",{type:"text",value:B,onChange:v=>O(v.target.value),onKeyDown:v=>{v.key==="Enter"&&z(u),v.key==="Escape"&&G(null)},placeholder:"Preset name...",className:"flex-1 px-2 py-1 text-xs bg-gray-800 border border-gray-600 rounded text-gray-200 placeholder-gray-500 focus:border-blue-500 focus:outline-none",autoFocus:!0}),e.jsx("button",{onClick:()=>z(u),className:"px-2 py-1 text-xs bg-blue-600 hover:bg-blue-500 rounded text-white",children:"Save"})]})]},u.id))})]},r)})})]}),R&&(()=>{const r=t.find(a=>a.id===R);return r!=null&&r.presetId?e.jsxs("div",{className:"p-3 border-t border-gray-700 space-y-2",children:[e.jsx("div",{className:"text-[10px] text-gray-500 uppercase font-semibold tracking-wider",children:"Edit Preset"}),e.jsx("input",{type:"text",value:_,onChange:a=>J(a.target.value),onKeyDown:a=>{a.key==="Enter"&&_.trim()&&(w(r.presetId,r.id,{name:_.trim()}),$(null)),a.key==="Escape"&&$(null)},placeholder:"Preset name...",className:"w-full px-2 py-1 text-xs bg-gray-800 border border-gray-600 rounded text-gray-200 placeholder-gray-500 focus:border-blue-500 focus:outline-none",autoFocus:!0}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>{_.trim()&&(w(r.presetId,r.id,{name:_.trim()}),$(null))},disabled:!_.trim(),className:"flex-1 px-2 py-1 text-xs bg-blue-600 hover:bg-blue-500 disabled:bg-gray-700 disabled:text-gray-500 rounded text-white transition-colors",children:"Save"}),e.jsx("button",{onClick:()=>{j(r.presetId,r.id),$(null)},className:"px-2 py-1 text-xs bg-red-900 hover:bg-red-800 rounded text-red-300 transition-colors",children:"Delete"}),e.jsx("button",{onClick:()=>$(null),className:"px-2 py-1 text-xs bg-gray-700 hover:bg-gray-600 rounded text-gray-300 transition-colors",children:"Cancel"})]})]}):null})(),e.jsx("div",{className:"p-3 border-t border-gray-700",children:k?e.jsxs("div",{className:"space-y-2",children:[e.jsx("input",{type:"text",value:m,onChange:r=>y(r.target.value),onKeyDown:r=>r.key==="Enter"&&K(),placeholder:"org/dataset-name",className:"w-full px-2 py-1.5 text-sm bg-gray-800 border border-gray-600 rounded text-gray-200 placeholder-gray-500 focus:border-blue-500 focus:outline-none",autoFocus:!0}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:P,onChange:r=>N(r.target.value),placeholder:"Response col (auto-detect)",className:"flex-1 px-2 py-1 text-xs bg-gray-800 border border-gray-600 rounded text-gray-200 placeholder-gray-500 focus:border-blue-500 focus:outline-none"}),e.jsx("input",{type:"text",value:F,onChange:r=>W(r.target.value),placeholder:"Split",className:"w-16 px-2 py-1 text-xs bg-gray-800 border border-gray-600 rounded text-gray-200 placeholder-gray-500 focus:border-blue-500 focus:outline-none"})]}),e.jsx("div",{className:"flex gap-2",children:e.jsx("input",{type:"text",value:H,onChange:r=>Y(r.target.value),placeholder:"Prompt col (auto-detect)",className:"flex-1 px-2 py-1 text-xs bg-gray-800 border border-gray-600 rounded text-gray-200 placeholder-gray-500 focus:border-blue-500 focus:outline-none"})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:K,disabled:!m.trim()||n[m.trim()],className:"flex-1 px-2 py-1.5 text-sm bg-blue-600 hover:bg-blue-500 disabled:bg-gray-700 disabled:text-gray-500 rounded text-white transition-colors",children:n[m.trim()]?"Loading...":"Load"}),e.jsx("button",{onClick:()=>o(!1),className:"px-3 py-1.5 text-sm bg-gray-700 hover:bg-gray-600 rounded text-gray-300 transition-colors",children:"Cancel"})]})]}):e.jsx("button",{onClick:()=>{$(null),o(!0),y(""),N(""),W("train"),Y("")},className:"w-full px-3 py-2 text-sm bg-blue-600 hover:bg-blue-500 rounded text-white font-medium transition-colors",children:"+ Add Repo"})})]})}function de(t){if(!t)return[{text:"(no response)",className:"text-gray-500 italic"}];const l=[],n=t.split(`
3
+ `);for(let c=0;c<n.length;c++){const p=n[c],s=p.toLowerCase().trim();let x="text-gray-300";s.startsWith("wait")||s.startsWith("hmm")||s.startsWith("but wait")?x="text-yellow-400":s.startsWith("let me try")||s.startsWith("let me reconsider")||s.startsWith("let me think")?x="text-cyan-400":s.startsWith("so the answer")||s.startsWith("so the expression")||s.startsWith("therefore")||s.startsWith("the final")?x="text-green-400 font-bold":s.startsWith("i give up")||s.startsWith("i can't find")||s.startsWith("i'm stuck")||s.startsWith("i'm sorry")?x="text-red-400 font-bold":p.includes("=")&&/[+\-*/]/.test(p)&&(x="text-gray-100"),l.push({text:p,className:x}),c<n.length-1&&l.push({text:`
4
+ `,className:""})}return l}function ue(t){if(!t||!t.trim())return[];try{const l=JSON.parse(t);if(Array.isArray(l)&&l.length>0&&l[0].role!==void 0)return l.map(n=>({role:String(n.role||"unknown"),content:String(n.content??"")}))}catch{}if(t.includes("<|im_start|>"))return t.split("<|im_start|>").filter(Boolean).map(n=>{const c=n.indexOf(`
5
+ `),p=c>0?n.slice(0,c).trim():"unknown",s=(c>0?n.slice(c+1):n).replace(/<\|im_end\|>/g,"").trim();return{role:p,content:s}});if(/<\|(system|user|assistant)\|>/.test(t)){const l=/<\|(system|user|assistant)\|>/g,n=[];let c;for(;(c=l.exec(t))!==null;)n.push({role:c[1],start:c.index,tagEnd:c.index+c[0].length});return n.map((p,s)=>{const x=s+1<n.length?n[s+1].start:t.length;return{role:p.role,content:t.slice(p.tagEnd,x).trim()}})}if(t.includes("[INST]")||t.includes("<<SYS>>")){const l=[],n=t.match(/<<SYS>>([\s\S]*?)<<\/SYS>>/);n&&l.push({role:"system",content:n[1].trim()});const p=t.replace(/<<SYS>>[\s\S]*?<<\/SYS>>/g,"").split(/\[INST\]|\[\/INST\]/).map(x=>x.trim()).filter(Boolean);let s=!0;for(const x of p)l.push({role:s?"user":"assistant",content:x}),s=!s;return l.length>0?l:[{role:"prompt",content:t}]}if(/^(System|User|Assistant|Human):\s/m.test(t)){const l=/^(System|User|Assistant|Human):\s*/gm,n=[];let c;for(;(c=l.exec(t))!==null;){const p=c[1].toLowerCase()==="human"?"user":c[1].toLowerCase();n.push({role:p,contentStart:c.index+c[0].length})}return n.map((p,s)=>{const x=s+1<n.length?t.lastIndexOf(`
6
+ `,n[s+1].contentStart-n[s+1].role.length-2):t.length;return{role:p.role,content:t.slice(p.contentStart,x>p.contentStart?x:t.length).trim()}})}return[{role:"prompt",content:t}]}function xe({datasetName:t,repoName:l,data:n,sampleIdx:c,isLoading:p,dragHandleProps:s}){var o;const[x,b]=i.useState(!1);if(p)return e.jsx("div",{className:"h-full border border-gray-700 rounded-lg flex items-center justify-center",children:e.jsx("div",{className:"text-gray-500 text-sm",children:"Loading..."})});if(!n)return e.jsx("div",{className:"h-full border border-gray-700 rounded-lg flex items-center justify-center",children:e.jsx("div",{className:"text-gray-500 text-sm",children:"No data"})});const g=n.eval_correct[c],h=n.analyses[c],S=(o=n.extractions)==null?void 0:o[c],I=g===void 0?"border-gray-700":g?"border-green-600":"border-red-600",j=de((h==null?void 0:h.think_text)||""),w=(h==null?void 0:h.answer_text)||"",k=n.prompt_text?ue(n.prompt_text):[];return e.jsxs("div",{className:`h-full border-2 ${I} rounded-lg flex flex-col bg-gray-900/50`,children:[e.jsxs("div",{className:"px-3 py-2 border-b border-gray-700 flex items-center justify-between shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"text-sm font-semibold text-gray-200 truncate",title:l?`${t}
7
+ ${l}`:t,children:t}),g!==void 0&&e.jsx("span",{className:`px-1.5 py-0.5 text-[10px] rounded font-medium ${g?"bg-green-900 text-green-300":"bg-red-900 text-red-300"}`,children:g?"CORRECT":"WRONG"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0 ml-2",children:[e.jsx("span",{className:"text-[10px] text-gray-500",children:h&&e.jsxs(e.Fragment,{children:["Think: ",h.think_len.toLocaleString()," | BT: ",h.backtracks]})}),s&&e.jsx("span",{...s,title:"Drag to reorder",className:"drag-handle text-gray-600 hover:text-gray-400 transition-colors",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:[e.jsx("circle",{cx:"5",cy:"3",r:"1.5"}),e.jsx("circle",{cx:"11",cy:"3",r:"1.5"}),e.jsx("circle",{cx:"5",cy:"8",r:"1.5"}),e.jsx("circle",{cx:"11",cy:"8",r:"1.5"}),e.jsx("circle",{cx:"5",cy:"13",r:"1.5"}),e.jsx("circle",{cx:"11",cy:"13",r:"1.5"})]})})]})]}),S&&e.jsxs("div",{className:"px-3 py-1.5 border-b border-gray-700/50 bg-gray-800/30 overflow-x-auto whitespace-nowrap",children:[e.jsx("span",{className:"text-[10px] text-gray-500 uppercase font-medium",children:"Extracted: "}),e.jsx("span",{className:"text-xs text-gray-300 font-mono",children:S})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto trace-scroll px-3 py-2",children:[k.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsxs("button",{onClick:()=>b(!x),className:"flex items-center gap-1 text-xs font-semibold text-gray-400 uppercase tracking-wider mb-1 hover:text-gray-300 transition-colors",children:[e.jsx("span",{className:"text-[10px]",children:x?"▼":"▶"}),"Prompt (",k.length," message",k.length!==1?"s":"",")"]}),x&&e.jsx("div",{className:"space-y-1.5",children:k.map((m,y)=>e.jsx(pe,{message:m},y))})]}),e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wider mb-1",children:["Thinking (",(h==null?void 0:h.think_len.toLocaleString())||0," chars)"]}),e.jsx("pre",{className:"text-xs leading-relaxed whitespace-pre-wrap font-mono",children:j.map((m,y)=>e.jsx("span",{className:m.className,children:m.text},y))})]}),w&&e.jsxs("div",{children:[e.jsxs("div",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wider mb-1",children:["Answer (",(h==null?void 0:h.answer_len.toLocaleString())||0," chars)"]}),e.jsx("pre",{className:"text-xs leading-relaxed whitespace-pre-wrap font-mono text-gray-100 font-bold",children:w})]})]})]})}const ae={system:{border:"border-l-purple-500",label:"text-purple-400",bg:"bg-purple-500/5"},user:{border:"border-l-blue-500",label:"text-blue-400",bg:"bg-blue-500/5"},assistant:{border:"border-l-green-500",label:"text-green-400",bg:"bg-green-500/5"},prompt:{border:"border-l-gray-500",label:"text-gray-400",bg:"bg-gray-500/5"}};function pe({message:t}){const l=ae[t.role]||ae.prompt;return e.jsxs("div",{className:`border-l-2 ${l.border} ${l.bg} rounded-r pl-2 py-1`,children:[e.jsx("div",{className:`text-[10px] font-semibold uppercase tracking-wider ${l.label}`,children:t.role}),e.jsx("pre",{className:"text-xs leading-relaxed whitespace-pre-wrap font-mono text-gray-300 max-h-60 overflow-y-auto",children:t.content})]})}function me({activeDatasets:t,questionIdx:l,sampleIdx:n,getQuestionData:c}){let p="",s=0;const x=t.length>0?c(t[0].id):void 0;return x&&(p=x.question,s=x.n_samples),p?e.jsxs("div",{className:"px-4 py-3 border-b border-gray-700 bg-gray-900/80",children:[e.jsxs("div",{className:"text-sm text-gray-200 font-medium mb-2 leading-relaxed max-h-24 overflow-y-auto",children:["Q",l,": ",p]}),s>1&&e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[e.jsx("span",{className:"text-[10px] text-gray-500 mr-1",children:"Samples:"}),Array.from({length:s},(b,g)=>{const h=t.map(o=>{const m=c(o.id);return m==null?void 0:m.eval_correct[g]}),S=h.every(o=>o===!0),I=h.some(o=>o===!0),j=h.every(o=>o===!1);let w="bg-gray-700";S?w="bg-green-700":I?w="bg-yellow-700":j&&(w="bg-red-900");const k=g===n;return e.jsx("span",{className:`inline-block w-4 h-4 rounded-sm text-[9px] text-center leading-4 font-mono ${w} ${k?"ring-2 ring-blue-400 ring-offset-1 ring-offset-gray-900":""}`,title:`Sample ${g+1}: ${h.map((o,m)=>{var y;return`${(y=t[m])==null?void 0:y.name}=${o?"correct":"wrong"}`}).join(", ")}`,children:g+1},g)}),e.jsxs("span",{className:"text-[10px] text-gray-600 ml-2",children:[e.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-sm bg-green-700 mr-0.5 align-middle"})," all",e.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-sm bg-yellow-700 mr-0.5 ml-1.5 align-middle"})," some",e.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-sm bg-red-900 mr-0.5 ml-1.5 align-middle"})," none"]})]}),e.jsx("div",{className:"flex items-center gap-3 mt-1.5 flex-wrap",children:t.map(b=>{const g=c(b.id),h=g==null?void 0:g.eval_correct[n];return e.jsxs("span",{className:"text-[11px]",children:[e.jsxs("span",{className:"text-gray-500",children:[b.name,": "]}),e.jsx("span",{className:h?"text-green-400":"text-red-400",children:h===void 0?"?":h?"Correct":"Wrong"})]},b.id)})})]}):e.jsx("div",{className:"px-4 py-3 border-b border-gray-700 bg-gray-900/80",children:e.jsx("p",{className:"text-sm text-gray-500 italic",children:"Load repos and select a question to begin"})})}const ge=[{value:"all",label:"All"},{value:"improvements",label:"Improvements"},{value:"regressions",label:"Regressions"},{value:"both-correct",label:"Both Correct"},{value:"both-wrong",label:"Both Wrong"}];function he({questionIdx:t,sampleIdx:l,maxQuestions:n,maxSamples:c,filter:p,onQuestionChange:s,onSampleChange:x,onFilterChange:b}){const g=()=>s(Math.max(0,t-1)),h=()=>s(Math.min(n-1,t+1)),S=()=>x(Math.max(0,l-1)),I=()=>x(Math.min(c-1,l+1));return e.jsxs("div",{className:"px-4 py-2 border-t border-gray-700 bg-gray-900/80 flex items-center justify-between flex-wrap gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:g,disabled:t<=0,className:"px-2 py-1 text-xs bg-gray-800 hover:bg-gray-700 disabled:opacity-40 rounded border border-gray-600 text-gray-300 transition-colors",children:"← Prev Q"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-xs text-gray-500",children:"Q"}),e.jsx("input",{type:"number",value:t,onChange:j=>{const w=parseInt(j.target.value);!isNaN(w)&&w>=0&&w<n&&s(w)},className:"w-16 px-1.5 py-1 text-xs text-center bg-gray-800 border border-gray-600 rounded text-gray-200 focus:border-blue-500 focus:outline-none"}),e.jsxs("span",{className:"text-xs text-gray-500",children:["/ ",n>0?n-1:0]})]}),e.jsx("button",{onClick:h,disabled:t>=n-1,className:"px-2 py-1 text-xs bg-gray-800 hover:bg-gray-700 disabled:opacity-40 rounded border border-gray-600 text-gray-300 transition-colors",children:"Next Q →"})]}),c>1&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:S,disabled:l<=0,className:"px-2 py-1 text-xs bg-gray-800 hover:bg-gray-700 disabled:opacity-40 rounded border border-gray-600 text-gray-300 transition-colors",children:"← Prev S"}),e.jsxs("span",{className:"text-xs text-gray-400",children:["Sample ",l+1,"/",c]}),e.jsx("button",{onClick:I,disabled:l>=c-1,className:"px-2 py-1 text-xs bg-gray-800 hover:bg-gray-700 disabled:opacity-40 rounded border border-gray-600 text-gray-300 transition-colors",children:"Next S →"})]}),e.jsx("div",{className:"flex items-center gap-1",children:ge.map(j=>e.jsx("button",{onClick:()=>b(j.value),className:`px-2 py-1 text-[10px] rounded border transition-colors ${p===j.value?"bg-blue-600 border-blue-500 text-white":"bg-gray-800 border-gray-600 text-gray-400 hover:bg-gray-700"}`,children:j.label},j.value))}),e.jsxs("div",{className:"text-[10px] text-gray-600",children:[e.jsx("kbd",{className:"px-1 bg-gray-800 rounded",children:"j"}),"/",e.jsx("kbd",{className:"px-1 bg-gray-800 rounded",children:"k"})," question"," ",e.jsx("kbd",{className:"px-1 bg-gray-800 rounded",children:"h"}),"/",e.jsx("kbd",{className:"px-1 bg-gray-800 rounded",children:"l"})," sample"]})]})}function ye(){const t=ie(),l=i.useCallback(async s=>{await t.addDataset(s.repo,s.column,s.split,void 0,s.id,s.name)},[t.addDataset]),n=i.useCallback(async(s,x,b,g)=>{const h=await A.createPreset(s,x,b,g);t.setPresets(S=>[...S,h])},[]),c=i.useCallback(async(s,x)=>{await A.deletePreset(s),t.setPresets(b=>b.filter(g=>g.id!==s)),x&&t.clearDatasetPreset(x)},[t.clearDatasetPreset]),p=i.useCallback(async(s,x,b)=>{const g=await A.updatePreset(s,b);t.setPresets(h=>h.map(S=>S.id===s?g:S)),b.name&&t.updateDatasetPresetName(x,b.name)},[t.updateDatasetPresetName]);return i.useEffect(()=>{const s=x=>{if(!(x.target instanceof HTMLInputElement||x.target instanceof HTMLTextAreaElement))switch(x.key){case"j":t.setQuestionIdx(b=>Math.min(t.maxQuestions-1,b+1));break;case"k":t.setQuestionIdx(b=>Math.max(0,b-1));break;case"l":t.setSampleIdx(b=>Math.min(t.maxSamples-1,b+1));break;case"h":t.setSampleIdx(b=>Math.max(0,b-1));break}};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[t.maxQuestions,t.maxSamples,t.setQuestionIdx,t.setSampleIdx]),e.jsxs("div",{className:"h-full flex overflow-hidden",children:[e.jsx(ce,{datasets:t.datasets,presets:t.presets,loading:t.loading,groups:t.groups,groupIds:t.groupIds,currentGroupId:t.currentGroupId,onAddDataset:t.addDataset,onRemoveDataset:t.removeDataset,onToggleDataset:t.toggleDataset,onSetCurrentGroup:t.setCurrentGroupId,onLoadPreset:l,onSavePreset:n,onDeletePreset:c,onUpdatePreset:p}),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[t.error&&e.jsxs("div",{className:"px-4 py-2 bg-red-900/50 border-b border-red-700 text-red-300 text-sm flex items-center justify-between",children:[e.jsx("span",{children:t.error}),e.jsx("button",{onClick:()=>t.setError(null),className:"text-red-400 hover:text-red-300 ml-2",children:"Dismiss"})]}),e.jsx(me,{activeDatasets:t.activeDatasets,questionIdx:t.questionIdx,sampleIdx:t.sampleIdx,getQuestionData:t.getQuestionData}),e.jsx(be,{datasets:t.orderedActiveDatasets,getQuestionData:t.getQuestionData,sampleIdx:t.sampleIdx,onReorder:t.reorderPanels}),e.jsx(he,{questionIdx:t.questionIdx,sampleIdx:t.sampleIdx,maxQuestions:t.maxQuestions,maxSamples:t.maxSamples,filter:t.filter,onQuestionChange:t.setQuestionIdx,onSampleChange:t.setSampleIdx,onFilterChange:t.setFilter})]})]})}function be({datasets:t,getQuestionData:l,sampleIdx:n,onReorder:c}){const[p,s]=i.useState(null),[x,b]=i.useState(null),g=i.useRef({}),h=i.useCallback((o,m)=>{s(m),o.dataTransfer.effectAllowed="move";const y=document.createElement("canvas");y.width=1,y.height=1,o.dataTransfer.setDragImage(y,0,0)},[]),S=i.useCallback(()=>{s(null),b(null),g.current={}},[]),I=i.useCallback((o,m)=>{o.preventDefault(),g.current[m]=(g.current[m]||0)+1,b(m)},[]),j=i.useCallback((o,m)=>{g.current[m]=(g.current[m]||0)-1,g.current[m]<=0&&(g.current[m]=0,b(y=>y===m?null:y))},[]),w=i.useCallback(o=>{o.preventDefault(),o.dataTransfer.dropEffect="move"},[]),k=i.useCallback((o,m)=>{o.preventDefault(),p&&p!==m&&c(p,m),s(null),b(null),g.current={}},[p,c]);return t.length===0?e.jsx("div",{className:"flex-1 flex gap-2 p-2 overflow-x-auto min-h-0",children:e.jsx("div",{className:"flex-1 flex items-center justify-center text-gray-500",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-lg mb-2",children:"No repos active"}),e.jsx("p",{className:"text-sm",children:"Add a HuggingFace repo from the sidebar to get started"})]})})}):e.jsx("div",{className:"flex-1 flex gap-2 p-2 overflow-x-auto min-h-0",children:t.map(o=>{const m=p===o.id,y=x===o.id&&p!==null&&p!==o.id,P={draggable:!0,onDragStart:N=>h(N,o.id),onDragEnd:S};return e.jsx("div",{onDragEnter:N=>I(N,o.id),onDragLeave:N=>j(N,o.id),onDragOver:w,onDrop:N=>k(N,o.id),className:`flex-1 min-w-0 transition-all duration-150 ${m?"opacity-30 scale-[0.97]":""} ${y?"panel-drop-target":""}`,children:e.jsx(xe,{datasetName:o.presetName||o.name,repoName:o.presetName?o.name:void 0,data:l(o.id),sampleIdx:n,dragHandleProps:P})},o.id)})})}export{ye as default};
frontend/dist/assets/PlanRevisionsApp-DyhuRMap.js ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ import{r as i,j as t}from"./index-CJnY-Hdk.js";function S(r,p){const x=r.split(`
2
+ `),n=p.split(`
3
+ `),d=new Set(x),m=new Set(n),s=[];let o=0,a=0;for(;o<x.length||a<n.length;){const u=x[o],l=n[a];o>=x.length?(s.push({text:n[a],type:"add"}),a++):a>=n.length?(s.push({text:x[o],type:"del"}),o++):u===l?(s.push({text:u,type:"same"}),o++,a++):m.has(u)?d.has(l)?(s.push({text:u,type:"del"}),s.push({text:l,type:"add"}),o++,a++):(s.push({text:l,type:"add"}),a++):(s.push({text:u,type:"del"}),o++)}return s}function _({prev:r,curr:p}){const x=i.useMemo(()=>S(r,p),[r,p]);return t.jsx("pre",{className:"text-xs font-mono whitespace-pre-wrap leading-relaxed",children:x.map((n,d)=>n.type==="same"?t.jsx("span",{className:"text-gray-300",children:n.text+`
4
+ `},d):n.type==="add"?t.jsx("span",{className:"bg-green-900/40 text-green-300",children:"+ "+n.text+`
5
+ `},d):t.jsx("span",{className:"bg-red-900/40 text-red-300",children:"- "+n.text+`
6
+ `},d))})}function k({text:r}){return t.jsx("pre",{className:"text-xs font-mono whitespace-pre-wrap leading-relaxed text-gray-200",children:r})}function R(){const[r,p]=i.useState(null),[x,n]=i.useState(!0),[d,m]=i.useState(null),[s,o]=i.useState(""),[a,u]=i.useState(""),[l,y]=i.useState(0),[b,j]=i.useState(!1);i.useEffect(()=>{n(!0),fetch("/api/plan-revisions/").then(e=>{if(!e.ok)throw new Error(e.statusText);return e.json()}).then(e=>{p(e),e.conditions.length>0&&o(e.conditions[0]),n(!1)}).catch(e=>{m(e.message),n(!1)})},[]),i.useEffect(()=>{if(!r||!s)return;const e=Object.keys(r.data[s]||{}).sort((c,h)=>Number(c)-Number(h));e.length>0&&u(e[0]),y(0)},[s,r]),i.useEffect(()=>{y(0)},[a]);const N=i.useMemo(()=>!r||!s?[]:Object.keys(r.data[s]||{}).sort((e,c)=>Number(e)-Number(c)),[r,s]),g=i.useMemo(()=>{var e;return!r||!s||!a?[]:((e=r.data[s])==null?void 0:e[a])??[]},[r,s,a]),f=g[l],v=l>0?g[l-1]:null;if(x)return t.jsx("div",{className:"h-full flex items-center justify-center text-gray-400",children:"Loading plan revisions from HuggingFace…"});if(d)return t.jsxs("div",{className:"h-full flex items-center justify-center text-red-400",children:["Error: ",d]});if(!r)return null;const w=e=>e.replace("_revise_every_5_seed0","").replace("planning_","").replace("_start_ext_gemini_2.5_pro"," +gemini");return t.jsxs("div",{className:"h-full flex flex-col bg-gray-950 text-gray-100",children:[t.jsxs("div",{className:"flex items-center gap-4 px-4 py-2 border-b border-gray-800 bg-gray-900 shrink-0 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-gray-400 uppercase tracking-wide",children:"Condition"}),t.jsx("div",{className:"flex gap-1 flex-wrap",children:r.conditions.map(e=>t.jsx("button",{onClick:()=>o(e),title:e,className:`px-2 py-1 text-xs rounded border transition-colors ${s===e?"bg-blue-700 border-blue-500 text-white":"bg-gray-800 border-gray-700 text-gray-400 hover:border-gray-500"}`,children:w(e)},e))})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-gray-400 uppercase tracking-wide",children:"Query"}),t.jsx("select",{value:a,onChange:e=>u(e.target.value),className:"bg-gray-800 border border-gray-700 text-gray-200 text-xs rounded px-2 py-1",children:N.map(e=>{var h;const c=((h=r.data[s])==null?void 0:h[e])??[];return t.jsxs("option",{value:e,children:["#",e," (",c.length," revision",c.length!==1?"s":"",")"]},e)})})]}),t.jsxs("label",{className:"flex items-center gap-1 text-xs text-gray-400 cursor-pointer ml-auto",children:[t.jsx("input",{type:"checkbox",checked:b,onChange:e=>j(e.target.checked),className:"accent-blue-500"}),"Show diff vs previous"]})]}),g.length===0?t.jsx("div",{className:"flex-1 flex items-center justify-center text-gray-500",children:"No plan revisions for this query / condition."}):t.jsxs("div",{className:"flex-1 flex min-h-0",children:[t.jsx("div",{className:"w-36 shrink-0 border-r border-gray-800 flex flex-col overflow-y-auto bg-gray-900",children:g.map((e,c)=>t.jsxs("button",{onClick:()=>y(c),className:`px-3 py-2 text-left text-xs border-b border-gray-800 transition-colors ${l===c?"bg-blue-900/50 text-blue-300 border-l-2 border-l-blue-500":"text-gray-400 hover:bg-gray-800"}`,children:[t.jsx("div",{className:"font-medium",children:e.source==="initial"?"Initial":`Revision ${c}`}),t.jsx("div",{className:"text-gray-600 text-[10px] mt-0.5",children:e.source})]},c))}),t.jsx("div",{className:"flex-1 flex flex-col min-w-0 overflow-hidden",children:f&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"px-4 py-2 bg-gray-900/50 border-b border-gray-800 shrink-0 flex items-center gap-3",children:[t.jsx("span",{className:"text-sm font-medium text-gray-200",children:f.source==="initial"?"Initial Plan":`Revision ${l} of ${g.length-1}`}),t.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${f.source==="initial"?"bg-gray-700 text-gray-300":"bg-amber-900/50 text-amber-300"}`,children:f.source}),b&&v&&t.jsxs("span",{className:"text-xs text-gray-500",children:["diff vs ",l===1?"initial":`revision ${l-1}`]})]}),t.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:b&&v?t.jsx(_,{prev:v.plan_text,curr:f.plan_text}):t.jsx(k,{text:f.plan_text})})]})})]})]})}export{R as default};
frontend/dist/assets/SelectedToolsApp-caodUoP9.js ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import{r as o,j as e}from"./index-CJnY-Hdk.js";const k={reasoning:{border:"border-purple-700",labelColor:"text-purple-400",bg:"bg-purple-950/30"},tool_call:{border:"border-blue-700",labelColor:"text-blue-400",bg:"bg-blue-950/30"},tool_result:{border:"border-gray-600",labelColor:"text-gray-400",bg:"bg-gray-800/30"},final_answer:{border:"border-green-700",labelColor:"text-green-400",bg:"bg-green-950/30"},unknown:{border:"border-gray-700",labelColor:"text-gray-500",bg:""}};function _(l){if(!l)return[];const s=[],i=l.split(/\n\n(?=\[)/);for(const n of i){const r=n.trim();r.startsWith("[Reasoning]:")?s.push({type:"reasoning",label:"Reasoning",content:r.slice(12).trim()}):r.startsWith("[Tool call]")?s.push({type:"tool_call",label:"Tool Call",content:r.slice(11).trim()}):r.startsWith("[Tool result]:")?s.push({type:"tool_result",label:"Tool Result",content:r.slice(14).trim()}):r.startsWith("[Final answer]:")?s.push({type:"final_answer",label:"Final Answer",content:r.slice(15).trim()}):r&&s.push({type:"unknown",label:"—",content:r})}return s}function C(l){if(!l)return[];const s=[],i=l.split(`
2
+
3
+ ---
4
+
5
+ `);for(const n of i){const r=n.trim();if(r.startsWith(`[Reasoning]
6
+ `))s.push({type:"reasoning",label:"Reasoning",content:r.slice(12).trim()});else if(r.startsWith("[Tool Call:")){const u=`
7
+
8
+ [Tool Result]
9
+ `,x=r.indexOf(u),p=r.indexOf(`]
10
+ `),d=p>=0?r.slice(11,p).trim():"unknown";if(x>=0){const g=r.slice(0,x).replace(/^\[Tool Call:[^\]]*\]\n/,"").trim(),b=r.slice(x+u.length).trim();s.push({type:"tool_call",label:`Tool Call: ${d}`,content:g}),s.push({type:"tool_result",label:"Tool Result",content:b})}else{const g=r.replace(/^\[Tool Call:[^\]]*\]\n/,"").trim();s.push({type:"tool_call",label:`Tool Call: ${d}`,content:g})}}else r.startsWith(`[Final Answer]
11
+ `)?s.push({type:"final_answer",label:"Final Answer",content:r.slice(15).trim()}):r&&s.push({type:"unknown",label:"—",content:r})}return s}function h({blocks:l}){return l.length===0?e.jsx("div",{className:"text-gray-500 text-xs italic",children:"No steps."}):e.jsx("div",{className:"space-y-2",children:l.map((s,i)=>{const n=k[s.type];return e.jsxs("div",{className:`border-l-2 ${n.border} ${n.bg} pl-3 py-1.5 rounded-r`,children:[e.jsx("div",{className:`text-[10px] font-bold uppercase tracking-widest mb-1 ${n.labelColor}`,children:s.label??s.type}),e.jsx("pre",{className:"text-xs text-gray-300 whitespace-pre-wrap font-mono leading-relaxed",children:s.content})]},i)})})}function S(){const[l,s]=o.useState([]),[i,n]=o.useState(!0),[r,u]=o.useState(null),[x,p]=o.useState(0),[d,g]=o.useState(""),[b,y]=o.useState("all");o.useEffect(()=>{n(!0),fetch("/api/selected-tools/").then(t=>{if(!t.ok)throw new Error(t.statusText);return t.json()}).then(t=>{s(t.rows),n(!1)}).catch(t=>{u(t.message),n(!1)})},[]);const f=o.useMemo(()=>{let t=l;if(b==="direct"&&(t=t.filter(c=>c.direct_answer)),b==="searched"&&(t=t.filter(c=>!c.direct_answer)),d.trim()){const c=d.toLowerCase();t=t.filter(v=>v.query_id.includes(c))}return t},[l,d,b]),a=f[x]??null,j=o.useMemo(()=>a?_(a.excerpt):[],[a]),N=o.useMemo(()=>a?C(a.new_trajectory):[],[a]),m=l.filter(t=>t.direct_answer).length,w=l.length?Math.round(100*m/l.length):0;return i?e.jsx("div",{className:"h-full flex items-center justify-center text-gray-400",children:"Loading from HuggingFace…"}):r?e.jsxs("div",{className:"h-full flex items-center justify-center text-red-400",children:["Error: ",r]}):e.jsxs("div",{className:"h-full flex overflow-hidden bg-gray-950 text-gray-100",children:[e.jsxs("div",{className:"w-64 shrink-0 flex flex-col border-r border-gray-800 bg-gray-900",children:[e.jsxs("div",{className:"px-3 py-2 border-b border-gray-800 bg-gray-900/80",children:[e.jsx("div",{className:"text-[10px] text-gray-500 uppercase tracking-widest mb-1",children:"Direct-answer rate"}),e.jsxs("div",{className:"text-lg font-bold text-emerald-400",children:[w,"%"]}),e.jsxs("div",{className:"text-[10px] text-gray-600",children:[m," / ",l.length," no tool calls"]})]}),e.jsx("div",{className:"flex gap-1 px-2 py-2 border-b border-gray-800",children:["all","direct","searched"].map(t=>e.jsx("button",{onClick:()=>{y(t),p(0)},className:`flex-1 text-[10px] py-1 rounded border transition-colors capitalize ${b===t?t==="direct"?"bg-emerald-900/60 border-emerald-600 text-emerald-300":t==="searched"?"bg-blue-900/60 border-blue-600 text-blue-300":"bg-gray-700 border-gray-500 text-gray-200":"bg-gray-800/50 border-gray-700 text-gray-500 hover:border-gray-500"}`,children:t},t))}),e.jsxs("div",{className:"px-2 py-1.5 border-b border-gray-800",children:[e.jsx("input",{type:"text",placeholder:"Search query ID…",value:d,onChange:t=>{g(t.target.value),p(0)},className:"w-full bg-gray-800 border border-gray-700 text-gray-200 text-xs rounded px-2 py-1.5 placeholder-gray-600"}),e.jsxs("div",{className:"text-[10px] text-gray-600 mt-1",children:[f.length," / ",l.length]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:f.map((t,c)=>e.jsxs("button",{onClick:()=>p(c),className:`w-full text-left px-3 py-2 border-b border-gray-800/50 text-xs transition-colors ${x===c?"bg-blue-900/40 text-blue-200 border-l-2 border-l-blue-500":"text-gray-400 hover:bg-gray-800"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"font-medium text-gray-200",children:["#",t.query_id]}),t.direct_answer?e.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-emerald-900/60 text-emerald-400 border border-emerald-800",children:"direct"}):e.jsxs("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-blue-900/60 text-blue-400 border border-blue-800",children:[t.total_tool_calls," calls"]})]}),e.jsxs("div",{className:"text-[10px] text-gray-600 mt-0.5",children:["k=",t.k_effective," selected steps"]})]},t.query_id))})]}),a?e.jsxs("div",{className:"flex-1 flex flex-col min-w-0 overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 bg-gray-900/60 border-b border-gray-800 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("span",{className:"text-sm font-medium text-gray-100",children:["Query #",a.query_id]}),a.direct_answer?e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-emerald-900/50 text-emerald-300 border border-emerald-800",children:"Direct answer"}):e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-blue-900/50 text-blue-300 border border-blue-800",children:[a.total_tool_calls," tool calls"]}),e.jsxs("span",{className:"text-xs text-gray-500",children:["k=",a.k_effective," steps selected"]}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${a.status==="completed"?"bg-gray-800 text-gray-400":"bg-amber-900/50 text-amber-300"}`,children:a.status})]}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-widest text-gray-500",children:"Selected steps"}),a.selected_indices.map(t=>e.jsxs("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-gray-800 border border-gray-700 text-gray-300 font-mono",children:["#",t]},t))]}),e.jsxs("div",{className:"mt-1.5 text-xs text-gray-400 leading-snug bg-gray-800/50 rounded px-2 py-1.5 border border-gray-700",children:[e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-widest text-amber-500 mr-2",children:"Rationale"}),a.rationale]})]}),e.jsxs("div",{className:"flex-1 flex overflow-hidden min-w-0",children:[e.jsxs("div",{className:"flex-1 flex flex-col min-w-0 border-r border-gray-800 overflow-hidden",children:[e.jsxs("div",{className:"px-3 py-1.5 bg-gray-900/40 border-b border-gray-800 shrink-0",children:[e.jsx("span",{className:"text-[11px] font-semibold text-amber-400 uppercase tracking-widest",children:"Selected Tool Calls"}),e.jsxs("span",{className:"text-[10px] text-gray-600 ml-2",children:["reference trajectory · ",a.k_effective," steps"]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-3",children:e.jsx(h,{blocks:j})})]}),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0 overflow-hidden",children:[e.jsxs("div",{className:"px-3 py-1.5 bg-gray-900/40 border-b border-gray-800 shrink-0",children:[e.jsx("span",{className:"text-[11px] font-semibold text-sky-400 uppercase tracking-widest",children:"New Trajectory"}),e.jsx("span",{className:"text-[10px] text-gray-600 ml-2",children:"gpt-oss-120b · conditioned on selected steps"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-3",children:e.jsx(h,{blocks:N})})]})]})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center text-gray-500",children:"No query selected."})]})}export{S as default};
frontend/dist/assets/TrajExtApp-B7SGrOTM.js ADDED
@@ -0,0 +1 @@
 
 
1
+ import{r as o,j as e}from"./index-CJnY-Hdk.js";function y(s){if(!s||s==="(no trajectory steps)")return[];const a=[],c=s.split(/\n\n(?=\[)/);for(const n of c){const r=n.trim();r.startsWith("[Reasoning]:")?a.push({type:"reasoning",content:r.slice(12).trim()}):r.startsWith("[Tool call]")?a.push({type:"tool_call",content:r.slice(11).trim()}):r.startsWith("[Tool result]:")?a.push({type:"tool_result",content:r.slice(14).trim()}):r.startsWith("[Final answer]:")?a.push({type:"final_answer",content:r.slice(15).trim()}):r&&a.push({type:"unknown",content:r})}return a}const f={reasoning:{border:"border-purple-700",label:"Reasoning",labelColor:"text-purple-400",bg:"bg-purple-950/30"},tool_call:{border:"border-blue-700",label:"Tool Call",labelColor:"text-blue-400",bg:"bg-blue-950/30"},tool_result:{border:"border-gray-600",label:"Tool Result",labelColor:"text-gray-400",bg:"bg-gray-800/30"},final_answer:{border:"border-green-700",label:"Final Answer",labelColor:"text-green-400",bg:"bg-green-950/30"},unknown:{border:"border-gray-700",label:"—",labelColor:"text-gray-500",bg:""}};function j({text:s}){const a=o.useMemo(()=>y(s),[s]);return a.length===0?e.jsx("div",{className:"text-gray-500 text-xs",children:"No trajectory steps."}):e.jsx("div",{className:"space-y-2",children:a.map((c,n)=>{const r=f[c.type];return e.jsxs("div",{className:`border-l-2 ${r.border} ${r.bg} pl-3 py-1 rounded-r`,children:[e.jsx("div",{className:`text-[10px] font-bold uppercase tracking-widest mb-1 ${r.labelColor}`,children:r.label}),e.jsx("pre",{className:"text-xs text-gray-300 whitespace-pre-wrap font-mono leading-relaxed",children:c.content})]},n)})})}const v=["trajectory","prompt","both"];function w(){const[s,a]=o.useState([]),[c,n]=o.useState(!0),[r,b]=o.useState(null),[u,p]=o.useState(0),[i,h]=o.useState("trajectory"),[x,m]=o.useState("");o.useEffect(()=>{n(!0),fetch("/api/traj-ext/").then(t=>{if(!t.ok)throw new Error(t.statusText);return t.json()}).then(t=>{a(t.rows),n(!1)}).catch(t=>{b(t.message),n(!1)})},[]);const g=o.useMemo(()=>{if(!x.trim())return s;const t=x.toLowerCase();return s.filter(d=>d.query_id.includes(t)||d.question.toLowerCase().includes(t))},[s,x]),l=g[u]??null;return c?e.jsx("div",{className:"h-full flex items-center justify-center text-gray-400",children:"Loading traj-ext data from HuggingFace…"}):r?e.jsxs("div",{className:"h-full flex items-center justify-center text-red-400",children:["Error: ",r]}):e.jsxs("div",{className:"h-full flex overflow-hidden bg-gray-950 text-gray-100",children:[e.jsxs("div",{className:"w-64 shrink-0 flex flex-col border-r border-gray-800 bg-gray-900",children:[e.jsxs("div",{className:"p-2 border-b border-gray-800",children:[e.jsx("input",{type:"text",placeholder:"Search queries…",value:x,onChange:t=>{m(t.target.value),p(0)},className:"w-full bg-gray-800 border border-gray-700 text-gray-200 text-xs rounded px-2 py-1.5 placeholder-gray-600"}),e.jsxs("div",{className:"text-[10px] text-gray-600 mt-1",children:[g.length," / ",s.length," trajectories"]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:g.map((t,d)=>e.jsxs("button",{onClick:()=>p(d),className:`w-full text-left px-3 py-2 border-b border-gray-800/50 text-xs transition-colors ${u===d?"bg-blue-900/40 text-blue-200 border-l-2 border-l-blue-500":"text-gray-400 hover:bg-gray-800"}`,children:[e.jsxs("div",{className:"font-medium text-gray-200",children:["#",t.query_id]}),e.jsxs("div",{className:"text-gray-500 truncate mt-0.5",children:[t.question.slice(0,60),"…"]}),e.jsxs("div",{className:"flex gap-2 mt-1 text-[10px] text-gray-600",children:[e.jsxs("span",{children:[t.n_tool_calls," tools"]}),e.jsxs("span",{children:[t.n_reasoning_steps," reasoning"]}),e.jsx("span",{className:t.status==="completed"?"text-green-600":"text-amber-600",children:t.status})]})]},t.run_id))})]}),l?e.jsxs("div",{className:"flex-1 flex flex-col min-w-0 overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 bg-gray-900/60 border-b border-gray-800 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsxs("span",{className:"text-sm font-medium text-gray-100",children:["Query #",l.query_id]}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${l.status==="completed"?"bg-green-900/50 text-green-300":"bg-amber-900/50 text-amber-300"}`,children:l.status}),e.jsxs("span",{className:"text-xs text-gray-500",children:[l.n_tool_calls," tool calls · ",l.n_reasoning_steps," reasoning"]}),e.jsx("div",{className:"ml-auto flex gap-1",children:v.map(t=>e.jsx("button",{onClick:()=>h(t),className:`px-2 py-0.5 text-xs rounded border transition-colors capitalize ${i===t?"bg-blue-700 border-blue-500 text-white":"bg-gray-800 border-gray-700 text-gray-400 hover:border-gray-500"}`,children:t},t))})]}),e.jsx("div",{className:"mt-1 text-xs text-gray-300 leading-snug",children:l.question})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 min-w-0",children:[(i==="trajectory"||i==="both")&&e.jsxs("div",{children:[i==="both"&&e.jsx("div",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wide mb-2",children:"Trajectory (serialized)"}),e.jsx(j,{text:l.trajectory_text})]}),(i==="prompt"||i==="both")&&e.jsxs("div",{children:[i==="both"&&e.jsx("div",{className:"text-xs font-semibold text-gray-400 uppercase tracking-wide mb-2 mt-4",children:"Full traj_ext Prompt"}),e.jsx("pre",{className:"text-xs font-mono whitespace-pre-wrap text-gray-200 bg-gray-900 border border-gray-700 rounded p-3 leading-relaxed",children:l.formatted_prompt})]})]})]}):e.jsx("div",{className:"flex-1 flex items-center justify-center text-gray-500",children:"No trajectory selected."})]})}export{w as default};
frontend/dist/assets/VisualizerApp-BQRtLE-N.js ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ModelApp-zTXc-dCH.js","assets/index-CJnY-Hdk.js","assets/index-CinLULj0.css","assets/PlanRevisionsApp-DyhuRMap.js","assets/TrajExtApp-B7SGrOTM.js","assets/SelectedToolsApp-caodUoP9.js"])))=>i.map(i=>d[i]);
2
+ import{u as o,j as e,n as d,r as a,_ as r}from"./index-CJnY-Hdk.js";const c=a.lazy(()=>r(()=>import("./ModelApp-zTXc-dCH.js"),__vite__mapDeps([0,1,2]))),n=a.lazy(()=>r(()=>import("./PlanRevisionsApp-DyhuRMap.js"),__vite__mapDeps([3,1,2]))),x=a.lazy(()=>r(()=>import("./TrajExtApp-B7SGrOTM.js"),__vite__mapDeps([4,1,2]))),m=a.lazy(()=>r(()=>import("./SelectedToolsApp-caodUoP9.js"),__vite__mapDeps([5,1,2]))),i=[{id:"model",label:"Model Trace",activeClass:"border-blue-500 text-blue-400"},{id:"plan-revisions",label:"Plan Revisions",activeClass:"border-amber-500 text-amber-400"},{id:"traj-ext",label:"Traj Ext",activeClass:"border-emerald-500 text-emerald-400"},{id:"selected-tools",label:"Selected Tools",activeClass:"border-amber-400 text-amber-300"}],p=new Set(i.map(t=>t.id));function u(){const t=o(),s=p.has(t.tab)?t.tab:"model";return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsx("div",{className:"flex items-center border-b border-gray-800 bg-gray-900/50 px-2 shrink-0",children:i.map(l=>e.jsx("button",{onClick:()=>d({page:"viz",tab:l.id}),className:`px-5 py-2 text-sm font-medium border-b-2 transition-colors ${s===l.id?l.activeClass:"border-transparent text-gray-500 hover:text-gray-300"}`,children:l.label},l.id))}),e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsxs(a.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center h-full text-gray-500",children:"Loading..."}),children:[s==="model"&&e.jsx("div",{className:"theme-model h-full",children:e.jsx(c,{})}),s==="plan-revisions"&&e.jsx("div",{className:"h-full",children:e.jsx(n,{})}),s==="traj-ext"&&e.jsx("div",{className:"h-full",children:e.jsx(x,{})}),s==="selected-tools"&&e.jsx("div",{className:"h-full",children:e.jsx(m,{})})]})})]})}export{u as default};
frontend/dist/assets/index-CJnY-Hdk.js ADDED
The diff for this file is too large to render. See raw diff
 
frontend/dist/index.html CHANGED
@@ -4,7 +4,7 @@
4
  <meta charset="UTF-8" />
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
  <title>RACA Dashboard</title>
7
- <script type="module" crossorigin src="/assets/index-Bb_fUogv.js"></script>
8
  <link rel="stylesheet" crossorigin href="/assets/index-CinLULj0.css">
9
  </head>
10
  <body class="bg-gray-950 text-gray-100">
 
4
  <meta charset="UTF-8" />
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
  <title>RACA Dashboard</title>
7
+ <script type="module" crossorigin src="/assets/index-CJnY-Hdk.js"></script>
8
  <link rel="stylesheet" crossorigin href="/assets/index-CinLULj0.css">
9
  </head>
10
  <body class="bg-gray-950 text-gray-100">
frontend/src/selected_tools/SelectedToolsApp.tsx CHANGED
@@ -245,8 +245,17 @@ export default function SelectedToolsApp() {
245
  {current.status}
246
  </span>
247
  </div>
 
 
 
 
 
 
 
 
 
248
  {/* Rationale */}
249
- <div className="mt-2 text-xs text-gray-400 leading-snug bg-gray-800/50 rounded px-2 py-1.5 border border-gray-700">
250
  <span className="text-[10px] font-bold uppercase tracking-widest text-amber-500 mr-2">Rationale</span>
251
  {current.rationale}
252
  </div>
 
245
  {current.status}
246
  </span>
247
  </div>
248
+ {/* Selected indices */}
249
+ <div className="mt-1.5 flex items-center gap-1.5 flex-wrap">
250
+ <span className="text-[10px] font-bold uppercase tracking-widest text-gray-500">Selected steps</span>
251
+ {current.selected_indices.map(idx => (
252
+ <span key={idx} className="text-[10px] px-1.5 py-0.5 rounded bg-gray-800 border border-gray-700 text-gray-300 font-mono">
253
+ #{idx}
254
+ </span>
255
+ ))}
256
+ </div>
257
  {/* Rationale */}
258
+ <div className="mt-1.5 text-xs text-gray-400 leading-snug bg-gray-800/50 rounded px-2 py-1.5 border border-gray-700">
259
  <span className="text-[10px] font-bold uppercase tracking-widest text-amber-500 mr-2">Rationale</span>
260
  {current.rationale}
261
  </div>