evalution 2.0.2 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +90 -10
- package/dist/client/assets/{DatasetView-DZ2uLHKV.js → DatasetView-B1KoSX7p.js} +4 -4
- package/dist/client/assets/{EvalRunView-T610dLVw.js → EvalRunView-By5RN8fo.js} +1 -1
- package/dist/client/assets/{EvalView-Cae68vPB.js → EvalView-BW2qyhFj.js} +1 -1
- package/dist/client/assets/{data-grid-overlay-editor-PtH7A6E4.js → data-grid-overlay-editor-CQsCX66k.js} +1 -1
- package/dist/client/assets/{highlighted-body-KPVGNVTW-CPtwvSJb.js → highlighted-body-KPVGNVTW-D7b_g0Y9.js} +1 -1
- package/dist/client/assets/{index-BFH07Ynk.js → index-BDqLFfPf.js} +128 -128
- package/dist/client/assets/{number-overlay-editor-BbQhagHP.js → number-overlay-editor-lGaIg9Iu.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/{cost-fetching-trace-sink-Dz8gniQ6.js → cost-fetching-trace-sink-BEqbMdt1.js} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/ingest.js +2 -2
- package/dist/{local-database-trace-provider-87-WGqfS.js → local-database-trace-provider-BHe2hLFA.js} +20 -1
- package/dist/{trace-event-ingestor-B1DYEg2H.js → trace-event-ingestor-fjlL_FYB.js} +50 -9
- package/package.json +5 -5
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as n,g as P,a as ee,c as se,j as s,i as ae,b as te,d as I,E as le,f as z,e as ne,T as ce,s as re,h as ie,k as de,l as H,m as oe,n as me,O as he}from"./index-
|
|
1
|
+
import{r as n,g as P,a as ee,c as se,j as s,i as ae,b as te,d as I,E as le,f as z,e as ne,T as ce,s as re,h as ie,k as de,l as H,m as oe,n as me,O as he}from"./index-BDqLFfPf.js";const ue=500;function ve(c){if(!c)return"";const m=c.score===void 0?"":Number.isInteger(c.score)?String(c.score):c.score.toFixed(2);return[he[c.outcome],m].filter(Boolean).join(" ")}function je({providerId:c,runId:m,version:T,progress:i,onOpenTrace:L,onDeleted:_}){var B;const[l,G]=n.useState(null),[u,J]=n.useState({rows:[],checks:[]}),[p,w]=n.useState(null),[v,K]=n.useState(null),[$,Q]=n.useState([]),[N,D]=n.useState(""),[U,M]=n.useState(!1),[b,O]=n.useState(null),[Y,q]=n.useState(0),k=n.useRef(void 0),A=i==null?void 0:i.done;n.useEffect(()=>{A===void 0||k.current||(k.current=setTimeout(()=>{k.current=void 0,q(e=>e+1)},ue))},[A]),n.useEffect(()=>()=>clearTimeout(k.current),[]),n.useEffect(()=>{let e=!1;return P(c,m).then(a=>{e||(G(a.run),J(a.results))}).catch(a=>!e&&w(a.message)),()=>{e=!0}},[c,m,T,Y]);const C=l==null?void 0:l.evalId;n.useEffect(()=>{C&&ee(c,C).then(e=>{const a=e.filter(t=>t.id!==m);Q(a),D(t=>a.some(j=>j.id===t)?t:"")}).catch(()=>{})},[c,C,m,T]),n.useEffect(()=>{if(O(null),!N)return;let e=!1;return P(c,N).then(a=>!e&&O(a)).catch(a=>!e&&w(a.message)),()=>{e=!0}},[c,N]);const g=n.useMemo(()=>l&&b?se({results:u,arms:l.arms},{results:b.results,arms:b.run.arms}):null,[l,u,b]);if(p&&!l)return s.jsxs("div",{className:"eval-view eval-view-error",children:["Error: ",p]});if(!l)return s.jsx("div",{className:"eval-view"});const h=l.definition.checks,E=e=>{const a=h.find(t=>t.id===e);return(a==null?void 0:a.label)??(a==null?void 0:a.uri.split("#").pop())??e},x=l.arms.filter(e=>!e.error),F=ae(u.checks),R=te(u),W=new Map((g??[]).map(e=>[I(e.armId,e.rowId,e.checkId),e])),S=(i==null?void 0:i.status)??l.status,V=(i==null?void 0:i.done)??u.rows.length,d=v?F.get(v):void 0,y=v?(B=R.find(e=>e.rowId===v.split(":")[1]))==null?void 0:B.arms.get(v.split(":")[0]):void 0,X=async()=>{if(window.confirm(oe(l.startedAt,S==="running"))){M(!0);try{await me(c,m),_()}catch(e){w(e.message),M(!1)}}},Z=(e,a,t)=>{var o;const j=I(e,a,t);K(j);const r=(o=R.find(f=>f.rowId===a))==null?void 0:o.arms.get(e);r!=null&&r.traceId&&r.traceProviderId&&L(r.traceProviderId,r.traceId)};return s.jsxs("div",{className:"eval-view eval-run-view",children:[s.jsxs("div",{className:"trace-view-header",children:[s.jsxs("div",{className:"trace-view-header-row",children:[s.jsxs("div",{className:"trace-view-title",children:[s.jsx(le,{size:14}),s.jsxs("span",{className:"trace-view-name",children:[l.definition.name," · ",z(l.startedAt)]})]}),s.jsxs("div",{className:"trace-view-header-actions",children:[S==="running"&&s.jsx("button",{type:"button",className:"dialog-btn-cancel",onClick:()=>ne(c,m).catch(e=>w(e.message)),children:"Cancel"}),s.jsx("button",{type:"button",className:"trace-view-prompt-btn trace-view-delete-btn",onClick:X,disabled:U,title:"Delete run","aria-label":"Delete run",children:s.jsx(ce,{})})]})]}),s.jsxs("div",{className:"trace-view-meta",children:[s.jsx("span",{className:"trace-view-meta-item",children:S==="running"?s.jsxs(s.Fragment,{children:[s.jsx("progress",{max:l.total,value:V})," ",V,"/",l.total]}):S}),l.startVersion&&s.jsx("span",{className:"trace-view-meta-item",title:`Commit ${l.startVersion}`,children:l.startVersion.slice(0,7)}),l.dirty&&s.jsx("span",{className:"eval-badge",children:"uncommitted changes"}),l.drifted&&s.jsx("span",{className:"eval-badge",children:"drifted"}),$.length>0&&s.jsxs("label",{className:"trace-view-meta-item eval-compare",children:["Compare with",s.jsxs("select",{"aria-label":"Compare with run",value:N,onChange:e=>D(e.target.value),children:[s.jsx("option",{value:"",children:"—"}),$.map(e=>s.jsxs("option",{value:e.id,children:[z(e.startedAt)," (",e.arms.map(a=>a.label).join(", "),")"]},e.id))]})]})]})]}),p&&s.jsx("div",{className:"pg-exec-error",children:p}),s.jsxs("div",{className:"eval-view-body",children:[s.jsx("div",{className:"eval-arm-summaries",children:l.arms.map(e=>{if(e.error)return s.jsxs("div",{className:"eval-arm-summary",children:[s.jsx("div",{className:"eval-arm-label",children:e.label}),s.jsx("div",{className:"eval-check-missing",children:e.error})]},e.id);const a=re(u,e.id,h.map(t=>t.id));return s.jsxs("div",{className:"eval-arm-summary",children:[s.jsx("div",{className:"eval-arm-label",children:e.label}),a.checks.map(t=>s.jsxs("div",{className:"eval-arm-check",children:[s.jsx("span",{children:E(t.checkId)}),s.jsx("span",{className:"eval-arm-rate",children:t.meanScore!==void 0&&t.passRate===void 0?`mean ${t.meanScore.toFixed(2)}`:ie(t.passRate)})]},t.checkId)),s.jsxs("div",{className:"eval-arm-stats",children:[a.rowErrors>0&&s.jsxs("span",{children:[a.rowErrors," row errors"]}),a.totalCost!==void 0&&s.jsx("span",{children:de(a.totalCost)}),a.p50Duration!==void 0&&s.jsxs("span",{children:["p50 ",H(a.p50Duration)," · p95"," ",H(a.p95Duration??a.p50Duration)]})]})]},e.id)})}),g&&s.jsx("p",{className:"eval-compare-summary",children:g.length===0?"No outcome changed.":`${g.filter(e=>e.regressed).length} regressed, ${g.filter(e=>!e.regressed).length} otherwise changed — outlined below.`}),s.jsx("div",{className:"eval-grid-scroll",children:s.jsxs("table",{className:"eval-grid",children:[s.jsxs("thead",{children:[s.jsxs("tr",{children:[s.jsx("th",{rowSpan:x.length>1?2:1,children:"Row"}),x.length>1?x.map(e=>s.jsx("th",{colSpan:h.length||1,children:e.label},e.id)):h.map(e=>s.jsx("th",{children:E(e.id)},e.id))]}),x.length>1&&s.jsx("tr",{children:x.flatMap(e=>h.map(a=>s.jsx("th",{children:E(a.id)},`${e.id}:${a.id}`)))})]}),s.jsx("tbody",{children:R.map(e=>s.jsxs("tr",{children:[s.jsx("td",{className:"eval-grid-row",children:e.rowIndex+1}),x.flatMap(a=>{const t=e.arms.get(a.id);return t&&t.status!=="ok"?[s.jsxs("td",{colSpan:h.length||1,className:`eval-cell eval-cell-${t.status}`,title:t.error,children:[t.status,": ",t.error]},a.id)]:h.map(j=>{const r=I(a.id,e.rowId,j.id),o=F.get(r),f=W.get(r);return s.jsx("td",{className:["eval-cell",o&&`eval-cell-${o.outcome}`,v===r&&"eval-cell-selected",f&&(f.regressed?"eval-cell-regressed":"eval-cell-changed")].filter(Boolean).join(" "),title:[o==null?void 0:o.message,f&&`was ${f.before}`,(t==null?void 0:t.traceIncomplete)&&"The trace was incomplete when checks ran"].filter(Boolean).join(`
|
|
2
2
|
`)||void 0,onClick:()=>Z(a.id,e.rowId,j.id),children:ve(o)},r)})})]},e.rowId))})]})}),d&&s.jsxs("div",{className:"eval-cell-detail",children:[s.jsxs("div",{className:"eval-arm-label",children:["Row ",((y==null?void 0:y.rowIndex)??0)+1," ·"," ",E(d.checkId)," · ",d.outcome,d.score!==void 0&&` (${d.score})`]}),d.message&&s.jsx("pre",{className:"eval-cell-message",children:d.message}),d.details!==void 0&&s.jsx("pre",{className:"eval-cell-message",children:JSON.stringify(d.details,null,2)})]})]})]})}export{je as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{q as Ee,r as f,t as as,u as cs,v as rs,a as Re,w as is,x as ls,y as os,z as K,A as ds,B as us,C as Pe,D as hs,F as ms,G as ps,H as fs,j as s,I as xs,J as vs,T as Be,P as Oe,K as De,e as gs,L as js,R as bs,M as ks,N as ys,Q as Ns,U as ws,V as Ss,W as Cs,X as Is,Y as $s,Z as Es,_ as Rs,$ as Ps,a0 as Os,a1 as Ds,a2 as Fs,f as Fe,h as Ts,a3 as Ms,m as As,n as Bs,a4 as Us,a5 as Ks,a6 as ae,a7 as Ls,a8 as _s,a9 as Vs,aa as Ws,ab as Ys}from"./index-BFH07Ynk.js";function Ue(c,a){var l;return(l=a.find(o=>o.def.name===c.name&&o.def.type.syntax===c.type.syntax))==null?void 0:l.id}function qs(c,a){if((c==null?void 0:c.kind)==="object")return c.properties[a];if((c==null?void 0:c.kind)==="value"&&c.value.kind==="object"){const l=c.value.properties[a];return l&&{kind:"value",value:l}}}function Ke(c,a,l,o,d,m){if(a&&a.kind!=="object")return a;if(!a){const h=Ue(c,o);if(h)return m.push(d),{kind:"dataset",field:h}}if(c.type.kind==="object"){const h={...(a==null?void 0:a.kind)==="object"?a.properties:{}},j=[];for(const x of c.type.properties){const v=Ke(x,h[x.name],qs(l,x.name),o,`${d}.${x.name}`,j);v&&(h[x.name]=v)}const p=j.length>0;return!a&&!p&&l?(m.push(d),l):(m.push(...j),Object.keys(h).length===0?a:{kind:"object",properties:h})}return!a&&l?(m.push(d),l):a}function Hs(c,a,l){const o={...a},d=[...Object.values(c.functionInputs),...Object.values(c.executeInputs)].flatMap(Ee);for(;d.length>0;){const m=d.pop(),h=l==null?void 0:l[m];if(Object.hasOwn(o,m)||!h)continue;const{receipt:j,...p}=h;o[m]=p,d.push(...Object.values(h.args??{}).flatMap(Ee))}return Object.keys(o).length>0?o:void 0}function Qs(c){const{prompt:a,fields:l,stored:o,scope:d="all"}=c,m=[],h=d==="all"?void 0:new Set(d.checkIds),j=(v,w,S,g)=>{const R={...w};for(const $ of v){const r=Ke($,w[$.name],S==null?void 0:S[$.name],l,`${g}:${$.name}`,m);r&&(R[$.name]=r)}return R},p=h?c.inputs:{functionInputs:j(a.functionParameters,c.inputs.functionInputs,o==null?void 0:o.functionInputs,"fn"),executeInputs:j(a.executeParameters??[],c.inputs.executeInputs,o==null?void 0:o.executeInputs,"exec")};if(!h){const v=Hs(p,c.inputs.resources,o==null?void 0:o.resources);v&&(p.resources=v)}const x=c.checks.map(v=>{if(h&&!h.has(v.id))return v;const w=c.checkInfos.find(g=>g.uri===v.uri);if(!w)return v;const S={...v.args};for(const g of w.parameters){if(S[g.name])continue;const R=Ue(g,l);if(R){S[g.name]={kind:"dataset",field:R},m.push(`check:${v.id}:${g.name}`);continue}const $=a.functionParameters.some(r=>r.name===g.name&&r.type.syntax===g.type.syntax)?"function":(a.executeParameters??[]).some(r=>r.name===g.name&&r.type.syntax===g.type.syntax)?"execute":void 0;$&&(S[g.name]={kind:"input",half:$,path:g.name},m.push(`check:${v.id}:${g.name}`))}return{...v,args:S}});return{inputs:p,checks:x,matched:m}}const zs={resources:[]},Gs=400;function Te(c){const a=l=>Object.fromEntries(Object.entries(l).map(([o,d])=>[o,Ls(d)]));return{fn:a(c.inputs.functionInputs),exec:a(c.inputs.executeInputs),checks:Object.fromEntries(c.checks.map(l=>[l.id,a(l.args)])),instances:Is(c.inputs.resources)}}function ce(c){return Object.fromEntries(Object.entries(c).flatMap(([a,l])=>{const o=_s(l);return o?[[a,o]]:[]}))}function Js(c){let a=c.length+1;for(;c.some(l=>l.id===`c${a}`);)a++;return`c${a}`}function Me(c){var a;return(a=Object.entries(c.resources??{}).find(([,l])=>l===Vs))==null?void 0:a[0]}function rt({providerId:c,evalId:a,prompts:l,datasets:o,version:d,datasetVersion:m,progress:h,onOpenRun:j,onRunStarted:p,onOpenPrompt:x,onOpenDataset:v,onDeleted:w,onDuplicated:S,onRunDeleted:g,agents:R=[],onAskAgent:$}){var Ie,$e;const[r,k]=f.useState(null),[T,O]=f.useState(null),[A,E]=f.useState(null),[M,re]=f.useState(),[ie,Le]=f.useState(),[D,_e]=f.useState([]),[le,Z]=f.useState([]),[y,q]=f.useState({fn:{},exec:{},checks:{},instances:{}}),[Ve,oe]=f.useState(new Set),[We,ee]=f.useState(!1),[de,H]=f.useState(""),i=r?as(l,r.prompt):void 0,ue=et(i),I=r&&o.find(e=>e.providerId===r.dataset.providerId&&e.id===r.dataset.id),Q=(i==null?void 0:i.functionParameters)??[],L=(i==null?void 0:i.executeParameters)??[],he=f.useMemo(()=>{var e;return new Map((((e=i==null?void 0:i.inputSources)==null?void 0:e.resources)??[]).map(t=>[t.uri,t]))},[i==null?void 0:i.inputSources]),me=f.useRef(null),_=f.useRef(null),se=e=>{const t=_.current;_.current=e==="all"||t==="all"?"all":{checkIds:[...(t==null?void 0:t.checkIds)??[],...e.checkIds]}};f.useEffect(()=>{let e=!1;return cs(c,a).then(t=>{if(!e&&(k(t),me.current!==a)){me.current=a,_.current=rs(c,a)?"all":null,H(t.name);const n=Te(t);P.current=n,q(n)}}).catch(t=>!e&&O(t.message)),Re(c,a).then(t=>!e&&Z(t)).catch(()=>{}),()=>{e=!0}},[c,a,d]);const pe=Object.values(h).filter(e=>e.evalId===a).map(e=>`${e.runId}:${e.done}`).join();f.useEffect(()=>{pe&&Re(c,a).then(Z).catch(()=>{})},[pe]);const z=r==null?void 0:r.dataset.providerId,G=r==null?void 0:r.dataset.id;f.useEffect(()=>{if(!z||!G)return;let e=!1;const t=n=>{e||(re(n),Le(K({providerId:z,id:G})))};return is(z,G).then(n=>t(n.dataset.fields)).catch(()=>t([])),()=>{e=!0}},[z,G,m]);const fe=i==null?void 0:i.providerId;f.useEffect(()=>{ls().then(e=>{var t,n;return _e(((t=e.find(u=>u.providerId===fe))==null?void 0:t.checks)??((n=e[0])==null?void 0:n.checks)??[])}).catch(()=>{})},[fe]);const J=f.useRef({}),te=f.useRef(void 0),V=f.useCallback(async()=>{clearTimeout(te.current);const e=J.current;if(J.current={},Object.keys(e).length!==0)try{k(await os(c,a,e))}catch(t){E(t.message)}},[c,a]);f.useEffect(()=>()=>void V(),[V]);const F=(e,t=!1)=>{J.current={...J.current,...e},k(n=>n&&{...n,...e}),clearTimeout(te.current),t?V():te.current=setTimeout(()=>void V(),Gs)},ne=e=>{const t=$s(e.instances);return{functionInputs:ce(e.fn),executeInputs:ce(e.exec),...t&&{resources:t}}},B=(e,t)=>t.map(n=>({...n,args:ce(e.checks[n.id]??{})})),P=f.useRef(y),xe=f.useRef(r);xe.current=r;const W=(e,t=(n=>(n=xe.current)==null?void 0:n.checks)()??[])=>{P.current=e,q(e),F({inputs:ne(e),checks:B(e,t)})},Ye=(r==null?void 0:r.checks.map(e=>`${e.id}=${e.uri}`).join())??"";f.useEffect(()=>{const e=_.current;if(!e||!r||!i||!M||ie!==K(r.dataset)||r.checks.length>0&&D.length===0)return;_.current=null;const t={inputs:ne(y),checks:B(y,r.checks)},n=Qs({prompt:i,fields:M,inputs:t.inputs,checks:t.checks,checkInfos:D,stored:ds(i),scope:e});if(n.matched.length===0)return;const u=Te({inputs:n.inputs,checks:n.checks});oe(b=>new Set([...b,...n.matched])),P.current=u,q(u),F({inputs:n.inputs,checks:n.checks})},[r==null?void 0:r.id,i==null?void 0:i.id,M,ie,D,Ye]);const ve=e=>oe(t=>{if(!t.has(e))return t;const n=new Set(t);return n.delete(e),n}),ge=ne(y),qe=r?B(y,r.checks):[],Y=r?us(ge,qe,{...i&&{prompt:i},...M&&{fields:M},checks:D}):[];r&&!i&&Y.unshift("The eval's prompt no longer exists"),r&&!I&&Y.unshift("The eval's dataset no longer exists");const X=Pe(hs(ms(i==null?void 0:i.inputSources,y.instances),{functionParameters:Q,executeParameters:L,bindings:ge,fields:M??[],offerMismatches:!0,newColumn:!0})),je={functionParameters:Q,executeParameters:L,fields:M},be=Pe(Object.fromEntries(((r==null?void 0:r.checks)??[]).map(e=>{var t;return[e.id,ps(((t=D.find(n=>n.uri===e.uri))==null?void 0:t.parameters)??[],je)]}))),ke=(e,t)=>{const n=P.current,u=typeof e=="function"?e(n.instances):e;if(!t)return W({...n,instances:u});const[b,N]=t.kind==="rename"?[t.from,t.to]:[t.name,null];W({fn:ae(n.fn,b,N),exec:ae(n.exec,b,N),checks:Object.fromEntries(Object.entries(n.checks).map(([C,U])=>[C,ae(U,b,N)])),instances:u})},ye=fs({instances:y.instances,catalogByUri:he,rowsMayDeclare:!0,adopt:e=>{const t=Us(P.current.instances,e,he);return ke(t.instances),t.uri},describeOther:(e,t)=>Ks(e,t,je)}),Ne=async(e,t)=>{if(!r||!(i!=null&&i.providerId))return t(null);try{const n=await Ws(r.dataset.providerId,r.dataset.id,"checkUri"in e?{from:{providerId:i.providerId,...e}}:{from:{providerId:i.providerId,promptId:i.id,...e}});re(u=>[...u??[],n]),t(Ys(n.id))}catch(n){E(n.message),t(null)}},He=e=>(t,n)=>{ve(`${e}:${t}`);const u=Me(n),b=N=>{const C={...n.resources};u!==void 0&&(N?C[u]=N:delete C[u]);const U=P.current;W({...U,[e]:{...U[e],[t]:{...n,resources:C}}})};if(u===void 0){const N=P.current;W({...N,[e]:{...N[e],[t]:n}});return}Ne({half:e==="fn"?"function":"execute",path:u?`${t}.${u}`:t},b)},Qe=e=>(t,n)=>{ve(`check:${e.id}:${t}`);const u=Me(n),b=N=>{const C=P.current;W({...C,checks:{...C.checks,[e.id]:{...C.checks[e.id],[t]:N}}})};if(u===void 0)return b(n);Ne({checkUri:e.uri,path:u?`${t}.${u}`:t},N=>{const C={...n.resources};N?C[u]=N:delete C[u],b({...n,resources:C})})},ze=(e,t)=>{if(!r)return;const n=r.checks.map(u=>{if(u.id!==e)return u;const b={...u,...t};return t.threshold===void 0&&"threshold"in t&&delete b.threshold,t.label===void 0&&"label"in t&&delete b.label,b});F({checks:B(y,n)})},Ge=e=>{if(!r)return;const t=Js(r.checks),n=[...r.checks,{id:t,uri:e,args:{}}];se({checkIds:[t]}),F({checks:B(y,n)},!0)},Je=e=>{if(!r)return;const{[e]:t,...n}=y.checks,u={...y,checks:n};P.current=u,q(u),F({checks:B(u,r.checks.filter(b=>b.id!==e))},!0)},we=()=>{ee(!1);const e=de.trim();e&&r&&e!==r.name?F({name:e},!0):r&&H(r.name)},Xe=async()=>{if(r)try{S(await Es(Rs(r),c))}catch(e){E(e.message)}},Ze=async()=>{if(r&&window.confirm(`Delete "${r.name}" and all its runs?`))try{await Ps(c,a),w()}catch(e){E(e.message)}},es=async e=>{var n;const t=(((n=h[e.id])==null?void 0:n.status)??e.status)==="running";if(window.confirm(As(e.startedAt,t)))try{await Bs(c,e.id),Z(u=>u.filter(b=>b.id!==e.id)),g(e)}catch(u){E(u.message)}};if(T)return s.jsxs("div",{className:"eval-view eval-view-error",children:["Error: ",T]});if(!r)return s.jsx("div",{className:"eval-view"});const Se=(e,{key:t,label:n,matchedKey:u,selection:b,onChange:N,sources:C,slots:U})=>s.jsxs("div",{className:"pg-exec-param",children:[s.jsxs("div",{className:"pg-exec-param-label",children:[s.jsxs("span",{className:"pg-exec-param-name",children:[n,e.optional?"":" *"]}),s.jsx("span",{className:"pg-exec-param-type",title:e.type.syntax,children:Ds(e.type.syntax,60)}),Ve.has(u)&&s.jsx("span",{className:"eval-matched",title:"Filled in for you — change it if it's wrong",children:"matched"})]}),e.description&&s.jsx("div",{className:"pg-exec-param-desc",children:e.description}),s.jsx(Fs,{propDef:e,selection:b,onChange:N,resources:C.resources,slots:U,context:ye})]},t),Ce=(e,t)=>e.map(n=>Se(n,{key:`${t}:${n.name}`,label:t==="exec"?`execute.${n.name}`:n.name,matchedKey:`${t}:${n.name}`,selection:y[t][n.name]??{},onChange:u=>He(t)(n.name,u),sources:X,slots:t==="fn"?X.functionSlots:X.executeSlots})),ss=s.jsxs("div",{className:"pg-prompt-header eval-header",children:[s.jsxs("div",{className:"pg-prompt-header-row",children:[We?s.jsx("form",{className:"dataset-view-rename",onSubmit:e=>{e.preventDefault(),we()},children:s.jsx("input",{autoFocus:!0,"aria-label":"Eval name",value:de,onChange:e=>H(e.target.value),onFocus:e=>e.target.select(),onBlur:we,onKeyDown:e=>{e.key==="Escape"&&(H(r.name),ee(!1))}})}):s.jsx("span",{className:"pg-prompt-name",onDoubleClick:()=>ee(!0),title:"Double-click to rename",children:r.name}),s.jsxs("div",{className:"pg-prompt-header-right",children:[A&&s.jsxs("div",{className:"pg-header-error",children:[A,s.jsx("button",{type:"button",className:"pg-dismiss",onClick:()=>E(null),children:"×"})]}),$&&s.jsx(xs,{agents:R,onAsk:$}),s.jsx("button",{type:"button",className:"trace-view-prompt-btn",onClick:Xe,title:"Duplicate eval","aria-label":"Duplicate eval",children:s.jsx(vs,{})}),s.jsx("button",{type:"button",className:"trace-view-prompt-btn trace-view-delete-btn",onClick:Ze,title:"Delete eval","aria-label":"Delete eval",children:s.jsx(Be,{})})]})]}),s.jsxs("div",{className:"eval-header-links",children:[s.jsxs("button",{type:"button",className:"eval-header-link",disabled:!i,title:"Open the prompt",onClick:()=>i&&x(i),children:[s.jsx(Oe,{}),s.jsx("span",{className:"eval-header-link-name",children:(i==null?void 0:i.name)??"Prompt missing"}),i&&"↗"]}),s.jsxs("button",{type:"button",className:"eval-header-link",disabled:!I,title:"Open the dataset",onClick:()=>I&&v(I),children:[s.jsx(De,{}),s.jsx("span",{className:"eval-header-link-name",children:(I==null?void 0:I.name)??"Dataset missing"}),I&&"↗"]})]})]}),ts=s.jsxs("div",{className:"eval-editor",children:[s.jsxs("section",{className:"eval-section",children:[s.jsxs("label",{className:"eval-select-row",children:[s.jsxs("span",{className:"eval-select-label",children:[s.jsx(Oe,{}),"Prompt"]}),s.jsx(Ae,{label:(i==null?void 0:i.name)??"(missing prompt)",children:s.jsxs("select",{className:"pg-model-overlay-select","aria-label":"Prompt",value:i?`${i.providerId}:${i.id}`:"",onChange:e=>{const t=l.find(n=>`${n.providerId}:${n.id}`===e.target.value);t!=null&&t.providerId&&(se("all"),F({prompt:{id:t.globalId??t.id,providerId:t.providerId}},!0))},children:[!i&&s.jsx("option",{value:"",children:"(missing prompt)"}),l.map(e=>s.jsx("option",{value:`${e.providerId}:${e.id}`,children:e.name},`${e.providerId}:${e.id}`))]})})]}),s.jsxs("label",{className:"eval-select-row",children:[s.jsxs("span",{className:"eval-select-label",children:[s.jsx(De,{}),"Dataset"]}),s.jsx(Ae,{label:(I==null?void 0:I.name)??"(missing dataset)",children:s.jsxs("select",{className:"pg-model-overlay-select","aria-label":"Dataset",value:I?K(I):"",onChange:e=>{const t=o.find(n=>K(n)===e.target.value);t&&(se("all"),F({dataset:{providerId:t.providerId,id:t.id}},!0))},children:[!I&&s.jsx("option",{value:"",children:"(missing dataset)"}),o.map(e=>s.jsx("option",{value:K(e),children:e.name},K(e)))]})})]})]}),s.jsxs("section",{className:"eval-section",children:[s.jsx("h4",{className:"pg-msg-header pg-role-label eval-section-title",children:"Checks"}),r.checks.length===0&&s.jsx("p",{className:"eval-empty",children:"Nothing judges a run yet. Add a check to say what a good answer is."}),r.checks.map(e=>{var t;return s.jsx(Xs,{check:e,info:D.find(n=>n.uri===e.uri),onChangeCheck:n=>ze(e.id,n),onRemove:()=>Je(e.id),children:(t=D.find(n=>n.uri===e.uri))==null?void 0:t.parameters.map(n=>{var u,b;return Se(n,{key:`check:${e.id}:${n.name}`,label:n.name,matchedKey:`check:${e.id}:${n.name}`,selection:((u=y.checks[e.id])==null?void 0:u[n.name])??{},onChange:N=>Qe(e)(n.name,N),sources:be[e.id]??zs,slots:((b=be[e.id])==null?void 0:b.functionSlots)??{}})})},e.id)}),s.jsx(Zs,{checks:D,onAdd:Ge})]}),s.jsxs("section",{className:"eval-section",children:[s.jsx("h4",{className:"pg-msg-header pg-role-label eval-section-title",children:"Runs"}),le.length===0?s.jsx("p",{className:"eval-empty",children:"No runs yet. Run it from the panel."}):s.jsx(nt,{runs:le,progress:h,onOpen:e=>j(e,r.name),onCancel:e=>gs(c,e.id).catch(t=>E(t.message)),onDelete:es})]})]}),ns=s.jsxs(js,{title:"Inputs",notice:Y.length>0&&s.jsx("ul",{className:"eval-problems","aria-label":"Problems",children:Y.map(e=>s.jsx("li",{children:e},e))}),footer:s.jsx(tt,{choices:ue,disabled:Y.length>0,onRun:async e=>{await V();try{const t=await ys(c,a,e);p(t,r.name)}catch(t){E(t instanceof Ns?`Can't run: ${t.problems.join("; ")}`:t.message)}}}),children:[i?s.jsxs(s.Fragment,{children:[Ce(Q,"fn"),L.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"pg-exec-section"}),Ce(L,"exec")]}),Q.length+L.length===0&&s.jsx("p",{className:"eval-empty",children:"This prompt takes no inputs."})]}):s.jsx("p",{className:"eval-empty",children:"Choose a prompt."}),s.jsx("div",{className:"pg-exec-section"}),((((Ie=i==null?void 0:i.inputSources)==null?void 0:Ie.resources.length)??0)>0||Object.keys(y.instances).length>0)&&s.jsx(bs,{instances:y.instances,onChange:ke,sources:X,catalog:(($e=i==null?void 0:i.inputSources)==null?void 0:$e.resources)??[],referencedBy:e=>ks(e,y.instances,[{selections:y.fn},{selections:y.exec},...Object.values(y.checks).map(t=>({selections:t}))]),context:ye}),s.jsx("div",{className:"pg-exec-section"}),s.jsx(st,{choices:ue})]});return s.jsx("div",{className:"eval-view",children:s.jsx(ws,{header:ss,editor:ts,panel:ns})})}function Xs({check:c,info:a,onChangeCheck:l,onRemove:o,children:d}){const m=c.label??(a==null?void 0:a.label)??c.uri,h=(a==null?void 0:a.group)!=="Built-in"||c.threshold!==void 0;return s.jsxs("div",{className:"eval-check",children:[s.jsxs("div",{className:"eval-check-header",children:[s.jsx(Os,{className:"eval-check-label",label:"Check name",title:c.uri,value:m,onCommit:j=>l({label:j.trim()||void 0})}),(a==null?void 0:a.group)&&s.jsx("span",{className:"eval-check-group",children:a.group}),s.jsx("button",{type:"button",className:"pg-dismiss eval-check-remove",title:"Remove check","aria-label":`Remove ${m}`,onClick:o,children:"×"})]}),(a==null?void 0:a.description)&&s.jsx("div",{className:"pg-exec-param-desc",children:a.description}),!a&&s.jsx("div",{className:"eval-check-missing",children:"This check no longer exists."}),(a==null?void 0:a.error)&&s.jsx("div",{className:"eval-check-missing",children:a.error}),(d||h)&&s.jsxs("div",{className:"eval-check-fields",children:[d&&s.jsx("div",{className:"eval-check-params",children:d}),h&&s.jsxs("label",{className:"eval-check-threshold",title:"For a check that returns a score: pass at or above this. Left empty, the score is just recorded.",children:[s.jsx("span",{children:"Pass at score ≥"}),s.jsx("input",{type:"number",step:"any",placeholder:"—","aria-label":"Threshold",value:c.threshold??"",onChange:j=>l({threshold:j.target.value===""?void 0:Number(j.target.value)})})]})]})]})}function Ae({label:c,children:a}){return s.jsxs("div",{className:"eval-select",children:[s.jsx("span",{className:"proppy-catalog-label",children:c}),s.jsx("span",{"aria-hidden":!0,className:"proppy-catalog-chevron",children:"▾"}),a]})}function Zs({checks:c,onAdd:a}){const l=new Map;for(const d of c){if(d.error)continue;const m=d.group??"Playground";l.set(m,[...l.get(m)??[],d])}const o=c.filter(d=>d.error);return s.jsxs("div",{className:"eval-add-check",children:[s.jsxs("div",{className:"pg-add-msg-btn pg-add-question",children:["+ Add check",s.jsxs("select",{"aria-label":"Add check",className:"pg-model-overlay-select",value:"",onChange:d=>d.target.value&&a(d.target.value),children:[s.jsx("option",{value:"",children:"+ Add check…"}),[...l].map(([d,m])=>s.jsx("optgroup",{label:d,children:m.map(h=>s.jsx("option",{value:h.uri,title:h.description,children:h.label},h.uri))},d))]})]}),o.map(d=>s.jsxs("div",{className:"pg-exec-error",children:[s.jsx("code",{children:d.uri})," failed to load: ",d.error]},d.uri))]})}function et(c){const[a,l]=f.useState([]),[o,d]=f.useState(),[m,h]=f.useState(new Set(["head"])),[j,p]=f.useState(4),x=f.useRef(void 0),v=a.find(k=>k.wip&&k.onHead),w=a.filter(k=>!k.wip&&k.names.length>0),S=c&&`${c.providerId}:${c.id}`;f.useEffect(()=>{if(!(c!=null&&c.providerId))return;let k=!1;return Promise.all([Ss(c).catch(()=>[]),Cs(c.providerId).catch(()=>{})]).then(([T,O])=>{if(k)return;l(T),d(O);const A=T.find(E=>E.wip&&E.onHead);A&&A.id!==x.current&&(x.current=A.id,h(E=>new Set([...E,"wip"])))}),()=>{k=!0}},[S,c==null?void 0:c.wipId]);const g=k=>h(T=>{const O=new Set(T);return O.has(k)?O.delete(k):O.add(k),O}),R=!v&&w.length===0,$=[...R||m.has("head")?[{kind:"head"}]:[],...v&&m.has("wip")?[{kind:"wip",variation:v.id}]:[],...w.filter(k=>m.has(k.id)).map(k=>({kind:"variation",variation:k.id,label:k.names[0]}))],r=o&&!o.versioned?"⚠️ Results won't record a version.":o&&!o.clean?"⚠️ There are uncommitted changes.":void 0;return{wip:v,named:w,single:R,chosen:m,toggle:g,concurrency:j,setConcurrency:p,arms:$,warning:r}}function st({choices:c}){const{wip:a,named:l,single:o,chosen:d,toggle:m,concurrency:h,setConcurrency:j}=c,p=f.useId();return s.jsxs("div",{className:"eval-run-options",role:"group","aria-labelledby":o?void 0:p,children:[!o&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"pg-exec-param-name",id:p,children:"Run against"}),s.jsxs("label",{children:[s.jsx("input",{type:"checkbox",checked:d.has("head"),onChange:()=>m("head")}),"Working tree"]}),a&&s.jsxs("label",{children:[s.jsx("input",{type:"checkbox",checked:d.has("wip"),onChange:()=>m("wip")}),"Unsaved edits"]}),l.map(x=>s.jsxs("label",{children:[s.jsx("input",{type:"checkbox",checked:d.has(x.id),onChange:()=>m(x.id)}),x.names[0]]},x.id)),s.jsx("div",{className:"pg-exec-section"})]}),s.jsxs("label",{className:"eval-run-concurrency",children:["Parallel workers",s.jsx("input",{type:"number",min:1,value:h,onChange:x=>j(Math.max(1,Number(x.target.value)||1))})]})]})}function tt({choices:c,disabled:a,onRun:l}){const{arms:o,concurrency:d,warning:m}=c,[h,j]=f.useState(!1);return s.jsxs("div",{className:"eval-run-control",children:[m&&s.jsx("p",{className:"eval-run-warning",children:m}),s.jsx("button",{type:"button",className:"pg-run-btn",disabled:a||h||o.length===0,title:a?"Fix the problems below to run":o.length===0?"Choose what to run against":void 0,onClick:async()=>{j(!0),await l({arms:o,concurrency:d}),j(!1)},children:h?"…":"▶ Run"})]})}function nt({runs:c,progress:a,onOpen:l,onCancel:o,onDelete:d}){const[m,h]=f.useState(new Set),j=async p=>{h(x=>new Set(x).add(p.id)),await d(p),h(x=>{const v=new Set(x);return v.delete(p.id),v})};return s.jsx("div",{className:"eval-runs-scroll",children:s.jsx("table",{className:"eval-runs",children:s.jsx("tbody",{children:c.map(p=>{const x=a[p.id],v=(x==null?void 0:x.status)??p.status,w=(x==null?void 0:x.counts)??p.counts,S=(x==null?void 0:x.done)??p.done;return s.jsxs("tr",{className:"eval-run-row",onClick:()=>l(p),children:[s.jsx("td",{children:Fe(p.startedAt)}),s.jsx("td",{children:p.arms.map(g=>g.label).join(" · ")}),s.jsx("td",{children:v==="running"?s.jsxs(s.Fragment,{children:[s.jsx("progress",{max:p.total,value:S})," ",S,"/",p.total]}):s.jsx("span",{className:`eval-status eval-status-${v}`,children:v==="done"?`${Ts(Ms(w))} passing`:v})}),s.jsxs("td",{className:"eval-run-counts",children:[w.fail>0&&s.jsxs("span",{className:"eval-count-fail",children:[w.fail," failed"]}),w.error>0&&s.jsxs("span",{className:"eval-count-error",children:[w.error," errors"]})]}),s.jsxs("td",{className:"eval-run-badges",children:[p.dirty&&s.jsx("span",{className:"eval-badge",title:"Run with uncommitted changes",children:"uncommitted changes"}),p.drifted&&s.jsx("span",{className:"eval-badge",title:"The working tree changed mid-run",children:"drifted"}),v==="running"&&s.jsx("button",{type:"button",className:"dialog-btn-cancel",onClick:g=>{g.stopPropagation(),o(p)},children:"Cancel"})]}),s.jsx("td",{className:"eval-run-actions",children:s.jsx("button",{type:"button",className:"eval-run-delete",title:"Delete run","aria-label":`Delete run from ${Fe(p.startedAt)}`,disabled:m.has(p.id),onClick:g=>{g.stopPropagation(),j(p)},children:s.jsx(Be,{})})})]},p.id)})})})})}export{rt as default};
|
|
1
|
+
import{q as Ee,r as f,t as as,u as cs,v as rs,a as Re,w as is,x as ls,y as os,z as K,A as ds,B as us,C as Pe,D as hs,F as ms,G as ps,H as fs,j as s,I as xs,J as vs,T as Be,P as Oe,K as De,e as gs,L as js,R as bs,M as ks,N as ys,Q as Ns,U as ws,V as Ss,W as Cs,X as Is,Y as $s,Z as Es,_ as Rs,$ as Ps,a0 as Os,a1 as Ds,a2 as Fs,f as Fe,h as Ts,a3 as Ms,m as As,n as Bs,a4 as Us,a5 as Ks,a6 as ae,a7 as Ls,a8 as _s,a9 as Vs,aa as Ws,ab as Ys}from"./index-BDqLFfPf.js";function Ue(c,a){var l;return(l=a.find(o=>o.def.name===c.name&&o.def.type.syntax===c.type.syntax))==null?void 0:l.id}function qs(c,a){if((c==null?void 0:c.kind)==="object")return c.properties[a];if((c==null?void 0:c.kind)==="value"&&c.value.kind==="object"){const l=c.value.properties[a];return l&&{kind:"value",value:l}}}function Ke(c,a,l,o,d,m){if(a&&a.kind!=="object")return a;if(!a){const h=Ue(c,o);if(h)return m.push(d),{kind:"dataset",field:h}}if(c.type.kind==="object"){const h={...(a==null?void 0:a.kind)==="object"?a.properties:{}},j=[];for(const x of c.type.properties){const v=Ke(x,h[x.name],qs(l,x.name),o,`${d}.${x.name}`,j);v&&(h[x.name]=v)}const p=j.length>0;return!a&&!p&&l?(m.push(d),l):(m.push(...j),Object.keys(h).length===0?a:{kind:"object",properties:h})}return!a&&l?(m.push(d),l):a}function Hs(c,a,l){const o={...a},d=[...Object.values(c.functionInputs),...Object.values(c.executeInputs)].flatMap(Ee);for(;d.length>0;){const m=d.pop(),h=l==null?void 0:l[m];if(Object.hasOwn(o,m)||!h)continue;const{receipt:j,...p}=h;o[m]=p,d.push(...Object.values(h.args??{}).flatMap(Ee))}return Object.keys(o).length>0?o:void 0}function Qs(c){const{prompt:a,fields:l,stored:o,scope:d="all"}=c,m=[],h=d==="all"?void 0:new Set(d.checkIds),j=(v,w,S,g)=>{const R={...w};for(const $ of v){const r=Ke($,w[$.name],S==null?void 0:S[$.name],l,`${g}:${$.name}`,m);r&&(R[$.name]=r)}return R},p=h?c.inputs:{functionInputs:j(a.functionParameters,c.inputs.functionInputs,o==null?void 0:o.functionInputs,"fn"),executeInputs:j(a.executeParameters??[],c.inputs.executeInputs,o==null?void 0:o.executeInputs,"exec")};if(!h){const v=Hs(p,c.inputs.resources,o==null?void 0:o.resources);v&&(p.resources=v)}const x=c.checks.map(v=>{if(h&&!h.has(v.id))return v;const w=c.checkInfos.find(g=>g.uri===v.uri);if(!w)return v;const S={...v.args};for(const g of w.parameters){if(S[g.name])continue;const R=Ue(g,l);if(R){S[g.name]={kind:"dataset",field:R},m.push(`check:${v.id}:${g.name}`);continue}const $=a.functionParameters.some(r=>r.name===g.name&&r.type.syntax===g.type.syntax)?"function":(a.executeParameters??[]).some(r=>r.name===g.name&&r.type.syntax===g.type.syntax)?"execute":void 0;$&&(S[g.name]={kind:"input",half:$,path:g.name},m.push(`check:${v.id}:${g.name}`))}return{...v,args:S}});return{inputs:p,checks:x,matched:m}}const zs={resources:[]},Gs=400;function Te(c){const a=l=>Object.fromEntries(Object.entries(l).map(([o,d])=>[o,Ls(d)]));return{fn:a(c.inputs.functionInputs),exec:a(c.inputs.executeInputs),checks:Object.fromEntries(c.checks.map(l=>[l.id,a(l.args)])),instances:Is(c.inputs.resources)}}function ce(c){return Object.fromEntries(Object.entries(c).flatMap(([a,l])=>{const o=_s(l);return o?[[a,o]]:[]}))}function Js(c){let a=c.length+1;for(;c.some(l=>l.id===`c${a}`);)a++;return`c${a}`}function Me(c){var a;return(a=Object.entries(c.resources??{}).find(([,l])=>l===Vs))==null?void 0:a[0]}function rt({providerId:c,evalId:a,prompts:l,datasets:o,version:d,datasetVersion:m,progress:h,onOpenRun:j,onRunStarted:p,onOpenPrompt:x,onOpenDataset:v,onDeleted:w,onDuplicated:S,onRunDeleted:g,agents:R=[],onAskAgent:$}){var Ie,$e;const[r,k]=f.useState(null),[T,O]=f.useState(null),[A,E]=f.useState(null),[M,re]=f.useState(),[ie,Le]=f.useState(),[D,_e]=f.useState([]),[le,Z]=f.useState([]),[y,q]=f.useState({fn:{},exec:{},checks:{},instances:{}}),[Ve,oe]=f.useState(new Set),[We,ee]=f.useState(!1),[de,H]=f.useState(""),i=r?as(l,r.prompt):void 0,ue=et(i),I=r&&o.find(e=>e.providerId===r.dataset.providerId&&e.id===r.dataset.id),Q=(i==null?void 0:i.functionParameters)??[],L=(i==null?void 0:i.executeParameters)??[],he=f.useMemo(()=>{var e;return new Map((((e=i==null?void 0:i.inputSources)==null?void 0:e.resources)??[]).map(t=>[t.uri,t]))},[i==null?void 0:i.inputSources]),me=f.useRef(null),_=f.useRef(null),se=e=>{const t=_.current;_.current=e==="all"||t==="all"?"all":{checkIds:[...(t==null?void 0:t.checkIds)??[],...e.checkIds]}};f.useEffect(()=>{let e=!1;return cs(c,a).then(t=>{if(!e&&(k(t),me.current!==a)){me.current=a,_.current=rs(c,a)?"all":null,H(t.name);const n=Te(t);P.current=n,q(n)}}).catch(t=>!e&&O(t.message)),Re(c,a).then(t=>!e&&Z(t)).catch(()=>{}),()=>{e=!0}},[c,a,d]);const pe=Object.values(h).filter(e=>e.evalId===a).map(e=>`${e.runId}:${e.done}`).join();f.useEffect(()=>{pe&&Re(c,a).then(Z).catch(()=>{})},[pe]);const z=r==null?void 0:r.dataset.providerId,G=r==null?void 0:r.dataset.id;f.useEffect(()=>{if(!z||!G)return;let e=!1;const t=n=>{e||(re(n),Le(K({providerId:z,id:G})))};return is(z,G).then(n=>t(n.dataset.fields)).catch(()=>t([])),()=>{e=!0}},[z,G,m]);const fe=i==null?void 0:i.providerId;f.useEffect(()=>{ls().then(e=>{var t,n;return _e(((t=e.find(u=>u.providerId===fe))==null?void 0:t.checks)??((n=e[0])==null?void 0:n.checks)??[])}).catch(()=>{})},[fe]);const J=f.useRef({}),te=f.useRef(void 0),V=f.useCallback(async()=>{clearTimeout(te.current);const e=J.current;if(J.current={},Object.keys(e).length!==0)try{k(await os(c,a,e))}catch(t){E(t.message)}},[c,a]);f.useEffect(()=>()=>void V(),[V]);const F=(e,t=!1)=>{J.current={...J.current,...e},k(n=>n&&{...n,...e}),clearTimeout(te.current),t?V():te.current=setTimeout(()=>void V(),Gs)},ne=e=>{const t=$s(e.instances);return{functionInputs:ce(e.fn),executeInputs:ce(e.exec),...t&&{resources:t}}},B=(e,t)=>t.map(n=>({...n,args:ce(e.checks[n.id]??{})})),P=f.useRef(y),xe=f.useRef(r);xe.current=r;const W=(e,t=(n=>(n=xe.current)==null?void 0:n.checks)()??[])=>{P.current=e,q(e),F({inputs:ne(e),checks:B(e,t)})},Ye=(r==null?void 0:r.checks.map(e=>`${e.id}=${e.uri}`).join())??"";f.useEffect(()=>{const e=_.current;if(!e||!r||!i||!M||ie!==K(r.dataset)||r.checks.length>0&&D.length===0)return;_.current=null;const t={inputs:ne(y),checks:B(y,r.checks)},n=Qs({prompt:i,fields:M,inputs:t.inputs,checks:t.checks,checkInfos:D,stored:ds(i),scope:e});if(n.matched.length===0)return;const u=Te({inputs:n.inputs,checks:n.checks});oe(b=>new Set([...b,...n.matched])),P.current=u,q(u),F({inputs:n.inputs,checks:n.checks})},[r==null?void 0:r.id,i==null?void 0:i.id,M,ie,D,Ye]);const ve=e=>oe(t=>{if(!t.has(e))return t;const n=new Set(t);return n.delete(e),n}),ge=ne(y),qe=r?B(y,r.checks):[],Y=r?us(ge,qe,{...i&&{prompt:i},...M&&{fields:M},checks:D}):[];r&&!i&&Y.unshift("The eval's prompt no longer exists"),r&&!I&&Y.unshift("The eval's dataset no longer exists");const X=Pe(hs(ms(i==null?void 0:i.inputSources,y.instances),{functionParameters:Q,executeParameters:L,bindings:ge,fields:M??[],offerMismatches:!0,newColumn:!0})),je={functionParameters:Q,executeParameters:L,fields:M},be=Pe(Object.fromEntries(((r==null?void 0:r.checks)??[]).map(e=>{var t;return[e.id,ps(((t=D.find(n=>n.uri===e.uri))==null?void 0:t.parameters)??[],je)]}))),ke=(e,t)=>{const n=P.current,u=typeof e=="function"?e(n.instances):e;if(!t)return W({...n,instances:u});const[b,N]=t.kind==="rename"?[t.from,t.to]:[t.name,null];W({fn:ae(n.fn,b,N),exec:ae(n.exec,b,N),checks:Object.fromEntries(Object.entries(n.checks).map(([C,U])=>[C,ae(U,b,N)])),instances:u})},ye=fs({instances:y.instances,catalogByUri:he,rowsMayDeclare:!0,adopt:e=>{const t=Us(P.current.instances,e,he);return ke(t.instances),t.uri},describeOther:(e,t)=>Ks(e,t,je)}),Ne=async(e,t)=>{if(!r||!(i!=null&&i.providerId))return t(null);try{const n=await Ws(r.dataset.providerId,r.dataset.id,"checkUri"in e?{from:{providerId:i.providerId,...e}}:{from:{providerId:i.providerId,promptId:i.id,...e}});re(u=>[...u??[],n]),t(Ys(n.id))}catch(n){E(n.message),t(null)}},He=e=>(t,n)=>{ve(`${e}:${t}`);const u=Me(n),b=N=>{const C={...n.resources};u!==void 0&&(N?C[u]=N:delete C[u]);const U=P.current;W({...U,[e]:{...U[e],[t]:{...n,resources:C}}})};if(u===void 0){const N=P.current;W({...N,[e]:{...N[e],[t]:n}});return}Ne({half:e==="fn"?"function":"execute",path:u?`${t}.${u}`:t},b)},Qe=e=>(t,n)=>{ve(`check:${e.id}:${t}`);const u=Me(n),b=N=>{const C=P.current;W({...C,checks:{...C.checks,[e.id]:{...C.checks[e.id],[t]:N}}})};if(u===void 0)return b(n);Ne({checkUri:e.uri,path:u?`${t}.${u}`:t},N=>{const C={...n.resources};N?C[u]=N:delete C[u],b({...n,resources:C})})},ze=(e,t)=>{if(!r)return;const n=r.checks.map(u=>{if(u.id!==e)return u;const b={...u,...t};return t.threshold===void 0&&"threshold"in t&&delete b.threshold,t.label===void 0&&"label"in t&&delete b.label,b});F({checks:B(y,n)})},Ge=e=>{if(!r)return;const t=Js(r.checks),n=[...r.checks,{id:t,uri:e,args:{}}];se({checkIds:[t]}),F({checks:B(y,n)},!0)},Je=e=>{if(!r)return;const{[e]:t,...n}=y.checks,u={...y,checks:n};P.current=u,q(u),F({checks:B(u,r.checks.filter(b=>b.id!==e))},!0)},we=()=>{ee(!1);const e=de.trim();e&&r&&e!==r.name?F({name:e},!0):r&&H(r.name)},Xe=async()=>{if(r)try{S(await Es(Rs(r),c))}catch(e){E(e.message)}},Ze=async()=>{if(r&&window.confirm(`Delete "${r.name}" and all its runs?`))try{await Ps(c,a),w()}catch(e){E(e.message)}},es=async e=>{var n;const t=(((n=h[e.id])==null?void 0:n.status)??e.status)==="running";if(window.confirm(As(e.startedAt,t)))try{await Bs(c,e.id),Z(u=>u.filter(b=>b.id!==e.id)),g(e)}catch(u){E(u.message)}};if(T)return s.jsxs("div",{className:"eval-view eval-view-error",children:["Error: ",T]});if(!r)return s.jsx("div",{className:"eval-view"});const Se=(e,{key:t,label:n,matchedKey:u,selection:b,onChange:N,sources:C,slots:U})=>s.jsxs("div",{className:"pg-exec-param",children:[s.jsxs("div",{className:"pg-exec-param-label",children:[s.jsxs("span",{className:"pg-exec-param-name",children:[n,e.optional?"":" *"]}),s.jsx("span",{className:"pg-exec-param-type",title:e.type.syntax,children:Ds(e.type.syntax,60)}),Ve.has(u)&&s.jsx("span",{className:"eval-matched",title:"Filled in for you — change it if it's wrong",children:"matched"})]}),e.description&&s.jsx("div",{className:"pg-exec-param-desc",children:e.description}),s.jsx(Fs,{propDef:e,selection:b,onChange:N,resources:C.resources,slots:U,context:ye})]},t),Ce=(e,t)=>e.map(n=>Se(n,{key:`${t}:${n.name}`,label:t==="exec"?`execute.${n.name}`:n.name,matchedKey:`${t}:${n.name}`,selection:y[t][n.name]??{},onChange:u=>He(t)(n.name,u),sources:X,slots:t==="fn"?X.functionSlots:X.executeSlots})),ss=s.jsxs("div",{className:"pg-prompt-header eval-header",children:[s.jsxs("div",{className:"pg-prompt-header-row",children:[We?s.jsx("form",{className:"dataset-view-rename",onSubmit:e=>{e.preventDefault(),we()},children:s.jsx("input",{autoFocus:!0,"aria-label":"Eval name",value:de,onChange:e=>H(e.target.value),onFocus:e=>e.target.select(),onBlur:we,onKeyDown:e=>{e.key==="Escape"&&(H(r.name),ee(!1))}})}):s.jsx("span",{className:"pg-prompt-name",onDoubleClick:()=>ee(!0),title:"Double-click to rename",children:r.name}),s.jsxs("div",{className:"pg-prompt-header-right",children:[A&&s.jsxs("div",{className:"pg-header-error",children:[A,s.jsx("button",{type:"button",className:"pg-dismiss",onClick:()=>E(null),children:"×"})]}),$&&s.jsx(xs,{agents:R,onAsk:$}),s.jsx("button",{type:"button",className:"trace-view-prompt-btn",onClick:Xe,title:"Duplicate eval","aria-label":"Duplicate eval",children:s.jsx(vs,{})}),s.jsx("button",{type:"button",className:"trace-view-prompt-btn trace-view-delete-btn",onClick:Ze,title:"Delete eval","aria-label":"Delete eval",children:s.jsx(Be,{})})]})]}),s.jsxs("div",{className:"eval-header-links",children:[s.jsxs("button",{type:"button",className:"eval-header-link",disabled:!i,title:"Open the prompt",onClick:()=>i&&x(i),children:[s.jsx(Oe,{}),s.jsx("span",{className:"eval-header-link-name",children:(i==null?void 0:i.name)??"Prompt missing"}),i&&"↗"]}),s.jsxs("button",{type:"button",className:"eval-header-link",disabled:!I,title:"Open the dataset",onClick:()=>I&&v(I),children:[s.jsx(De,{}),s.jsx("span",{className:"eval-header-link-name",children:(I==null?void 0:I.name)??"Dataset missing"}),I&&"↗"]})]})]}),ts=s.jsxs("div",{className:"eval-editor",children:[s.jsxs("section",{className:"eval-section",children:[s.jsxs("label",{className:"eval-select-row",children:[s.jsxs("span",{className:"eval-select-label",children:[s.jsx(Oe,{}),"Prompt"]}),s.jsx(Ae,{label:(i==null?void 0:i.name)??"(missing prompt)",children:s.jsxs("select",{className:"pg-model-overlay-select","aria-label":"Prompt",value:i?`${i.providerId}:${i.id}`:"",onChange:e=>{const t=l.find(n=>`${n.providerId}:${n.id}`===e.target.value);t!=null&&t.providerId&&(se("all"),F({prompt:{id:t.globalId??t.id,providerId:t.providerId}},!0))},children:[!i&&s.jsx("option",{value:"",children:"(missing prompt)"}),l.map(e=>s.jsx("option",{value:`${e.providerId}:${e.id}`,children:e.name},`${e.providerId}:${e.id}`))]})})]}),s.jsxs("label",{className:"eval-select-row",children:[s.jsxs("span",{className:"eval-select-label",children:[s.jsx(De,{}),"Dataset"]}),s.jsx(Ae,{label:(I==null?void 0:I.name)??"(missing dataset)",children:s.jsxs("select",{className:"pg-model-overlay-select","aria-label":"Dataset",value:I?K(I):"",onChange:e=>{const t=o.find(n=>K(n)===e.target.value);t&&(se("all"),F({dataset:{providerId:t.providerId,id:t.id}},!0))},children:[!I&&s.jsx("option",{value:"",children:"(missing dataset)"}),o.map(e=>s.jsx("option",{value:K(e),children:e.name},K(e)))]})})]})]}),s.jsxs("section",{className:"eval-section",children:[s.jsx("h4",{className:"pg-msg-header pg-role-label eval-section-title",children:"Checks"}),r.checks.length===0&&s.jsx("p",{className:"eval-empty",children:"Nothing judges a run yet. Add a check to say what a good answer is."}),r.checks.map(e=>{var t;return s.jsx(Xs,{check:e,info:D.find(n=>n.uri===e.uri),onChangeCheck:n=>ze(e.id,n),onRemove:()=>Je(e.id),children:(t=D.find(n=>n.uri===e.uri))==null?void 0:t.parameters.map(n=>{var u,b;return Se(n,{key:`check:${e.id}:${n.name}`,label:n.name,matchedKey:`check:${e.id}:${n.name}`,selection:((u=y.checks[e.id])==null?void 0:u[n.name])??{},onChange:N=>Qe(e)(n.name,N),sources:be[e.id]??zs,slots:((b=be[e.id])==null?void 0:b.functionSlots)??{}})})},e.id)}),s.jsx(Zs,{checks:D,onAdd:Ge})]}),s.jsxs("section",{className:"eval-section",children:[s.jsx("h4",{className:"pg-msg-header pg-role-label eval-section-title",children:"Runs"}),le.length===0?s.jsx("p",{className:"eval-empty",children:"No runs yet. Run it from the panel."}):s.jsx(nt,{runs:le,progress:h,onOpen:e=>j(e,r.name),onCancel:e=>gs(c,e.id).catch(t=>E(t.message)),onDelete:es})]})]}),ns=s.jsxs(js,{title:"Inputs",notice:Y.length>0&&s.jsx("ul",{className:"eval-problems","aria-label":"Problems",children:Y.map(e=>s.jsx("li",{children:e},e))}),footer:s.jsx(tt,{choices:ue,disabled:Y.length>0,onRun:async e=>{await V();try{const t=await ys(c,a,e);p(t,r.name)}catch(t){E(t instanceof Ns?`Can't run: ${t.problems.join("; ")}`:t.message)}}}),children:[i?s.jsxs(s.Fragment,{children:[Ce(Q,"fn"),L.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"pg-exec-section"}),Ce(L,"exec")]}),Q.length+L.length===0&&s.jsx("p",{className:"eval-empty",children:"This prompt takes no inputs."})]}):s.jsx("p",{className:"eval-empty",children:"Choose a prompt."}),s.jsx("div",{className:"pg-exec-section"}),((((Ie=i==null?void 0:i.inputSources)==null?void 0:Ie.resources.length)??0)>0||Object.keys(y.instances).length>0)&&s.jsx(bs,{instances:y.instances,onChange:ke,sources:X,catalog:(($e=i==null?void 0:i.inputSources)==null?void 0:$e.resources)??[],referencedBy:e=>ks(e,y.instances,[{selections:y.fn},{selections:y.exec},...Object.values(y.checks).map(t=>({selections:t}))]),context:ye}),s.jsx("div",{className:"pg-exec-section"}),s.jsx(st,{choices:ue})]});return s.jsx("div",{className:"eval-view",children:s.jsx(ws,{header:ss,editor:ts,panel:ns})})}function Xs({check:c,info:a,onChangeCheck:l,onRemove:o,children:d}){const m=c.label??(a==null?void 0:a.label)??c.uri,h=(a==null?void 0:a.group)!=="Built-in"||c.threshold!==void 0;return s.jsxs("div",{className:"eval-check",children:[s.jsxs("div",{className:"eval-check-header",children:[s.jsx(Os,{className:"eval-check-label",label:"Check name",title:c.uri,value:m,onCommit:j=>l({label:j.trim()||void 0})}),(a==null?void 0:a.group)&&s.jsx("span",{className:"eval-check-group",children:a.group}),s.jsx("button",{type:"button",className:"pg-dismiss eval-check-remove",title:"Remove check","aria-label":`Remove ${m}`,onClick:o,children:"×"})]}),(a==null?void 0:a.description)&&s.jsx("div",{className:"pg-exec-param-desc",children:a.description}),!a&&s.jsx("div",{className:"eval-check-missing",children:"This check no longer exists."}),(a==null?void 0:a.error)&&s.jsx("div",{className:"eval-check-missing",children:a.error}),(d||h)&&s.jsxs("div",{className:"eval-check-fields",children:[d&&s.jsx("div",{className:"eval-check-params",children:d}),h&&s.jsxs("label",{className:"eval-check-threshold",title:"For a check that returns a score: pass at or above this. Left empty, the score is just recorded.",children:[s.jsx("span",{children:"Pass at score ≥"}),s.jsx("input",{type:"number",step:"any",placeholder:"—","aria-label":"Threshold",value:c.threshold??"",onChange:j=>l({threshold:j.target.value===""?void 0:Number(j.target.value)})})]})]})]})}function Ae({label:c,children:a}){return s.jsxs("div",{className:"eval-select",children:[s.jsx("span",{className:"proppy-catalog-label",children:c}),s.jsx("span",{"aria-hidden":!0,className:"proppy-catalog-chevron",children:"▾"}),a]})}function Zs({checks:c,onAdd:a}){const l=new Map;for(const d of c){if(d.error)continue;const m=d.group??"Playground";l.set(m,[...l.get(m)??[],d])}const o=c.filter(d=>d.error);return s.jsxs("div",{className:"eval-add-check",children:[s.jsxs("div",{className:"pg-add-msg-btn pg-add-question",children:["+ Add check",s.jsxs("select",{"aria-label":"Add check",className:"pg-model-overlay-select",value:"",onChange:d=>d.target.value&&a(d.target.value),children:[s.jsx("option",{value:"",children:"+ Add check…"}),[...l].map(([d,m])=>s.jsx("optgroup",{label:d,children:m.map(h=>s.jsx("option",{value:h.uri,title:h.description,children:h.label},h.uri))},d))]})]}),o.map(d=>s.jsxs("div",{className:"pg-exec-error",children:[s.jsx("code",{children:d.uri})," failed to load: ",d.error]},d.uri))]})}function et(c){const[a,l]=f.useState([]),[o,d]=f.useState(),[m,h]=f.useState(new Set(["head"])),[j,p]=f.useState(4),x=f.useRef(void 0),v=a.find(k=>k.wip&&k.onHead),w=a.filter(k=>!k.wip&&k.names.length>0),S=c&&`${c.providerId}:${c.id}`;f.useEffect(()=>{if(!(c!=null&&c.providerId))return;let k=!1;return Promise.all([Ss(c).catch(()=>[]),Cs(c.providerId).catch(()=>{})]).then(([T,O])=>{if(k)return;l(T),d(O);const A=T.find(E=>E.wip&&E.onHead);A&&A.id!==x.current&&(x.current=A.id,h(E=>new Set([...E,"wip"])))}),()=>{k=!0}},[S,c==null?void 0:c.wipId]);const g=k=>h(T=>{const O=new Set(T);return O.has(k)?O.delete(k):O.add(k),O}),R=!v&&w.length===0,$=[...R||m.has("head")?[{kind:"head"}]:[],...v&&m.has("wip")?[{kind:"wip",variation:v.id}]:[],...w.filter(k=>m.has(k.id)).map(k=>({kind:"variation",variation:k.id,label:k.names[0]}))],r=o&&!o.versioned?"⚠️ Results won't record a version.":o&&!o.clean?"⚠️ There are uncommitted changes.":void 0;return{wip:v,named:w,single:R,chosen:m,toggle:g,concurrency:j,setConcurrency:p,arms:$,warning:r}}function st({choices:c}){const{wip:a,named:l,single:o,chosen:d,toggle:m,concurrency:h,setConcurrency:j}=c,p=f.useId();return s.jsxs("div",{className:"eval-run-options",role:"group","aria-labelledby":o?void 0:p,children:[!o&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"pg-exec-param-name",id:p,children:"Run against"}),s.jsxs("label",{children:[s.jsx("input",{type:"checkbox",checked:d.has("head"),onChange:()=>m("head")}),"Working tree"]}),a&&s.jsxs("label",{children:[s.jsx("input",{type:"checkbox",checked:d.has("wip"),onChange:()=>m("wip")}),"Unsaved edits"]}),l.map(x=>s.jsxs("label",{children:[s.jsx("input",{type:"checkbox",checked:d.has(x.id),onChange:()=>m(x.id)}),x.names[0]]},x.id)),s.jsx("div",{className:"pg-exec-section"})]}),s.jsxs("label",{className:"eval-run-concurrency",children:["Parallel workers",s.jsx("input",{type:"number",min:1,value:h,onChange:x=>j(Math.max(1,Number(x.target.value)||1))})]})]})}function tt({choices:c,disabled:a,onRun:l}){const{arms:o,concurrency:d,warning:m}=c,[h,j]=f.useState(!1);return s.jsxs("div",{className:"eval-run-control",children:[m&&s.jsx("p",{className:"eval-run-warning",children:m}),s.jsx("button",{type:"button",className:"pg-run-btn",disabled:a||h||o.length===0,title:a?"Fix the problems below to run":o.length===0?"Choose what to run against":void 0,onClick:async()=>{j(!0),await l({arms:o,concurrency:d}),j(!1)},children:h?"…":"▶ Run"})]})}function nt({runs:c,progress:a,onOpen:l,onCancel:o,onDelete:d}){const[m,h]=f.useState(new Set),j=async p=>{h(x=>new Set(x).add(p.id)),await d(p),h(x=>{const v=new Set(x);return v.delete(p.id),v})};return s.jsx("div",{className:"eval-runs-scroll",children:s.jsx("table",{className:"eval-runs",children:s.jsx("tbody",{children:c.map(p=>{const x=a[p.id],v=(x==null?void 0:x.status)??p.status,w=(x==null?void 0:x.counts)??p.counts,S=(x==null?void 0:x.done)??p.done;return s.jsxs("tr",{className:"eval-run-row",onClick:()=>l(p),children:[s.jsx("td",{children:Fe(p.startedAt)}),s.jsx("td",{children:p.arms.map(g=>g.label).join(" · ")}),s.jsx("td",{children:v==="running"?s.jsxs(s.Fragment,{children:[s.jsx("progress",{max:p.total,value:S})," ",S,"/",p.total]}):s.jsx("span",{className:`eval-status eval-status-${v}`,children:v==="done"?`${Ts(Ms(w))} passing`:v})}),s.jsxs("td",{className:"eval-run-counts",children:[w.fail>0&&s.jsxs("span",{className:"eval-count-fail",children:[w.fail," failed"]}),w.error>0&&s.jsxs("span",{className:"eval-count-error",children:[w.error," errors"]})]}),s.jsxs("td",{className:"eval-run-badges",children:[p.dirty&&s.jsx("span",{className:"eval-badge",title:"Run with uncommitted changes",children:"uncommitted changes"}),p.drifted&&s.jsx("span",{className:"eval-badge",title:"The working tree changed mid-run",children:"drifted"}),v==="running"&&s.jsx("button",{type:"button",className:"dialog-btn-cancel",onClick:g=>{g.stopPropagation(),o(p)},children:"Cancel"})]}),s.jsx("td",{className:"eval-run-actions",children:s.jsx("button",{type:"button",className:"eval-run-delete",title:"Delete run","aria-label":`Delete run from ${Fe(p.startedAt)}`,disabled:m.has(p.id),onClick:g=>{g.stopPropagation(),j(p)},children:s.jsx(Be,{})})})]},p.id)})})})})}export{rt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r,ac as U}from"./index-
|
|
1
|
+
import{r,ac as U}from"./index-BDqLFfPf.js";import{s as Z,i as T,a as ee,b as te,T as re,C as ne,m as ie}from"./DatasetView-B1KoSX7p.js";const se=()=>t=>t.targetX,ae=()=>t=>t.targetY,oe=()=>t=>t.targetWidth,de=()=>t=>t.targetHeight,le=()=>t=>t.targetY+10,ue=()=>t=>Math.max(0,(t.targetHeight-28)/2),ce=Z("div")({name:"DataGridOverlayEditorStyle",class:"gdg-d19meir1",propsAsIs:!1,vars:{"d19meir1-0":[ae(),"px"],"d19meir1-1":[se(),"px"],"d19meir1-2":[oe(),"px"],"d19meir1-3":[de(),"px"],"d19meir1-4":[le(),"px"],"d19meir1-5":[ue(),"px"]}});function fe(){const[t,s]=r.useState();return[t??void 0,s]}function ge(){const[t,s]=fe(),[i,y]=r.useState(0),[m,S]=r.useState(!0);r.useLayoutEffect(()=>{if(t===void 0||!("IntersectionObserver"in window))return;const a=new IntersectionObserver(o=>{o.length!==0&&S(o[0].isIntersecting)},{threshold:1});return a.observe(t),()=>a.disconnect()},[t]),r.useEffect(()=>{if(m||t===void 0)return;let a;const o=()=>{const{right:R}=t.getBoundingClientRect();y(p=>Math.min(p+window.innerWidth-R-10,0)),a=requestAnimationFrame(o)};return a=requestAnimationFrame(o),()=>{a!==void 0&&cancelAnimationFrame(a)}},[t,m]);const k=r.useMemo(()=>({transform:`translateX(${i}px)`}),[i]);return{ref:s,style:k}}const he=t=>{const{target:s,content:i,onFinishEditing:y,forceEditMode:m,initialValue:S,imageEditorOverride:k,markdownDivCreateNode:a,highlight:o,className:R,theme:p,id:A,cell:h,bloom:c,portalElementRef:E,validateCell:d,getCellRenderer:M,provideEditor:v,isOutsideClick:K,customEventTarget:Y,activation:D}=t,[l,j]=r.useState(m?i:void 0),I=r.useRef(l??i);I.current=l??i;const[C,w]=r.useState(()=>d===void 0?!0:!(T(i)&&(d==null?void 0:d(h,i,I.current))===!1)),f=r.useCallback((e,n)=>{y(C?e:void 0,n)},[C,y]),L=r.useCallback(e=>{if(d!==void 0&&e!==void 0&&T(e)){const n=d(h,e,I.current);n===!1?w(!1):(typeof n=="object"&&(e=n),w(!0))}j(e)},[h,d]),b=r.useRef(!1),g=r.useRef(void 0),q=r.useCallback(()=>{f(l,[0,0]),b.current=!0},[l,f]),B=r.useCallback((e,n)=>{f(e,n??g.current??[0,0]),b.current=!0},[f]),$=r.useCallback(async e=>{let n=!1;e.key==="Escape"?(e.stopPropagation(),e.preventDefault(),g.current=[0,0]):e.key==="Enter"&&!e.shiftKey?(e.stopPropagation(),e.preventDefault(),g.current=[0,1],n=!0):e.key==="Tab"&&(e.stopPropagation(),e.preventDefault(),g.current=[e.shiftKey?-1:1,0],n=!0),window.setTimeout(()=>{!b.current&&g.current!==void 0&&(f(n?l:void 0,g.current),b.current=!0)},0)},[f,l]),F=l??i,[u,z]=r.useMemo(()=>{var O,X;if(ee(i))return[];const e={...i,location:h,activation:D},n=v==null?void 0:v(e);return n!==void 0?[n,!1]:[(X=(O=M(i))==null?void 0:O.provideEditor)==null?void 0:X.call(O,e),!1]},[h,i,M,v,D]),{ref:J,style:Q}=ge();let _=!0,N,V=!0,x;if(u!==void 0){_=u.disablePadding!==!0,V=u.disableStyling!==!0;const e=te(u);e&&(x=u.styleOverride);const n=e?u.editor:u;N=r.createElement(n,{portalElementRef:E,isHighlighted:o,activation:D,onChange:L,value:F,initialValue:S,onFinishedEditing:B,validatedSelection:T(F)?F.selectionRange:void 0,forceEditMode:m,target:s,imageEditorOverride:k,markdownDivCreateNode:a,isValid:C,theme:p})}x={...x,...Q};const G=(E==null?void 0:E.current)??document.getElementById("portal");if(G===null)return console.error('Cannot open Data Grid overlay editor, because portal not found. Please, either provide a portalElementRef or add `<div id="portal" />` as the last child of your `<body>`.'),null;let P=V?"gdg-style":"gdg-unstyle";C||(P+=" gdg-invalid"),_&&(P+=" gdg-pad");const H=(c==null?void 0:c[0])??1,W=(c==null?void 0:c[1])??1;return U.createPortal(r.createElement(re.Provider,{value:p},r.createElement(ne,{style:ie(p),className:R,onClickOutside:q,isOutsideClick:K,customEventTarget:Y},r.createElement(ce,{ref:J,id:A,className:P,style:x,as:z===!0?"label":void 0,targetX:s.x-H,targetY:s.y-W,targetWidth:s.width+H*2,targetHeight:s.height+W*2},r.createElement("div",{className:"gdg-clip-region",onKeyDown:$},N)))),G)};export{he as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r,S as p,o as d,j as f,p as E}from"./index-
|
|
1
|
+
import{r,S as p,o as d,j as f,p as E}from"./index-BDqLFfPf.js";var j=({code:i,language:e,maxHeight:g,raw:a,className:u,startLine:m,lineNumbers:n,...h})=>{let{shikiTheme:l}=r.useContext(p),t=d(),[x,s]=r.useState(a);return r.useEffect(()=>{if(!t){s(a);return}let o=t.highlight({code:i,language:e,themes:l},c=>{s(c)});o&&s(o)},[i,e,l,t,a]),f.jsx(E,{className:u,language:e,lineNumbers:n,maxHeight:g,result:x,startLine:m,...h})};export{j as HighlightedCodeBlockBody};
|