promptfoo 0.49.3 → 0.50.0

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.
Files changed (74) hide show
  1. package/dist/package.json +2 -1
  2. package/dist/src/__mocks__/esm.d.ts +1 -0
  3. package/dist/src/__mocks__/esm.d.ts.map +1 -1
  4. package/dist/src/__mocks__/esm.js +33 -1
  5. package/dist/src/__mocks__/esm.js.map +1 -1
  6. package/dist/src/assertions.d.ts.map +1 -1
  7. package/dist/src/assertions.js +11 -7
  8. package/dist/src/assertions.js.map +1 -1
  9. package/dist/src/constants.d.ts.map +1 -1
  10. package/dist/src/constants.js +5 -2
  11. package/dist/src/constants.js.map +1 -1
  12. package/dist/src/esm.d.ts +1 -0
  13. package/dist/src/esm.d.ts.map +1 -1
  14. package/dist/src/esm.js +36 -2
  15. package/dist/src/esm.js.map +1 -1
  16. package/dist/src/evaluator.d.ts +1 -0
  17. package/dist/src/evaluator.d.ts.map +1 -1
  18. package/dist/src/evaluator.js +39 -9
  19. package/dist/src/evaluator.js.map +1 -1
  20. package/dist/src/index.js +1 -1
  21. package/dist/src/index.js.map +1 -1
  22. package/dist/src/main.d.ts +1 -1
  23. package/dist/src/main.d.ts.map +1 -1
  24. package/dist/src/main.js +8 -2
  25. package/dist/src/main.js.map +1 -1
  26. package/dist/src/prompts.d.ts +1 -1
  27. package/dist/src/prompts.d.ts.map +1 -1
  28. package/dist/src/prompts.js +8 -11
  29. package/dist/src/prompts.js.map +1 -1
  30. package/dist/src/providers.d.ts.map +1 -1
  31. package/dist/src/providers.js +3 -24
  32. package/dist/src/providers.js.map +1 -1
  33. package/dist/src/testCases.d.ts.map +1 -1
  34. package/dist/src/testCases.js +25 -8
  35. package/dist/src/testCases.js.map +1 -1
  36. package/dist/src/util.d.ts +3 -3
  37. package/dist/src/util.d.ts.map +1 -1
  38. package/dist/src/util.js +39 -9
  39. package/dist/src/util.js.map +1 -1
  40. package/dist/src/web/nextui/404/index.html +1 -1
  41. package/dist/src/web/nextui/404.html +1 -1
  42. package/dist/src/web/nextui/_next/static/chunks/670-8cc4b4f4fc7b80ad.js +1 -0
  43. package/dist/src/web/nextui/_next/static/chunks/app/eval/[id]/{page-bba5a197d928a824.js → page-b7184244049e5915.js} +1 -1
  44. package/dist/src/web/nextui/_next/static/chunks/app/eval/page-d0218b6214481455.js +1 -0
  45. package/dist/src/web/nextui/_next/static/chunks/app/setup/{page-c3d032b73f8d1cc5.js → page-f5a10b7790f14c70.js} +1 -1
  46. package/dist/src/web/nextui/_next/static/chunks/{main-8674b1b080b54762.js → main-61a7cc8906bd5722.js} +1 -1
  47. package/dist/src/web/nextui/_next/static/chunks/webpack-a35a338695cdcd13.js +1 -0
  48. package/dist/src/web/nextui/_next/static/css/635638c73d973eb7.css +1 -0
  49. package/dist/src/web/nextui/_next/static/css/dded26353bff8496.css +1 -0
  50. package/dist/src/web/nextui/api/datasets +1 -0
  51. package/dist/src/web/nextui/api/prompts +1 -0
  52. package/dist/src/web/nextui/api/results +1 -1
  53. package/dist/src/web/nextui/auth/login/index.html +1 -1
  54. package/dist/src/web/nextui/auth/login/index.txt +3 -3
  55. package/dist/src/web/nextui/auth/signup/index.html +1 -1
  56. package/dist/src/web/nextui/auth/signup/index.txt +3 -3
  57. package/dist/src/web/nextui/datasets/index.html +1 -1
  58. package/dist/src/web/nextui/datasets/index.txt +3 -3
  59. package/dist/src/web/nextui/eval/index.html +1 -1
  60. package/dist/src/web/nextui/eval/index.txt +6 -6
  61. package/dist/src/web/nextui/index.html +1 -1
  62. package/dist/src/web/nextui/index.txt +3 -3
  63. package/dist/src/web/nextui/prompts/index.html +1 -1
  64. package/dist/src/web/nextui/prompts/index.txt +3 -3
  65. package/dist/src/web/nextui/setup/index.html +2 -2
  66. package/dist/src/web/nextui/setup/index.txt +5 -5
  67. package/package.json +2 -1
  68. package/dist/src/web/nextui/_next/static/chunks/952-ede6b209625d42a2.js +0 -1
  69. package/dist/src/web/nextui/_next/static/chunks/app/eval/page-f10300e40e4331ab.js +0 -1
  70. package/dist/src/web/nextui/_next/static/chunks/webpack-939efbb9ee2a5baf.js +0 -1
  71. package/dist/src/web/nextui/_next/static/css/87fb00eed311e9cd.css +0 -1
  72. package/dist/src/web/nextui/_next/static/css/e162c4971c41c2ac.css +0 -1
  73. /package/dist/src/web/nextui/_next/static/{v43WJXuuwBbzUsNlukiI- → vh97xvBohjbcaZhzFItCJ}/_buildManifest.js +0 -0
  74. /package/dist/src/web/nextui/_next/static/{v43WJXuuwBbzUsNlukiI- → vh97xvBohjbcaZhzFItCJ}/_ssgManifest.js +0 -0
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[952],{2810:function(e,t,s){"use strict";let n,l;async function r(){if(n||(l||(l=fetch("/api/config").then(e=>e.json()).then(e=>n=e.apiBaseUrl)),await l),void 0===n)throw Error("API base URL is undefined");return n}s.d(t,{b:function(){return r}})},9952:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return eA}});var n=s(7437),l=s(2265),r=s(2130),i=s(6882),a=s(3388),o=s(4033),c=s(3082),d=s(8440),u=s(6507),p=s(5551),h=s(7760),m=s(3391),x=s(4081),j=s(3226),g=s(819),f=s(8212),v=s(5507),b=s(923),y=s(654),Z=s(3295),C=s(2467),k=s(3457),w=s(1975),S=s(8276),N=s(9605),R=s(9190),E=s(2053),P=s(6704),O=s(9394),F=s(1797),I=s(6337),T=s(1101),L=s(9872),M=s(2653),D=s(3533),A=s(4740),U=s(4660);let _=(0,U.Ue)(e=>({evalId:null,setEvalId:t=>e(()=>({evalId:t})),table:null,setTable:t=>e(()=>({table:t})),config:null,setConfig:t=>e(()=>({config:t})),maxTextLength:250,setMaxTextLength:t=>e(()=>({maxTextLength:t})),wordBreak:"break-word",setWordBreak:t=>e(()=>({wordBreak:t})),showInferenceDetails:!0,setShowInferenceDetails:t=>e(()=>({showInferenceDetails:t})),renderMarkdown:!1,setRenderMarkdown:t=>e(()=>({renderMarkdown:t})),prettifyJson:!1,setPrettifyJson:t=>e(()=>({prettifyJson:t}))})),W=["#fd7f6f","#7eb0d5","#b2e061","#bd7ebe","#ffb55a","#ffee65","#beb9db","#fdcce5","#8bd3c7"];function V(e){let{table:t}=e,s=(0,l.useRef)(null),r=(0,l.useRef)(null);return(0,l.useEffect)(()=>{if(!s.current)return;r.current&&r.current.destroy();let e=t.body.flatMap(e=>e.outputs.map(e=>e.score)),n=Math.min(...e),l=(Math.ceil(Math.max(...e))-Math.floor(n))/10,i=Array.from({length:11},(e,t)=>parseFloat((Math.floor(n)+t*l).toFixed(2))),a=t.head.prompts.map((e,s)=>{let n=t.body.flatMap(e=>e.outputs[s].score),r=i.map(e=>n.filter(t=>t>=e&&t<e+l).length);return{label:"Prompt ".concat(s+1),data:r,backgroundColor:W[s%W.length]}});r.current=new P.kL(s.current,{type:"bar",data:{labels:i,datasets:a},options:{animation:!1,plugins:{title:{display:!0,text:"Score Distribution"},legend:{display:!1},tooltip:{callbacks:{title:function(e){let t=e[0].datasetIndex;return"Prompt ".concat(t+1)},label:function(e){let t=e.dataIndex,s=i[t],n=i[t+1];return n?"".concat(s," <= score < ").concat(n):"".concat(s," <= score")}}}}}})},[t]),(0,n.jsx)("canvas",{ref:s,style:{maxHeight:"300px"}})}function z(e){let{table:t}=e,s=(0,l.useRef)(null),r=(0,l.useRef)(null);return(0,l.useEffect)(()=>{if(!s.current)return;r.current&&r.current.destroy();let e=t.head.prompts.map((e,s)=>{let n=t.body.flatMap(e=>e.outputs[s]),l=n.filter(e=>e.pass).length,r=l/n.length*100;return{label:"Prompt ".concat(s+1),data:[r],backgroundColor:W[s%W.length]}});r.current=new P.kL(s.current,{type:"bar",data:{labels:["Pass Rate (%)"],datasets:e},options:{animation:!1,plugins:{title:{display:!0,text:"Pass rate"},legend:{display:!0}}}})},[t]),(0,n.jsx)("canvas",{ref:s,style:{maxHeight:"300px"}})}function B(e){let{table:t}=e,s=(0,l.useRef)(null),r=(0,l.useRef)(null),[i,a]=(0,l.useState)(0),[o,c]=(0,l.useState)(1),[d,u]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{if(!s.current)return;r.current&&r.current.destroy();let e=t.body.flatMap(e=>e.outputs.map(e=>e.score)),n=Math.min(...e),l=Math.max(...e),a=t.body.map(e=>{let t=e.outputs[i].score,s=e.outputs[o].score;return{x:t,y:s,backgroundColor:s>t?"green":s<t?"red":"gray"}});r.current=new P.kL(s.current,{type:"scatter",data:{datasets:[{data:a,backgroundColor:a.map(e=>e.backgroundColor)},{type:"line",data:[{x:n,y:n},{x:l,y:l}],borderColor:"gray",borderWidth:1,borderDash:[5,5],pointRadius:0}]},options:{animation:!1,plugins:{legend:{display:!1},tooltip:{callbacks:{label:function(e){let s=t.body[e.dataIndex],n=s.outputs[0].text,l=s.outputs[1].text;return n.length>30&&(n=n.substring(0,30)+"..."),l.length>30&&(l=l.substring(0,30)+"..."),"Output 1: ".concat(n,"\nOutput 2: ").concat(l)}}}},scales:{x:{title:{display:!0,text:"Prompt ".concat(i+1," Score")}},y:{title:{display:!0,text:"Prompt ".concat(o+1," Score")}}}}})},[t,i,o]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(O.Z,{open:d,onClose:()=>u(!1),children:[(0,n.jsx)(F.Z,{children:"Compare prompt outputs"}),(0,n.jsxs)(I.Z,{children:[(0,n.jsx)(x.Z,{sx:{m:1,minWidth:120},children:(0,n.jsx)(y.Z,{value:i,onChange:e=>a(Number(e.target.value)),children:t.head.prompts.map((e,t)=>(0,n.jsxs)(v.Z,{value:t,children:["Prompt ",t+1]},t))})}),(0,n.jsx)(x.Z,{sx:{m:1,minWidth:120},children:(0,n.jsx)(y.Z,{value:o,onChange:e=>c(Number(e.target.value)),children:t.head.prompts.map((e,t)=>(0,n.jsxs)(v.Z,{value:t,children:["Prompt ",t+1]},t))})})]})]}),(0,n.jsx)("canvas",{ref:s,style:{maxHeight:"300px",cursor:"pointer"},onClick:()=>u(!0)})]})}function J(e){let{columnVisibility:t}=e,s=(0,T.Z)();P.kL.defaults.color="dark"===s.palette.mode?"#aaa":"#666";let[r,i]=(0,l.useState)(!0),{table:a}=_();if(!a||!r||a.head.prompts.length<2)return null;let o=a.body.flatMap(e=>e.outputs.map(e=>e.score));return 1===new Set(o).size?null:(0,n.jsx)(A.SV,{fallback:null,children:(0,n.jsxs)(L.Z,{style:{position:"relative",padding:s.spacing(3)},children:[(0,n.jsx)(M.Z,{style:{position:"absolute",right:0,top:0},onClick:()=>i(!1),children:(0,n.jsx)(D.Z,{})}),(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[(0,n.jsx)("div",{style:{width:"33%"},children:(0,n.jsx)(z,{table:a})}),(0,n.jsx)("div",{style:{width:"33%"},children:(0,n.jsx)(V,{table:a})}),(0,n.jsx)("div",{style:{width:"33%"},children:(0,n.jsx)(B,{table:a})})]})]})})}P.kL.register(P.vn,P.ST,P.ho,P.uw,P.f$,P.ZL,P.jn,P.od,P.u,P.wL);var H=s(9116);s(5777);var G=s(3425),X=s(7660),q=s(3216),Y=s(182),$=s(5391),K=s(1396),Q=s.n(K);s(8715);var ee=e=>{let{lookup:t}=e;return t&&Object.keys(t).length?(0,n.jsx)("div",{className:"custom-metric-container",children:Object.entries(t).map(e=>{let[t,s]=e;return t&&s?(0,n.jsxs)("span",{children:[t,": ",s.toFixed(2)]},t):null})}):null},et=s(2834),es=s(5446),en=s(9329),el=s(4719),er=s(3701),ei=s(9279),ea=s(666),eo=s(5795),ec=s(6988),ed=s(4147);function eu(e){let{gradingResults:t}=e;return t?(0,n.jsxs)(u.Z,{mt:2,children:[(0,n.jsx)(j.Z,{variant:"subtitle1",children:"Assertions"}),(0,n.jsx)(eo.Z,{children:(0,n.jsxs)(er.Z,{children:[(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(ed.Z,{children:[(0,n.jsx)(ea.Z,{style:{fontWeight:"bold"},children:"Pass"}),(0,n.jsx)(ea.Z,{style:{fontWeight:"bold"},children:"Score"}),(0,n.jsx)(ea.Z,{style:{fontWeight:"bold"},children:"Type"}),(0,n.jsx)(ea.Z,{style:{fontWeight:"bold"},children:"Value"}),(0,n.jsx)(ea.Z,{style:{fontWeight:"bold"},children:"Reason"})]})}),(0,n.jsx)(ei.Z,{children:t.map((e,t)=>{var s,l;return(0,n.jsxs)(ed.Z,{children:[(0,n.jsx)(ea.Z,{children:e.pass?"✅":"❌"}),(0,n.jsx)(ea.Z,{children:e.score.toFixed(2)}),(0,n.jsx)(ea.Z,{children:(null===(s=e.assertion)||void 0===s?void 0:s.type)||""}),(0,n.jsx)(ea.Z,{style:{whiteSpace:"pre-wrap"},children:(null===(l=e.assertion)||void 0===l?void 0:l.value)?String(e.assertion.value):"-"}),(0,n.jsx)(ea.Z,{style:{whiteSpace:"pre-wrap"},children:e.reason})]},t)})})]})})]}):null}function ep(e){let{open:t,onClose:s,prompt:r,provider:i,output:a,gradingResults:o}=e,[c,d]=(0,l.useState)(!1);(0,l.useEffect)(()=>{d(!1)},[r]);let h=async e=>{await navigator.clipboard.writeText(e),d(!0)};return(0,n.jsxs)(O.Z,{open:t,onClose:s,fullWidth:!0,maxWidth:"lg",children:[(0,n.jsxs)(F.Z,{children:["Details",i&&": ".concat(i)]}),(0,n.jsxs)(I.Z,{children:[(0,n.jsxs)(u.Z,{mb:2,children:[(0,n.jsx)(j.Z,{variant:"subtitle1",style:{marginBottom:"1rem"},children:"Prompt"}),(0,n.jsx)(es.u,{readOnly:!0,value:r,style:{width:"100%",padding:"0.75rem"},maxRows:20}),(0,n.jsx)(M.Z,{onClick:()=>h(r),style:{position:"absolute",right:"10px",top:"10px"},children:c?(0,n.jsx)(el.Z,{}):(0,n.jsx)(en.Z,{})})]}),a&&(0,n.jsxs)(u.Z,{my:2,children:[(0,n.jsx)(j.Z,{variant:"subtitle1",style:{marginBottom:"1rem",marginTop:"1rem"},children:"Output"}),(0,n.jsx)(es.u,{readOnly:!0,maxRows:20,value:a,style:{width:"100%",padding:"0.75rem"}})]}),(0,n.jsx)(eu,{gradingResults:o})]}),(0,n.jsx)(et.Z,{children:(0,n.jsx)(p.Z,{onClick:s,children:"Close"})})]})}var eh=s(9396),em=s(4173),ex=function(){let e=(0,T.Z)(),[t,s]=l.useState(!1),r=()=>{s(!1)};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{style:{textAlign:"center",marginTop:20,marginBottom:40},children:(0,n.jsx)(p.Z,{variant:"text",color:"primary",startIcon:(0,n.jsx)(eh.Z,{}),onClick:()=>{s(!0)},children:"Generate test cases"})}),(0,n.jsxs)(O.Z,{open:t,onClose:r,children:[(0,n.jsx)(F.Z,{children:"Run on Command Line"}),(0,n.jsx)(I.Z,{children:(0,n.jsxs)(em.Z,{children:[(0,n.jsx)("p",{children:"This feature is in beta. UI coming soon."}),(0,n.jsxs)("p",{children:["Run"," ",(0,n.jsx)(u.Z,{component:"code",sx:{backgroundColor:"dark"===e.palette.mode?"#424242":"#f0f0f0",padding:"2px 4px",borderRadius:"4px"},children:"promptfoo generate dataset"}),"to generate test cases on the command line."]})]})}),(0,n.jsx)(et.Z,{children:(0,n.jsx)(p.Z,{onClick:r,color:"primary",children:"Close"})})]})]})},ej=s(2810);function eg(e){return null===e||0===e||1===e?"":"(".concat(e.toFixed(2),")")}function ef(e){return"string"==typeof e||"number"==typeof e?e.toString().length:Array.isArray(e)?e.reduce((e,t)=>e+ef(t),0):l.isValidElement(e)&&e.props.children?l.Children.toArray(e.props.children).reduce((e,t)=>e+ef(t),0):0}function ev(e){let t,{text:s,maxLength:r}=e,[i,a]=l.useState(!0),o=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if("string"==typeof e||"number"==typeof e){let s=e.toString();return s.slice(0,r-t)}if(Array.isArray(e)){let s=[],n=t;for(let t of e){let e=ef(t);if(n+e>r){s.push(o(t,n));break}s.push(t),n+=e}return s}if(l.isValidElement(e)&&e.props.children){let s=ef(e.props.children);if(s>r-t)return l.cloneElement(e,{...e.props,children:o(e.props.children,t)})}return e};t=l.isValidElement(s)||"string"==typeof s?s:JSON.stringify(s);let c=i?o(t):t,d=ef(t)>r;return(0,n.jsxs)("div",{style:{cursor:d?"pointer":"normal"},onClick:()=>{a(!i)},children:[c,i&&ef(t)>r&&(0,n.jsx)("span",{children:"..."})]})}function eb(e){var t,s,r,i,a,o;let c,d,u,p,h,{output:m,maxTextLength:x,rowIndex:j,promptIndex:g,onRating:f,firstOutput:v,filterMode:b,searchText:y,showStats:Z}=e,{renderMarkdown:C,prettifyJson:k}=_(),[w,N]=l.useState(!1),[R,E]=l.useState(!1),P=()=>E(!R),O="string"==typeof m.text?m.text:JSON.stringify(m.text),F=[];if(O.startsWith("[IMAGE]")){let e=O.slice(7).trim();c=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("img",{loading:"lazy",src:e,alt:m.prompt,onClick:P}),R&&(0,n.jsx)("div",{className:"lightbox",onClick:P,children:(0,n.jsx)("img",{src:e,alt:m.prompt})})]})}else!m.pass&&O.includes("---")?O=(F=O.split("---")).slice(1).join("---"):F=[O];if("different"===b&&v){let e,t="string"==typeof v.text?v.text:JSON.stringify(v.text);t.includes("---")&&(t=t.split("---").slice(1).join("---"));try{JSON.parse(t),JSON.parse(O),e=(0,H.CT)(t,O)}catch(s){e=t.includes(". ")&&O.includes(". ")?(0,H.SY)(t,O):(0,H.NV)(t,O)}c=(0,n.jsx)(n.Fragment,{children:e.map((e,t)=>e.added?(0,n.jsx)("ins",{children:e.value},t):e.removed?(0,n.jsx)("del",{children:e.value},t):(0,n.jsx)("span",{children:e.value},t))})}if(y){let e;let t=RegExp(y,"gi"),s=[];for(;null!==(e=t.exec(O));)s.push({start:e.index,end:t.lastIndex}),t.lastIndex;c=(0,n.jsx)(n.Fragment,{children:s.length>0?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{children:O.substring(0,s[0].start)},"text-before"),s.map((e,t)=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"search-highlight",children:O.substring(e.start,e.end)},"match-"+t),(0,n.jsx)("span",{children:O.substring(e.end,s[t+1]?s[t+1].start:O.length)},"text-after-"+t)]}))]}):(0,n.jsx)("span",{children:O},"no-match")})}else if(C)c=(0,n.jsx)(G.U,{children:O});else if(k)try{c=(0,n.jsx)("pre",{children:JSON.stringify(JSON.parse(O),null,2)})}catch(e){}let I=e=>{var t;f(j,g,e,void 0,null===(t=m.gradingResult)||void 0===t?void 0:t.comment)},T=()=>{var e;let t=prompt("Comment:",(null===(e=m.gradingResult)||void 0===e?void 0:e.comment)||"");null!=t&&f(j,g,void 0,void 0,t)};if(null===(t=m.tokenUsage)||void 0===t?void 0:t.completion){u=(0,n.jsxs)("span",{children:[Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(m.latencyMs)," ms"]});let e=m.tokenUsage.completion/(m.latencyMs/1e3);p=(0,n.jsx)("span",{children:Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(e)})}m.cost&&(h=(0,n.jsxs)("span",{children:["$",m.cost.toPrecision(2)]})),(null===(s=m.tokenUsage)||void 0===s?void 0:s.cached)?d=(0,n.jsxs)("span",{children:[Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(m.tokenUsage.cached)," ","(cached)"]}):(null===(r=m.tokenUsage)||void 0===r?void 0:r.total)&&(d=(0,n.jsx)("span",{children:Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(m.tokenUsage.total)}));let L=(null===(i=m.gradingResult)||void 0===i?void 0:i.comment)?(0,n.jsx)("div",{className:"comment",onClick:T,children:m.gradingResult.comment}):null,M=Z?(0,n.jsxs)("div",{className:"cell-detail",children:[d&&(0,n.jsxs)("div",{className:"stat-item",children:[(0,n.jsx)("strong",{children:"Tokens:"})," ",d]}),u&&(0,n.jsxs)("div",{className:"stat-item",children:[(0,n.jsx)("strong",{children:"Latency:"})," ",u]}),p&&(0,n.jsxs)("div",{className:"stat-item",children:[(0,n.jsx)("strong",{children:"Tokens/Sec:"})," ",p]}),h&&(0,n.jsxs)("div",{className:"stat-item",children:[(0,n.jsx)("strong",{children:"Cost:"})," ",h]})]}):null,D=(0,n.jsxs)("div",{className:"cell-actions",children:[m.prompt&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"action",onClick:()=>{N(!0)},children:(0,n.jsx)(S.Z,{title:"View ouput and test details",children:(0,n.jsx)("span",{children:"\uD83D\uDD0E"})})}),(0,n.jsx)(ep,{open:w,onClose:()=>{N(!1)},prompt:m.prompt,provider:m.provider,gradingResults:null===(a=m.gradingResult)||void 0===a?void 0:a.componentResults,output:O})]}),(0,n.jsx)("span",{className:"action",onClick:()=>I(!0),children:(0,n.jsx)(S.Z,{title:"Mark test passed (score 1.0)",children:(0,n.jsx)("span",{children:"\uD83D\uDC4D"})})}),(0,n.jsx)("span",{className:"action",onClick:()=>I(!1),children:(0,n.jsx)(S.Z,{title:"Mark test failed (score 0.0)",children:(0,n.jsx)("span",{children:"\uD83D\uDC4E"})})}),(0,n.jsx)("span",{className:"action",onClick:()=>{let e=prompt("Set test score (0.0 - 1.0):",String(m.score));if(null!==e){let s=parseFloat(e);if(!isNaN(s)&&s>=0&&s<=1){var t;f(j,g,void 0,s,null===(t=m.gradingResult)||void 0===t?void 0:t.comment)}else alert("Invalid score. Please enter a value between 0.0 and 1.0.")}},children:(0,n.jsx)(S.Z,{title:"Set test score",children:(0,n.jsx)("span",{children:"\uD83D\uDD22"})})}),(0,n.jsx)("span",{className:"action",onClick:T,children:(0,n.jsx)(S.Z,{title:"Edit comment",children:(0,n.jsx)("span",{children:"✏️"})})})]});return(0,n.jsxs)("div",{className:"cell",children:[m.pass?(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)("div",{className:"status pass",children:[(0,n.jsxs)("div",{className:"pill",children:["PASS",(0,n.jsx)("span",{className:"score",children:eg(m.score)})]}),(0,n.jsx)(ee,{lookup:m.namedScores})]})}):(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)("div",{className:"status fail",children:[(0,n.jsxs)("div",{className:"pill",children:["FAIL",m.score>0?" ":"",(0,n.jsx)("span",{className:"score",children:eg(m.score)})]}),(0,n.jsx)(ee,{lookup:m.namedScores}),(0,n.jsx)("span",{className:"fail-reason",children:null===(o=F[0])||void 0===o?void 0:o.trim().split("\n").map((e,t)=>(0,n.jsxs)(l.Fragment,{children:[e,(0,n.jsx)("br",{})]},t))})]})}),(0,n.jsx)(ev,{text:c||O,maxLength:x}),L,M,D]})}function ey(e){let{text:t,maxLength:s,expandedText:r,resourceId:i,className:a}=e,[o,c]=l.useState(!1);return(0,n.jsxs)("div",{className:"".concat(a||""),children:[(0,n.jsx)(ev,{text:t,maxLength:s}),r&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(S.Z,{title:"View prompt",children:(0,n.jsx)("span",{className:"action",onClick:()=>{c(!0)},children:"\uD83D\uDD0E"})}),(0,n.jsx)(ep,{open:o,onClose:()=>{c(!1)},prompt:r}),i&&(0,n.jsx)(S.Z,{title:"View other evals and datasets for this prompt",children:(0,n.jsx)("span",{className:"action",children:(0,n.jsx)(Q(),{href:"/prompts/?id=".concat(i),target:"_blank",children:(0,n.jsx)($.Z,{fontSize:"small"})})})})]})]})}function eZ(e){let{maxTextLength:t,columnVisibility:s,wordBreak:i,filterMode:a,failureFilter:o,searchText:c,showStats:d,onFailureFilterToggle:u}=e,{evalId:p,table:m,setTable:x}=_();(0,r.Z)(m,"Table should be defined");let{head:j,body:g}=m,f=j.prompts.map((e,t)=>g.reduce((e,s)=>e+(s.outputs[t].pass?1:0),0)),v=j.prompts.map((e,t)=>g.reduce((e,s)=>{var n,l;return e+((null===(l=s.outputs[t].gradingResult)||void 0===l?void 0:null===(n=l.componentResults)||void 0===n?void 0:n.length)||0)},0)),b=j.prompts.map((e,t)=>g.reduce((e,s)=>{var n;let l=null===(n=s.outputs[t].gradingResult)||void 0===n?void 0:n.componentResults;return e+(l?l.filter(e=>e.pass).length:0)},0)),y=async(e,t,s,n,l)=>{let r=[...g],i={...r[e]},a=[...i.outputs],o=null!=s?s:a[t].pass,c=void 0===n?s?1:0:n||0;a[t].pass=o,a[t].score=c;let d={...a[t].gradingResult||{},pass:o,score:c,reason:"Manual result (overrides all other grading results)",comment:l,assertion:null};a[t].gradingResult=d,i.outputs=a,r[e]=i;let u={head:j,body:r};x(u);try{let e=await fetch("".concat(await (0,ej.b)(),"/api/eval/").concat(p),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({table:u})});if(!e.ok)throw Error("Network response was not ok")}catch(e){console.error("Failed to update table:",e)}},Z=f.reduce((e,t,s,n)=>t>n[e]?s:e,0),C=f[Z],k=(0,X.Cl)(),w=[];j.vars.length>0&&w.push(k.group({id:"vars",header:()=>(0,n.jsx)("span",{className:"font-bold",children:"Variables"}),columns:j.vars.map((e,s)=>k.accessor(e=>e.vars[s],{id:"Variable ".concat(s+1),header:()=>(0,n.jsx)(ey,{text:e,maxLength:t,className:"font-bold"}),cell:e=>(0,n.jsx)(ev,{text:e.getValue(),maxLength:t}),size:50}))})),w.push(k.group({id:"prompts",header:()=>(0,n.jsx)("span",{className:"font-bold",children:"Outputs"}),columns:j.prompts.map((e,s)=>k.accessor(e=>(function(e){if("string"==typeof e){let t=e.startsWith("[PASS]"),s=e;return e.startsWith("[PASS]")?s=s.slice(6):e.startsWith("[FAIL]")&&(s=s.slice(6)),{text:s,pass:t,score:t?1:0}}return e})(e.outputs[s]),{id:"Prompt ".concat(s+1),header:()=>{var l,r,i,c,p,m,x,y;let Z=f[s]&&g.length?(f[s]/g.length*100).toFixed(2):"0.00",k=f[s]===C&&0!==C,w="Prompt ".concat(s+1),S=o[w]||!1,N=d?(0,n.jsxs)("div",{className:"prompt-detail",children:[v[s]?(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"Asserts:"})," ",b[s],"/",v[s]," passed"]}):null,(null===(l=e.metrics)||void 0===l?void 0:l.totalLatencyMs)?(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"Avg Latency:"})," ",Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(e.metrics.totalLatencyMs/g.length)," ","ms"]}):null,(null===(i=e.metrics)||void 0===i?void 0:null===(r=i.tokenUsage)||void 0===r?void 0:r.total)?(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"Avg Tokens:"})," ",Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(e.metrics.tokenUsage.total/g.length)]}):null,(null===(c=e.metrics)||void 0===c?void 0:c.totalLatencyMs)&&(null===(m=e.metrics)||void 0===m?void 0:null===(p=m.tokenUsage)||void 0===p?void 0:p.completion)?(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"Tokens/Sec:"})," ",Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(e.metrics.tokenUsage.completion/(e.metrics.totalLatencyMs/1e3))]}):null,(null===(x=e.metrics)||void 0===x?void 0:x.cost)?(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"Cost:"})," $",e.metrics.cost.toPrecision(2)]}):null]}):null,R=j.prompts.every(e=>e.provider===j.prompts[0].provider),E=e.provider?e.provider.split(":"):[],P=E.length>1?(0,n.jsxs)(n.Fragment,{children:[E[0],":",(0,n.jsx)("strong",{children:E.slice(1).join(":")})]}):(0,n.jsx)("strong",{children:e.provider});return(0,n.jsxs)("div",{className:"output-header",children:[(0,n.jsxs)("div",{className:"pills",children:[!R&&e.provider?(0,n.jsx)("div",{className:"provider",children:P}):null,(0,n.jsx)("div",{className:"summary",children:(0,n.jsxs)("div",{className:"highlight ".concat(k?"success":""),children:[(0,n.jsxs)("strong",{children:[Z,"% passing"]})," (",f[s],"/",g.length," cases)"]})}),(null===(y=e.metrics)||void 0===y?void 0:y.namedScores)&&Object.keys(e.metrics.namedScores).length>0?(0,n.jsx)(ee,{lookup:e.metrics.namedScores}):null]}),(0,n.jsx)(ey,{className:"prompt-container",text:e.display,expandedText:e.raw,maxLength:t,resourceId:e.id}),N,"failures"===a&&(0,n.jsx)(Y.Z,{sx:{"& .MuiFormControlLabel-label":{fontSize:"0.75rem"}},control:(0,n.jsx)(h.Z,{checked:S,onChange:e=>u(w,e.target.checked)}),label:"Show failures"})]})},cell:e=>(0,n.jsx)(eb,{output:e.getValue(),maxTextLength:t,rowIndex:e.row.index,promptIndex:s,onRating:y,firstOutput:R[e.row.index].outputs[0],filterMode:a,searchText:c,showStats:d})}))}));let S=g.some(e=>e.description);S&&w.splice(0,0,{accessorFn:e=>e.description||"",id:"description",header:()=>(0,n.jsx)("span",{className:"font-bold",children:"Description"}),cell:e=>(0,n.jsx)(ev,{text:String(e.getValue()),maxLength:t}),size:50});let N=Object.keys(s).length>0,R=l.useMemo(()=>{let e=RegExp(c,"i");return g.filter(t=>{let n="failures"===a?t.outputs.some((e,t)=>{let n="Prompt ".concat(t+1);return o[n]&&!e.pass&&(!N||s[n])}):"different"!==a||!t.outputs.every(e=>e.text===t.outputs[0].text),l=!c||t.outputs.some(t=>{var s;let n="".concat(t.text," ").concat(Object.keys(t.namedScores)," ").concat(null===(s=t.gradingResult)||void 0===s?void 0:s.reason);return e.test(n)});return n&&l})},[g,o,a,c,s,N]),E=(0,q.b7)({data:R,columns:w,columnResizeMode:"onChange",getCoreRowModel:(0,X.sC)(),state:{columnVisibility:s}});return(0,n.jsxs)("div",{children:[(0,n.jsxs)("table",{className:"results-table firefox-fix ".concat(t<=25?"compact":""),style:{wordBreak:i},children:[(0,n.jsx)("thead",{children:E.getHeaderGroups().map(e=>(0,n.jsx)("tr",{className:"header",children:e.headers.map(e=>(0,n.jsxs)("th",{colSpan:e.colSpan,style:{width:e.getSize()},children:[e.isPlaceholder?null:(0,q.ie)(e.column.columnDef.header,e.getContext()),(0,n.jsx)("div",{onMouseDown:e.getResizeHandler(),onTouchStart:e.getResizeHandler(),className:"resizer ".concat(e.column.getIsResizing()?"isResizing":"")})]},e.id))},e.id))}),(0,n.jsx)("tbody",{children:E.getRowModel().rows.map((e,t)=>{let s=!1;return(0,n.jsx)("tr",{children:e.getVisibleCells().map(e=>{let l=e.column.id.startsWith("Variable")||"description"===e.column.id,r=!l&&!s;return r&&(s=!0),(0,n.jsx)("td",{style:{width:e.column.getSize()},className:"".concat(l?"variable":""," ").concat(0!==t||l?"":"first-prompt-row"," ").concat(r?"first-prompt-col":""),children:(0,q.ie)(e.column.columnDef.cell,e.getContext())},e.id)})},e.id)})})]}),(0,n.jsx)(ex,{})]})}s(2604);var eC=s(2481),ek=s(7175);function ew(e){let{open:t,onClose:r}=e,{config:i}=_(),a=l.useRef(null),[o,c]=l.useState(!1),[d,h]=l.useState("");l.useEffect(()=>{t&&(async()=>{let{default:e}=await s.e(339).then(s.bind(s,8339));h(e.dump(i))})()},[t,i]);let m=()=>{c(!1),r()};return(0,n.jsxs)(O.Z,{open:t,onClose:m,"aria-labelledby":"config-dialog-title",maxWidth:"md",fullWidth:!0,children:[(0,n.jsx)(F.Z,{id:"config-dialog-title",children:(0,n.jsxs)(u.Z,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[(0,n.jsx)(j.Z,{variant:"h6",style:{flexGrow:1},children:"Config"}),(0,n.jsxs)(u.Z,{children:[(0,n.jsx)(S.Z,{title:"Copy to clipboard",children:(0,n.jsx)(M.Z,{onClick:()=>{a.current&&(a.current.select(),document.execCommand("copy"),c(!0))},children:o?(0,n.jsx)(el.Z,{}):(0,n.jsx)(ek.Z,{})})}),(0,n.jsx)(S.Z,{title:"Download .yaml",children:(0,n.jsx)(M.Z,{onClick:()=>{let e=new Blob([d],{type:"text/yaml;charset=utf-8"}),t=URL.createObjectURL(e),s=document.createElement("a");s.href=t,s.download="config.yaml",document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(t)},children:(0,n.jsx)(eC.Z,{})})})]})]})}),(0,n.jsx)(I.Z,{children:(0,n.jsx)(j.Z,{variant:"body1",component:"div",children:(0,n.jsx)("textarea",{ref:a,readOnly:!0,value:d,style:{width:"100%",minHeight:"400px",fontFamily:"monospace",border:"1px solid #ccc"}})})}),(0,n.jsx)(et.Z,{children:(0,n.jsx)(p.Z,{onClick:m,color:"primary",children:"Close"})})]})}var eS=e=>{let{open:t,onClose:s,shareUrl:r}=e,i=(0,l.useRef)(null),[a,o]=(0,l.useState)(!1),c=()=>{s(),o(!1)};return(0,n.jsxs)(O.Z,{open:t,onClose:c,PaperProps:{style:{minWidth:"min(660px, 100%)"}},children:[(0,n.jsx)(F.Z,{children:"Your eval is ready to share"}),(0,n.jsxs)(I.Z,{children:[(0,n.jsx)(w.Z,{inputRef:i,value:r,fullWidth:!0,InputProps:{readOnly:!0,endAdornment:(0,n.jsx)(M.Z,{onClick:()=>{i.current&&(i.current.select(),document.execCommand("copy"),o(!0))},children:a?(0,n.jsx)(el.Z,{}):(0,n.jsx)(ek.Z,{})})}}),(0,n.jsx)(em.Z,{sx:{fontSize:"0.75rem"},children:"Shared URLs are deleted after 2 weeks."})]}),(0,n.jsx)(et.Z,{children:(0,n.jsx)(p.Z,{onClick:c,color:"primary",children:"Close"})})]})},eN=s(33),eR=e=>{let{open:t,onClose:s}=e,{maxTextLength:l,setMaxTextLength:r,wordBreak:i,setWordBreak:a,showInferenceDetails:o,setShowInferenceDetails:c,renderMarkdown:d,setRenderMarkdown:m,prettifyJson:x,setPrettifyJson:g}=_();return(0,n.jsxs)(O.Z,{open:t,onClose:s,fullWidth:!0,maxWidth:"sm",children:[(0,n.jsx)(F.Z,{children:"Table View Settings"}),(0,n.jsxs)(I.Z,{children:[(0,n.jsx)(u.Z,{children:(0,n.jsx)(S.Z,{title:"Forcing line breaks makes it easier to adjust column widths to your liking",children:(0,n.jsx)(Y.Z,{control:(0,n.jsx)(h.Z,{checked:"break-all"===i,onChange:e=>a(e.target.checked?"break-all":"break-word")}),label:"Force line breaks"})})}),(0,n.jsx)(u.Z,{children:(0,n.jsx)(Y.Z,{control:(0,n.jsx)(h.Z,{checked:d,onChange:e=>m(e.target.checked)}),label:"Render model outputs as Markdown"})}),(0,n.jsx)(u.Z,{children:(0,n.jsx)(Y.Z,{control:(0,n.jsx)(h.Z,{checked:x,onChange:e=>g(e.target.checked)}),label:"Prettify JSON outputs"})}),(0,n.jsx)(u.Z,{children:(0,n.jsx)(S.Z,{title:"Show detailed inference statistics such as latency, tokens used, cost, etc.",children:(0,n.jsx)(Y.Z,{control:(0,n.jsx)(h.Z,{checked:o,onChange:e=>c(e.target.checked)}),label:"Show inference details"})})}),(0,n.jsxs)(u.Z,{maxWidth:"sm",children:[(0,n.jsxs)(j.Z,{mt:2,children:["Max text length: ",l]}),(0,n.jsx)(eN.ZP,{min:25,max:1e3,value:l,onChange:(e,t)=>r(t)})]})]}),(0,n.jsx)(et.Z,{children:(0,n.jsx)(p.Z,{onClick:s,children:"Close"})})]})},eE=s(1938),eP=s(7580);let eO=eP.env.NEXT_PUBLIC_PROMPTFOO_REMOTE_API_BASE_URL||eP.env.PROMPTFOO_REMOTE_API_BASE_URL||"https://api.promptfoo.dev",eF=eP.env.NEXT_PUBLIC_PROMPTFOO_REMOTE_APP_BASE_URL||eP.env.PROMPTFOO_REMOTE_APP_BASE_URL||"https://app.promptfoo.dev";s(6911);let eI=(0,R.Z)(k.Z)(e=>{let{theme:t}=e;return{maxWidth:"100%",flexWrap:"wrap",[t.breakpoints.down("sm")]:{flexDirection:"column"}}});function eT(e){let{recentEvals:t,onRecentEvalSelected:s,defaultEvalId:a}=e,c=(0,o.useRouter)(),{table:k,config:R,setConfig:P,maxTextLength:O,wordBreak:F,showInferenceDetails:I,evalId:T}=_(),{setStateFromConfig:L}=(0,eE.o)(),[M,D]=l.useState({}),[A,U]=l.useState([]),[W,V]=l.useState(""),[z]=(0,E.Nr)(W,1e3),[B,H]=l.useState({}),[G,X]=l.useState("all"),[q,Y]=l.useState(!1),[$,K]=l.useState(""),[Q,ee]=l.useState(!1),et=async()=>{ee(!0);try{let e=await fetch("".concat(eO,"/api/eval"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:{version:2,createdAt:new Date().toISOString(),results:{table:k},config:R}})}),{id:t}=await e.json(),s="".concat(eF,"/eval/").concat(t);K(s),Y(!0)}catch(e){alert("Sorry, something went wrong.")}finally{ee(!1)}},[es,en]=l.useState(!1),[el,er]=l.useState(!1);(0,r.Z)(k,"Table data must be loaded before rendering ResultsView");let{head:ei}=k,ea=async()=>{(0,r.Z)(R,"Config must be loaded before clicking its description");let e=window.prompt("Enter new description:",R.description);if(null!==e&&e!==R.description){let t={...R,description:e};try{let e=await fetch("".concat(await (0,ej.b)(),"/api/eval/").concat(T),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({config:t})});if(!e.ok)throw Error("Network response was not ok");P(t)}catch(e){console.error("Failed to update table:",e)}}},eo=[...ei.vars.map((e,t)=>({value:"Variable ".concat(t+1),label:"Var ".concat(t+1,": ").concat(ei.vars[t].length>100?ei.vars[t].slice(0,97)+"...":ei.vars[t]),group:"Variables"})),...ei.prompts.map((e,t)=>({value:"Prompt ".concat(t+1),label:"Prompt ".concat(t+1,": ").concat(ei.prompts[t].display.length>100?ei.prompts[t].display.slice(0,97)+"...":ei.prompts[t].display),group:"Prompts"}))];return l.useEffect(()=>{U(eo.map(e=>e.value))},[ei]),(0,n.jsxs)("div",{style:{marginLeft:"1rem",marginRight:"1rem"},children:[(0,n.jsx)(u.Z,{mb:2,sx:{display:"flex",alignItems:"center"},children:(0,n.jsxs)(j.Z,{variant:"h5",sx:{flexGrow:1},children:[(0,n.jsx)("span",{className:"description",onClick:ea,children:(null==R?void 0:R.description)||T})," ",(null==R?void 0:R.description)&&(0,n.jsx)("span",{className:"description-filepath",children:T})]})}),(0,n.jsx)(u.Z,{py:"md",children:(0,n.jsxs)(eI,{direction:"row",spacing:4,alignItems:"center",children:[(0,n.jsx)(u.Z,{children:t&&t.length>0&&(0,n.jsx)(x.Z,{sx:{m:1,minWidth:200},size:"small",children:(0,n.jsx)(d.Z,{size:"small",options:t,renderOption:(e,t)=>(0,l.createElement)("li",{...e,key:t.id},t.label),style:{width:350},renderInput:e=>(0,n.jsx)(w.Z,{...e,label:"Eval run",variant:"outlined"}),defaultValue:t.find(e=>e.id===a)||t[0],onChange:(e,t)=>{t&&t.id&&s(t.id)},disableClearable:!0})})}),(0,n.jsx)(u.Z,{children:(0,n.jsxs)(x.Z,{sx:{m:1,minWidth:200,maxWidth:350},size:"small",children:[(0,n.jsx)(g.Z,{id:"visible-columns-label",children:"Columns"}),(0,n.jsx)(y.Z,{labelId:"visible-columns-label",id:"visible-columns",multiple:!0,value:A,onChange:e=>{let{target:{value:t}}=e;U("string"==typeof t?t.split(","):t);let s=[...ei.vars.map((e,t)=>"Variable ".concat(t+1)),...ei.prompts.map((e,t)=>"Prompt ".concat(t+1))],n={};s.forEach(e=>{n[e]=("string"==typeof t?t.split(","):t).includes(e)}),D(n)},input:(0,n.jsx)(b.Z,{label:"Visible columns"}),renderValue:e=>e.join(", "),children:eo.map(e=>(0,n.jsxs)(v.Z,{dense:!0,value:e.value,children:[(0,n.jsx)(h.Z,{checked:A.indexOf(e.value)>-1}),(0,n.jsx)(f.Z,{primary:e.label})]},e.value))})]})}),(0,n.jsx)(u.Z,{children:(0,n.jsxs)(x.Z,{sx:{minWidth:180},size:"small",children:[(0,n.jsx)(g.Z,{id:"failure-filter-mode-label",children:"Display"}),(0,n.jsxs)(y.Z,{labelId:"filter-mode-label",id:"filter-mode",value:G,onChange:e=>{let t=e.target.value;X(t);let s={};ei.prompts.forEach((e,n)=>{s["Prompt ".concat(n+1)]="failures"===t}),H(s)},label:"Filter",children:[(0,n.jsx)(v.Z,{value:"all",children:"Show all results"}),(0,n.jsx)(v.Z,{value:"failures",children:"Show failures only"}),(0,n.jsx)(v.Z,{value:"different",children:"Show different only"})]})]})}),(0,n.jsx)(u.Z,{children:(0,n.jsx)(w.Z,{sx:{minWidth:180},size:"small",label:"Search",placeholder:"Text or regex",value:W,onChange:e=>{V(e.target.value)}})}),(0,n.jsx)(u.Z,{flexGrow:1}),(0,n.jsx)(u.Z,{display:"flex",justifyContent:"flex-end",children:(0,n.jsxs)(eI,{direction:"row",spacing:2,children:[(0,n.jsx)(S.Z,{title:"Edit table view settings",children:(0,n.jsx)(p.Z,{color:"primary",onClick:()=>er(!0),startIcon:(0,n.jsx)(Z.Z,{}),children:"Table Settings"})}),R&&(0,n.jsx)(S.Z,{title:"View the configuration that defines this eval",children:(0,n.jsx)(p.Z,{color:"primary",onClick:()=>en(!0),startIcon:(0,n.jsx)(N.Z,{}),children:"View YAML"})}),R&&(0,n.jsx)(S.Z,{title:"Edit eval",children:(0,n.jsx)(p.Z,{color:"primary",onClick:()=>{L(R),c.push("/setup/")},startIcon:(0,n.jsx)(m.Z,{}),children:"Edit Eval"})}),(null==R?void 0:R.sharing)&&(0,n.jsx)(S.Z,{title:"Generate a unique URL that others can access",children:(0,n.jsx)(p.Z,{color:"primary",onClick:et,disabled:Q,startIcon:Q?(0,n.jsx)(i.Z,{size:16}):(0,n.jsx)(C.Z,{}),children:"Share"})})]})})]})}),(0,n.jsx)(J,{columnVisibility:M}),(0,n.jsx)(eZ,{maxTextLength:O,columnVisibility:M,wordBreak:F,showStats:I,filterMode:G,failureFilter:B,searchText:z,onFailureFilterToggle:(e,t)=>{H(s=>({...s,[e]:t}))}}),(0,n.jsx)(ew,{open:es,onClose:()=>en(!1)}),(0,n.jsx)(eS,{open:q,onClose:()=>Y(!1),shareUrl:$}),(0,n.jsx)(eR,{open:el,onClose:()=>er(!1)})]})}var eL=s(279);async function eM(){let e=(0,c.createClientComponentClient)(),{data:{user:t}}=await e.auth.getUser();(0,r.Z)(t,"User not logged in");let{data:s,error:n}=await e.from("EvaluationResult").select("id, createdAt").eq("user_id",t.id).order("createdAt",{ascending:!1}).limit(100);return s||[]}async function eD(e){let t=(0,c.createClientComponentClient)(),{data:s,error:n}=await t.from("EvaluationResult").select("*").eq("id",e).single();return s}function eA(e){var t;let{fetchId:s,preloadedData:c,recentEvals:d,defaultEvalId:u}=e,p=(0,o.useRouter)(),{table:h,setTable:m,setConfig:x,setEvalId:j}=_(),[g,f]=l.useState(!1),[v,b]=l.useState(!1),[y,Z]=l.useState(d||[]),C=async()=>{let e=await fetch("".concat(await (0,ej.b)(),"/api/results"),{cache:"no-store"}),t=await e.json();return Z(t.data),t.data},k=l.useCallback(async e=>{let t=await fetch("".concat(await (0,ej.b)(),"/api/results/").concat(e),{cache:"no-store"}),s=await t.json();m(s.data.results.table),x(s.data.config),j(e)},[m,x,j]),w=async e=>{eL.Ox?(f(!1),p.push("/eval/remote:".concat(encodeURIComponent(e)))):p.push("/eval/?evalId=".concat(encodeURIComponent(e)))},[S,N]=l.useState(u||(null===(t=y[0])||void 0===t?void 0:t.id)),R=(0,o.useSearchParams)(),E=R?R.get("evalId"):null;return(l.useEffect(()=>{if(E){let e=async()=>{await k(E),f(!0),N(E),C()};e()}else if(c){var e;m(null===(e=c.data.results)||void 0===e?void 0:e.table),x(c.data.config),f(!0)}else if(s){let e=async()=>{var e;let t="".concat(eO,"/api/eval/").concat(s);console.log("Fetching eval from remote server",t);let n=await fetch(t);if(!n.ok){b(!0);return}let l=await n.json();m(null===(e=l.data.results)||void 0===e?void 0:e.table),x(l.data.config),f(!0)};e()}else if(eL.T8)(0,ej.b)().then(e=>{let t=(0,a.io)(e);return t.on("init",e=>{console.log("Initialized socket connection",e),f(!0),m(null==e?void 0:e.results.table),x(null==e?void 0:e.config),C().then(e=>{var t,s;N(null===(t=e[0])||void 0===t?void 0:t.id),j(null===(s=e[0])||void 0===s?void 0:s.id)})}),t.on("update",e=>{console.log("Received data update",e),m(e.results.table),x(e.config),C().then(e=>{var t;let s=null===(t=e[0])||void 0===t?void 0:t.id;s&&(N(s),j(s))})}),()=>{t.disconnect()}});else if(eL.Ox)eM().then(e=>{Z(e.map(e=>({id:e.id,label:e.createdAt}))),e.length>0&&eD(e[0].id).then(t=>{(0,r.Z)(t,"Eval not found");let s=t.results,n=t.config;N(e[0].id),m(s.table),x(n),f(!0)})});else{let e=async()=>{let e=await C();if(!(e.length>0))return(0,n.jsx)("div",{className:"notice",children:"No evals yet. Share some evals to this server and they will appear here."});{let t=await (0,ej.b)(),s=e[0].id,n=await fetch("".concat(t,"/api/results/").concat(s)),l=await n.json();m(l.data.results.table),x(l.data.config),f(!0),N(s),j(s)}};e()}},[s,m,x,j,k,c,N,E]),v)?(0,n.jsx)("div",{className:"notice",children:"404 Eval not found"}):g&&h?(0,n.jsx)(eT,{defaultEvalId:S,recentEvals:y,onRecentEvalSelected:w}):(0,n.jsxs)("div",{className:"notice",children:[(0,n.jsx)("div",{children:(0,n.jsx)(i.Z,{size:22})}),(0,n.jsx)("div",{children:"Loading eval data"})]})}s(5038)},279:function(e,t,s){"use strict";s.d(t,{Ox:function(){return r},T8:function(){return l},eA:function(){return i}});var n=s(7580);let l=!n.env.NEXT_PUBLIC_PROMPTFOO_BUILD_STANDALONE_SERVER,r=!!n.env.NEXT_PUBLIC_PROMPTFOO_USE_SUPABASE,i=""},1938:function(e,t,s){"use strict";s.d(t,{o:function(){return r}});var n=s(4660),l=s(4810);let r=(0,n.Ue)()((0,l.tJ)((e,t)=>({env:{},testCases:[],description:"",providers:[],prompts:[],setEnv:t=>e({env:t}),setTestCases:t=>e({testCases:t}),setDescription:t=>e({description:t}),setProviders:t=>e({providers:t}),setPrompts:t=>e({prompts:t}),setStateFromConfig:t=>{let s={};t.description&&(s.description=t.description||""),t.tests&&(s.testCases=t.tests),t.providers&&(s.providers=t.providers),t.prompts&&("string"==typeof t.prompts?s.prompts=[t.prompts]:Array.isArray(t.prompts)?s.prompts=t.prompts.filter(e=>!e.endsWith(".txt")&&!e.endsWith(".json")&&!e.endsWith(".yaml")):console.warn("Invalid prompts config",t.prompts)),e(s)},getTestSuite:()=>{let{description:e,testCases:s,providers:n,prompts:l,env:r}=t();return{env:r,description:e,providers:n,prompts:l,tests:s}}}),{name:"promptfoo",skipHydration:!0}))},8715:function(){},5038:function(){},2604:function(){},6911:function(){},5777:function(){}}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[11],{7304:function(e,n,s){Promise.resolve().then(s.t.bind(s,6685,23)),Promise.resolve().then(s.bind(s,9952))}},function(e){e.O(0,[674,293,808,548,82,420,975,886,683,133,782,952,971,596,744],function(){return e(e.s=7304)}),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- !function(){"use strict";var e,t,n,r,o,u,i,c,f,a={},d={};function l(e){var t=d[e];if(void 0!==t)return t.exports;var n=d[e]={exports:{}},r=!0;try{a[e].call(n.exports,n,n.exports,l),r=!1}finally{r&&delete d[e]}return n.exports}l.m=a,e=[],l.O=function(t,n,r,o){if(n){o=o||0;for(var u=e.length;u>0&&e[u-1][2]>o;u--)e[u]=e[u-1];e[u]=[n,r,o];return}for(var i=1/0,u=0;u<e.length;u++){for(var n=e[u][0],r=e[u][1],o=e[u][2],c=!0,f=0;f<n.length;f++)i>=o&&Object.keys(l.O).every(function(e){return l.O[e](n[f])})?n.splice(f--,1):(c=!1,o<i&&(i=o));if(c){e.splice(u--,1);var a=r();void 0!==a&&(t=a)}}return t},l.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(t,{a:t}),t},n=Object.getPrototypeOf?function(e){return Object.getPrototypeOf(e)}:function(e){return e.__proto__},l.t=function(e,r){if(1&r&&(e=this(e)),8&r||"object"==typeof e&&e&&(4&r&&e.__esModule||16&r&&"function"==typeof e.then))return e;var o=Object.create(null);l.r(o);var u={};t=t||[null,n({}),n([]),n(n)];for(var i=2&r&&e;"object"==typeof i&&!~t.indexOf(i);i=n(i))Object.getOwnPropertyNames(i).forEach(function(t){u[t]=function(){return e[t]}});return u.default=function(){return e},l.d(o,u),o},l.d=function(e,t){for(var n in t)l.o(t,n)&&!l.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},l.f={},l.e=function(e){return Promise.all(Object.keys(l.f).reduce(function(t,n){return l.f[n](e,t),t},[]))},l.u=function(e){return 922===e?"static/chunks/922.b293c6bd1040dbd7.js":"static/chunks/"+e+"-"+({133:"1318f46ed801a49d",339:"501c32916b785ef1"})[e]+".js"},l.miniCssF=function(e){return"static/css/"+({11:"87fb00eed311e9cd",185:"51a17e8edcdfdbb2",413:"16c1dd82fc87c9d7",421:"e162c4971c41c2ac",466:"48d388184a2f4ce3",931:"8119d8bd13a8adab"})[e]+".css"},l.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),l.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r={},o="_N_E:",l.l=function(e,t,n,u){if(r[e]){r[e].push(t);return}if(void 0!==n)for(var i,c,f=document.getElementsByTagName("script"),a=0;a<f.length;a++){var d=f[a];if(d.getAttribute("src")==e||d.getAttribute("data-webpack")==o+n){i=d;break}}i||(c=!0,(i=document.createElement("script")).charset="utf-8",i.timeout=120,l.nc&&i.setAttribute("nonce",l.nc),i.setAttribute("data-webpack",o+n),i.src=l.tu(e)),r[e]=[t];var s=function(t,n){i.onerror=i.onload=null,clearTimeout(p);var o=r[e];if(delete r[e],i.parentNode&&i.parentNode.removeChild(i),o&&o.forEach(function(e){return e(n)}),t)return t(n)},p=setTimeout(s.bind(null,void 0,{type:"timeout",target:i}),12e4);i.onerror=s.bind(null,i.onerror),i.onload=s.bind(null,i.onload),c&&document.head.appendChild(i)},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.tt=function(){return void 0===u&&(u={createScriptURL:function(e){return e}},"undefined"!=typeof trustedTypes&&trustedTypes.createPolicy&&(u=trustedTypes.createPolicy("nextjs#bundler",u))),u},l.tu=function(e){return l.tt().createScriptURL(e)},l.p="/_next/",i={272:0},l.f.j=function(e,t){var n=l.o(i,e)?i[e]:void 0;if(0!==n){if(n)t.push(n[2]);else if(272!=e){var r=new Promise(function(t,r){n=i[e]=[t,r]});t.push(n[2]=r);var o=l.p+l.u(e),u=Error();l.l(o,function(t){if(l.o(i,e)&&(0!==(n=i[e])&&(i[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;u.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",u.name="ChunkLoadError",u.type=r,u.request=o,n[1](u)}},"chunk-"+e,e)}else i[e]=0}},l.O.j=function(e){return 0===i[e]},c=function(e,t){var n,r,o=t[0],u=t[1],c=t[2],f=0;if(o.some(function(e){return 0!==i[e]})){for(n in u)l.o(u,n)&&(l.m[n]=u[n]);if(c)var a=c(l)}for(e&&e(t);f<o.length;f++)r=o[f],l.o(i,r)&&i[r]&&i[r][0](),i[r]=0;return l.O(a)},(f=self.webpackChunk_N_E=self.webpackChunk_N_E||[]).forEach(c.bind(null,0)),f.push=c.bind(null,f.push.bind(f))}();
@@ -1 +0,0 @@
1
- .custom-metric-container{display:inline-flex;flex-wrap:wrap;gap:.25rem;font-weight:400}.custom-metric-container>span{padding:.25rem .5rem;border-radius:4px;color:var(--text-color);border:1px solid var(--border-color);margin-right:.25rem}pre{white-space:pre-wrap}.font-bold{font-weight:700}.divTable,table.results-table{border:1px solid var(--table-border-color);border-collapse:collapse;width:100%;margin:1rem 0;box-shadow:0 2px 4px rgba(0,0,0,.1)}.results-table ins{background-color:var(--insert-highlight-color);text-decoration:none}.results-table del{background-color:var(--delete-highlight-color);-webkit-text-decoration:strikethrough;text-decoration:strikethrough}.tr{display:flex}.results-table tr,.tr{width:-moz-fit-content;width:fit-content}.results-table tr:hover,.tr:hover{background-color:rgba(0,0,0,.02)}.results-table td,.results-table th,.td,.th{position:relative;box-shadow:inset 0 0 0 1px var(--border-color);vertical-align:top;padding:1rem}.compact .td,.compact .th,.compact.results-table td,.compact.results-table th{padding:.5rem}.results-table td.variable,.results-table th.variable,.td.variable,.th.variable{background-color:var(--variable-background-color)}.results-table tr.header{background-color:var(--header-background-color)}.results-table th,.th{padding:1rem;position:relative;vertical-align:bottom;text-align:left;white-space:pre-wrap;font-weight:400}.results-table th .action{cursor:pointer;margin-left:.5rem}.results-table th .action svg{vertical-align:middle}.results-table td,.results-table th{height:1px}@-moz-document url-prefix(){.results-table td,.results-table th{height:100%}}.firefox-fix{display:table;height:100%}.results-table tr .cell{display:flex;flex-direction:column;white-space:pre-wrap;height:100%}.results-table tr .cell img{max-width:256px;max-height:256px;cursor:pointer}.compact.results-table tr .cell>*,.results-table tr .variable>*{display:inline}.results-table tr .cell-actions{display:flex;gap:.5rem;visibility:hidden;position:absolute;top:1.25rem;right:.75rem;line-height:0;font-size:1.25rem}.results-table tr:hover .cell-actions{visibility:visible}.results-table tr .cell-detail{display:flex;flex-wrap:wrap;column-gap:.5rem;row-gap:.25rem;padding-top:1rem;margin-top:auto}.results-table tr .stat-item{font-weight:400;font-size:.75rem;color:#888}.results-table tr .cell-actions .action{cursor:pointer}.results-table th .output-header{display:flex;flex-direction:column;height:100%;align-items:flex-start}.results-table th .output-header .pills{display:flex;flex-wrap:wrap;gap:.25rem;align-items:center;margin-bottom:.5rem}.results-table th .prompt-container{font-weight:700;margin-bottom:.5rem}.results-table th .prompt-container>*{display:inline}.results-table th .provider{display:inline-block;padding:.25rem .5rem;background-color:var(--neutral-background-color);border:1px solid var(--border-color);border-radius:4px;margin-right:.25rem}.results-table th .summary{font-weight:400}.results-table th .prompt-detail{display:flex;flex-wrap:wrap;column-gap:.5rem;row-gap:.25rem;font-size:.75rem;color:#888;margin-top:auto}.results-table th .summary .highlight{padding:.25rem .5rem;border-radius:4px;background-color:var(--fail-background-color);border:1px solid var(--border-color)}.results-table th .summary .highlight.success{background-color:var(--success-background-color);border:1px solid var(--pass-color)}.results-table .status{font-weight:700;margin-bottom:.5rem}.results-table .status .pill{display:inline-block;padding:.25rem .5rem;border-radius:4px;margin-right:.25rem}.results-table .pass .pill{background-color:var(--success-background-color);color:var(--pass-color);border:1px solid var(--pass-color)}.results-table .fail .pill{border:1px solid var(--fail-color)}.fail-reason,.results-table .fail{color:var(--fail-color)}.fail-reason{font-weight:700}.compact .fail-reason{display:inline}.results-table .fail .pill{background-color:var(--fail-background-color)}.results-table td .score{font-weight:400}.results-table .comment{margin-top:.5rem;padding:.25rem .5rem;border-radius:4px;background-color:var(--neutral-background-color);font-style:italic;cursor:pointer}.first-prompt-col{border-left:2px solid #888}.first-prompt-row{border-top:2px solid #888}.search-highlight{color:var(--search-text-color);background-color:var(--search-highlight-color)}.results-table tr .cell .lightbox{position:fixed;top:0;left:0;right:0;bottom:0;background-color:rgba(0,0,0,.7);display:flex;align-items:center;justify-content:center;z-index:1000}.results-table tr .cell .lightbox img{max-width:90%;max-height:90%}.resizer{position:absolute;right:0;top:0;height:100%;width:5px;cursor:col-resize;-webkit-user-select:none;-moz-user-select:none;user-select:none;touch-action:none;background:var(--text-color);opacity:.5}.resizer.isResizing{background:var(--text-color);opacity:1}@media (hover:hover){.resizer{opacity:0}:hover>.resizer{opacity:1}}.description{cursor:pointer;transition:background-color .3s ease}.description:hover{background-color:#f0f0f0}.description-filepath{color:#bbb;font-size:.75rem}body{background-color:var(--background-color);color:var(--text-color)}.notice{display:flex;flex-direction:column;gap:1.5rem;justify-content:center;align-items:center;height:9rem}
@@ -1 +0,0 @@
1
- .custom-metric-container{display:inline-flex;flex-wrap:wrap;gap:.25rem;font-weight:400}.custom-metric-container>span{padding:.25rem .5rem;border-radius:4px;color:var(--text-color);border:1px solid var(--border-color);margin-right:.25rem}pre{white-space:pre-wrap}.font-bold{font-weight:700}.divTable,table.results-table{border:1px solid var(--table-border-color);border-collapse:collapse;width:100%;margin:1rem 0;box-shadow:0 2px 4px rgba(0,0,0,.1)}.results-table ins{background-color:var(--insert-highlight-color);text-decoration:none}.results-table del{background-color:var(--delete-highlight-color);-webkit-text-decoration:strikethrough;text-decoration:strikethrough}.tr{display:flex}.results-table tr,.tr{width:-moz-fit-content;width:fit-content}.results-table tr:hover,.tr:hover{background-color:rgba(0,0,0,.02)}.results-table td,.results-table th,.td,.th{position:relative;box-shadow:inset 0 0 0 1px var(--border-color);vertical-align:top;padding:1rem}.compact .td,.compact .th,.compact.results-table td,.compact.results-table th{padding:.5rem}.results-table td.variable,.results-table th.variable,.td.variable,.th.variable{background-color:var(--variable-background-color)}.results-table tr.header{background-color:var(--header-background-color)}.results-table th,.th{padding:1rem;position:relative;vertical-align:bottom;text-align:left;white-space:pre-wrap;font-weight:400}.results-table th .action{cursor:pointer;margin-left:.5rem}.results-table th .action svg{vertical-align:middle}.results-table td,.results-table th{height:1px}@-moz-document url-prefix(){.results-table td,.results-table th{height:100%}}.firefox-fix{display:table;height:100%}.results-table tr .cell{display:flex;flex-direction:column;white-space:pre-wrap;height:100%}.results-table tr .cell img{max-width:256px;max-height:256px;cursor:pointer}.compact.results-table tr .cell>*,.results-table tr .variable>*{display:inline}.results-table tr .cell-actions{display:flex;gap:.5rem;visibility:hidden;position:absolute;top:1.25rem;right:.75rem;line-height:0;font-size:1.25rem}.results-table tr:hover .cell-actions{visibility:visible}.results-table tr .cell-detail{display:flex;flex-wrap:wrap;column-gap:.5rem;row-gap:.25rem;padding-top:1rem;margin-top:auto}.results-table tr .stat-item{font-weight:400;font-size:.75rem;color:#888}.results-table tr .cell-actions .action{cursor:pointer}.results-table th .output-header{display:flex;flex-direction:column;height:100%;align-items:flex-start}.results-table th .output-header .pills{display:flex;flex-wrap:wrap;gap:.25rem;align-items:center;margin-bottom:.5rem}.results-table th .prompt-container{font-weight:700;margin-bottom:.5rem}.results-table th .prompt-container>*{display:inline}.results-table th .provider{display:inline-block;padding:.25rem .5rem;background-color:var(--neutral-background-color);border:1px solid var(--border-color);border-radius:4px;margin-right:.25rem}.results-table th .summary{font-weight:400}.results-table th .prompt-detail{display:flex;flex-wrap:wrap;column-gap:.5rem;row-gap:.25rem;font-size:.75rem;color:#888;margin-top:auto}.results-table th .summary .highlight{padding:.25rem .5rem;border-radius:4px;background-color:var(--fail-background-color);border:1px solid var(--border-color)}.results-table th .summary .highlight.success{background-color:var(--success-background-color);border:1px solid var(--pass-color)}.results-table .status{font-weight:700;margin-bottom:.5rem}.results-table .status .pill{display:inline-block;padding:.25rem .5rem;border-radius:4px;margin-right:.25rem}.results-table .pass .pill{background-color:var(--success-background-color);color:var(--pass-color);border:1px solid var(--pass-color)}.results-table .fail .pill{border:1px solid var(--fail-color)}.fail-reason,.results-table .fail{color:var(--fail-color)}.fail-reason{font-weight:700}.compact .fail-reason{display:inline}.results-table .fail .pill{background-color:var(--fail-background-color)}.results-table td .score{font-weight:400}.results-table .comment{margin-top:.5rem;padding:.25rem .5rem;border-radius:4px;background-color:var(--neutral-background-color);font-style:italic;cursor:pointer}.first-prompt-col{border-left:2px solid #888}.first-prompt-row{border-top:2px solid #888}.search-highlight{color:var(--search-text-color);background-color:var(--search-highlight-color)}.results-table tr .cell .lightbox{position:fixed;top:0;left:0;right:0;bottom:0;background-color:rgba(0,0,0,.7);display:flex;align-items:center;justify-content:center;z-index:1000}.results-table tr .cell .lightbox img{max-width:90%;max-height:90%}.resizer{position:absolute;right:0;top:0;height:100%;width:5px;cursor:col-resize;-webkit-user-select:none;-moz-user-select:none;user-select:none;touch-action:none;background:var(--text-color);opacity:.5}.resizer.isResizing{background:var(--text-color);opacity:1}@media (hover:hover){.resizer{opacity:0}:hover>.resizer{opacity:1}}.description{cursor:pointer;transition:background-color .3s ease}.description:hover{background-color:#f0f0f0}.description-filepath{color:#bbb;font-size:.75rem}body{background-color:var(--background-color);color:var(--text-color)}.error,.notice{display:flex;flex-direction:column;gap:1.5rem;justify-content:center;align-items:center;height:9rem}.error{font-size:1.5rem}