promptfoo 0.33.3 → 0.34.1

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 (68) hide show
  1. package/README.md +23 -22
  2. package/dist/package.json +1 -1
  3. package/dist/src/assertions.d.ts +4 -2
  4. package/dist/src/assertions.d.ts.map +1 -1
  5. package/dist/src/assertions.js +22 -5
  6. package/dist/src/assertions.js.map +1 -1
  7. package/dist/src/evaluator.d.ts.map +1 -1
  8. package/dist/src/evaluator.js +8 -7
  9. package/dist/src/evaluator.js.map +1 -1
  10. package/dist/src/index.js +1 -1
  11. package/dist/src/index.js.map +1 -1
  12. package/dist/src/main.js +4 -3
  13. package/dist/src/main.js.map +1 -1
  14. package/dist/src/providers/huggingface.js +2 -2
  15. package/dist/src/providers/huggingface.js.map +1 -1
  16. package/dist/src/providers/openai.d.ts +20 -2
  17. package/dist/src/providers/openai.d.ts.map +1 -1
  18. package/dist/src/providers/openai.js +92 -31
  19. package/dist/src/providers/openai.js.map +1 -1
  20. package/dist/src/providers.d.ts.map +1 -1
  21. package/dist/src/providers.js +2 -2
  22. package/dist/src/providers.js.map +1 -1
  23. package/dist/src/table.d.ts.map +1 -1
  24. package/dist/src/table.js +5 -1
  25. package/dist/src/table.js.map +1 -1
  26. package/dist/src/types.d.ts +12 -5
  27. package/dist/src/types.d.ts.map +1 -1
  28. package/dist/src/util.d.ts +3 -1
  29. package/dist/src/util.d.ts.map +1 -1
  30. package/dist/src/util.js +108 -11
  31. package/dist/src/util.js.map +1 -1
  32. package/dist/src/web/nextui/404/index.html +1 -1
  33. package/dist/src/web/nextui/404.html +1 -1
  34. package/dist/src/web/nextui/_next/static/chunks/{919-d71c386cf4a86911.js → 440-d53e95152985d2c9.js} +3 -3
  35. package/dist/src/web/nextui/_next/static/chunks/729-98e547dcb2d392cc.js +1 -0
  36. package/dist/src/web/nextui/_next/static/chunks/896-f2519aac9087ba0a.js +8 -0
  37. package/dist/src/web/nextui/_next/static/chunks/app/eval/[id]/{page-6e1876bf1b902e7d.js → page-8571bc66ffa4f037.js} +1 -1
  38. package/dist/src/web/nextui/_next/static/chunks/app/eval/page-3b208fe2a2800a3e.js +1 -0
  39. package/dist/src/web/nextui/_next/static/chunks/app/setup/page-4bc19fb7fd534921.js +1 -0
  40. package/dist/src/web/nextui/_next/static/chunks/{webpack-e0942e16d7068577.js → webpack-d493d89689f7b43b.js} +1 -1
  41. package/dist/src/web/nextui/_next/static/css/8c7fcf68df21e7e6.css +1 -0
  42. package/dist/src/web/nextui/_next/static/css/fbdc70c454098755.css +1 -0
  43. package/dist/src/web/nextui/auth/login/index.html +1 -1
  44. package/dist/src/web/nextui/auth/login/index.txt +3 -3
  45. package/dist/src/web/nextui/auth/signup/index.html +1 -1
  46. package/dist/src/web/nextui/auth/signup/index.txt +3 -3
  47. package/dist/src/web/nextui/datasets/index.html +1 -1
  48. package/dist/src/web/nextui/datasets/index.txt +3 -3
  49. package/dist/src/web/nextui/eval/index.html +1 -1
  50. package/dist/src/web/nextui/eval/index.txt +6 -6
  51. package/dist/src/web/nextui/index.html +1 -1
  52. package/dist/src/web/nextui/index.txt +3 -3
  53. package/dist/src/web/nextui/prompts/index.html +1 -1
  54. package/dist/src/web/nextui/prompts/index.txt +3 -3
  55. package/dist/src/web/nextui/setup/index.html +2 -2
  56. package/dist/src/web/nextui/setup/index.txt +5 -5
  57. package/dist/src/web/server.d.ts.map +1 -1
  58. package/dist/src/web/server.js +18 -2
  59. package/dist/src/web/server.js.map +1 -1
  60. package/package.json +1 -1
  61. package/dist/src/web/nextui/_next/static/chunks/753-f62bfa32dbd9ff14.js +0 -8
  62. package/dist/src/web/nextui/_next/static/chunks/860-af67976c17d7f0d3.js +0 -1
  63. package/dist/src/web/nextui/_next/static/chunks/app/eval/page-c57265f0cc765850.js +0 -1
  64. package/dist/src/web/nextui/_next/static/chunks/app/setup/page-0e921c39ba7c3038.js +0 -1
  65. package/dist/src/web/nextui/_next/static/css/6de4b83ebb0d35d6.css +0 -1
  66. package/dist/src/web/nextui/_next/static/css/d214f868fd093747.css +0 -1
  67. /package/dist/src/web/nextui/_next/static/{a66W9hLbRiOSchIpxBjVs → VpwZ6hpHRmu4JDi-ZyG1a}/_buildManifest.js +0 -0
  68. /package/dist/src/web/nextui/_next/static/{a66W9hLbRiOSchIpxBjVs → VpwZ6hpHRmu4JDi-ZyG1a}/_ssgManifest.js +0 -0
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[860],{2810:function(e,t,s){"use strict";let n;async function l(){if(!n){let e=await fetch("/api/config"),t=await e.json();n=t.apiBaseUrl}return n}s.d(t,{b:function(){return l}})},1860:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return eN}});var n=s(7437),l=s(2265),r=s(2130),a=s(6882),i=s(3388),o=s(4033),c=s(3082),d=s(5551),u=s(6507),p=s(7760),h=s(4081),m=s(182),x=s(819),j=s(8212),f=s(5507),g=s(923),v=s(654),y=s(33),b=s(3457),Z=s(8276),w=s(3226),C=s(2467),S=s(9605),k=s(3391),R=s(9190),N=s(6704),P=s(9394),E=s(1797),F=s(6337),L=s(1101),D=s(9872),V=s(2653),I=s(3533),M=s(4740),O=s(4660);let W=(0,O.Ue)(e=>({table:null,setTable:t=>e(()=>({table:t})),config:null,setConfig:t=>e(()=>({config:t}))})),T=["#fd7f6f","#7eb0d5","#b2e061","#bd7ebe","#ffb55a","#ffee65","#beb9db","#fdcce5","#8bd3c7"];function U(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,a=Array.from({length:11},(e,t)=>parseFloat((Math.floor(n)+t*l).toFixed(2))),i=t.head.prompts.map((e,s)=>{let n=t.body.flatMap(e=>e.outputs[s].score),r=a.map(e=>n.filter(t=>t>=e&&t<e+l).length);return{label:"Prompt ".concat(s+1),data:r,backgroundColor:T[s%T.length]}});r.current=new N.kL(s.current,{type:"bar",data:{labels:a,datasets:i},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=a[t],n=a[t+1];return n?"".concat(s," <= score < ").concat(n):"".concat(s," <= score")}}}}}})},[t]),(0,n.jsx)("canvas",{ref:s,style:{maxHeight:"300px"}})}function A(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:T[s%T.length]}});r.current=new N.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 z(e){let{table:t}=e,s=(0,l.useRef)(null),r=(0,l.useRef)(null),[a,i]=(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),i=t.body.map(e=>{let t=e.outputs[a].score,s=e.outputs[o].score;return{x:t,y:s,backgroundColor:s>t?"green":s<t?"red":"gray"}});r.current=new N.kL(s.current,{type:"scatter",data:{datasets:[{data:i,backgroundColor:i.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(a+1," Score")}},y:{title:{display:!0,text:"Prompt ".concat(o+1," Score")}}}}})},[t,a,o]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(P.Z,{open:d,onClose:()=>u(!1),children:[(0,n.jsx)(E.Z,{children:"Compare prompt outputs"}),(0,n.jsxs)(F.Z,{children:[(0,n.jsx)(h.Z,{sx:{m:1,minWidth:120},children:(0,n.jsx)(v.Z,{value:a,onChange:e=>i(Number(e.target.value)),children:t.head.prompts.map((e,t)=>(0,n.jsxs)(f.Z,{value:t,children:["Prompt ",t+1]},t))})}),(0,n.jsx)(h.Z,{sx:{m:1,minWidth:120},children:(0,n.jsx)(v.Z,{value:o,onChange:e=>c(Number(e.target.value)),children:t.head.prompts.map((e,t)=>(0,n.jsxs)(f.Z,{value:t,children:["Prompt ",t+1]},t))})})]})]}),(0,n.jsx)("canvas",{ref:s,style:{maxHeight:"300px",cursor:"pointer"},onClick:()=>u(!0)})]})}function _(e){let{columnVisibility:t}=e,s=(0,L.Z)();N.kL.defaults.color="dark"===s.palette.mode?"#aaa":"#666";let[r,a]=(0,l.useState)(!0),{table:i}=W();if(!i||!r||i.head.prompts.length<2)return null;let o=i.body.flatMap(e=>e.outputs.map(e=>e.score));return 1===new Set(o).size?null:(0,n.jsx)(M.SV,{fallback:null,children:(0,n.jsxs)(D.Z,{style:{position:"relative",padding:s.spacing(3)},children:[(0,n.jsx)(V.Z,{style:{position:"absolute",right:0,top:0},onClick:()=>a(!1),children:(0,n.jsx)(I.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)(A,{table:i})}),(0,n.jsx)("div",{style:{width:"33%"},children:(0,n.jsx)(U,{table:i})}),(0,n.jsx)("div",{style:{width:"33%"},children:(0,n.jsx)(z,{table:i})})]})]})})}N.kL.register(N.vn,N.ST,N.ho,N.uw,N.f$,N.ZL,N.jn,N.od,N.u,N.wL);var H=s(9116);s(5777);var B=s(7660),J=s(3216),G=s(5391),q=s(1396),Y=s.n(q);s(8715);var X=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},$=s(2834),K=s(5446),Q=s(9329),ee=s(4719),et=s(3701),es=s(9279),en=s(666),el=s(5795),er=s(6988),ea=s(4147);function ei(e){let{gradingResults:t}=e;return t?(0,n.jsxs)(u.Z,{mt:2,children:[(0,n.jsx)(w.Z,{variant:"subtitle1",children:"Assertions"}),(0,n.jsx)(el.Z,{children:(0,n.jsxs)(et.Z,{children:[(0,n.jsx)(er.Z,{children:(0,n.jsxs)(ea.Z,{children:[(0,n.jsx)(en.Z,{style:{fontWeight:"bold"},children:"Pass"}),(0,n.jsx)(en.Z,{style:{fontWeight:"bold"},children:"Score"}),(0,n.jsx)(en.Z,{style:{fontWeight:"bold"},children:"Type"}),(0,n.jsx)(en.Z,{style:{fontWeight:"bold"},children:"Value"}),(0,n.jsx)(en.Z,{style:{fontWeight:"bold"},children:"Reason"})]})}),(0,n.jsx)(es.Z,{children:t.map((e,t)=>{var s,l;return(0,n.jsxs)(ea.Z,{children:[(0,n.jsx)(en.Z,{children:e.pass?"✅":"❌"}),(0,n.jsx)(en.Z,{children:e.score.toFixed(2)}),(0,n.jsx)(en.Z,{children:(null===(s=e.assertion)||void 0===s?void 0:s.type)||""}),(0,n.jsx)(en.Z,{style:{whiteSpace:"pre-wrap"},children:(null===(l=e.assertion)||void 0===l?void 0:l.value)?String(e.assertion.value):"-"}),(0,n.jsx)(en.Z,{style:{whiteSpace:"pre-wrap"},children:e.reason})]},t)})})]})})]}):null}function eo(e){let{open:t,onClose:s,prompt:r,provider:a,output:i,gradingResults:o}=e,[c,p]=(0,l.useState)(!1);(0,l.useEffect)(()=>{p(!1)},[r]);let h=async e=>{await navigator.clipboard.writeText(e),p(!0)};return(0,n.jsxs)(P.Z,{open:t,onClose:s,fullWidth:!0,maxWidth:"lg",children:[(0,n.jsxs)(E.Z,{children:["Details",a&&": ".concat(a)]}),(0,n.jsxs)(F.Z,{children:[(0,n.jsxs)(u.Z,{mb:2,children:[(0,n.jsx)(w.Z,{variant:"subtitle1",style:{marginBottom:"1rem"},children:"Prompt"}),(0,n.jsx)(K.u,{readOnly:!0,value:r,style:{width:"100%",padding:"0.75rem"},maxRows:20}),(0,n.jsx)(V.Z,{onClick:()=>h(r),style:{position:"absolute",right:"10px",top:"10px"},children:c?(0,n.jsx)(ee.Z,{}):(0,n.jsx)(Q.Z,{})})]}),i&&(0,n.jsxs)(u.Z,{my:2,children:[(0,n.jsx)(w.Z,{variant:"subtitle1",style:{marginBottom:"1rem",marginTop:"1rem"},children:"Output"}),(0,n.jsx)(K.u,{readOnly:!0,maxRows:20,value:i,style:{width:"100%",padding:"0.75rem"}})]}),(0,n.jsx)(ei,{gradingResults:o})]}),(0,n.jsx)($.Z,{children:(0,n.jsx)(d.Z,{onClick:s,children:"Close"})})]})}function ec(e){return null===e||0===e||1===e?"":"(".concat(e.toFixed(2),")")}function ed(e){return"string"==typeof e||"number"==typeof e?e.toString().length:Array.isArray(e)?e.reduce((e,t)=>e+ed(t),0):l.isValidElement(e)&&e.props.children?l.Children.toArray(e.props.children).reduce((e,t)=>e+ed(t),0):0}function eu(e){let t,{text:s,maxLength:r}=e,[a,i]=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=ed(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=ed(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=a?o(t):t,d=ed(t)>r;return(0,n.jsxs)("div",{style:{cursor:d?"pointer":"normal"},onClick:()=>{i(!a)},children:[c,a&&ed(t)>r&&(0,n.jsx)("span",{children:"..."})]})}function ep(e){var t,s,r;let a,i,{output:o,maxTextLength:c,rowIndex:d,promptIndex:u,onRating:p,firstOutput:h,filterMode:m}=e,[x,j]=l.useState(!1),f="string"==typeof o.text?o.text:JSON.stringify(o.text),g=[];if(!o.pass&&f.includes("---")?f=(g=f.split("---")).slice(1).join("---"):g=[f],"different"===m&&h){let e,t="string"==typeof h.text?h.text:JSON.stringify(h.text);t.includes("---")&&(t=t.split("---").slice(1).join("---"));try{JSON.parse(t),JSON.parse(f),e=(0,H.CT)(t,f)}catch(s){e=t.includes(". ")&&f.includes(". ")?(0,H.SY)(t,f):(0,H.NV)(t,f)}a=(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))})}let v=e=>{p(d,u,e)},y=(0,n.jsxs)("span",{children:[o.latencyMs," ms"]});(null===(t=o.tokenUsage)||void 0===t?void 0:t.cached)?i=(0,n.jsxs)("span",{children:[o.tokenUsage.cached," tokens (cached)"]}):(null===(s=o.tokenUsage)||void 0===s?void 0:s.total)&&(i=(0,n.jsxs)("span",{children:[o.tokenUsage.total," tokens"]}));let b=(0,n.jsxs)("span",{className:"cell-detail",children:[i,i&&y?" | ":"",y]}),w=(0,n.jsxs)("div",{className:"cell-actions",children:[o.prompt&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"action",onClick:()=>{j(!0)},children:(0,n.jsx)(Z.Z,{title:"View ouput and test details",children:(0,n.jsx)("span",{children:"\uD83D\uDD0E"})})}),(0,n.jsx)(eo,{open:x,onClose:()=>{j(!1)},prompt:o.prompt,provider:o.provider,gradingResults:null===(r=o.gradingResult)||void 0===r?void 0:r.componentResults,output:f})]}),(0,n.jsx)("span",{className:"action",onClick:()=>v(!0),children:(0,n.jsx)(Z.Z,{title:"Mark test passed (score 1.0)",children:(0,n.jsx)("span",{children:"\uD83D\uDC4D"})})}),(0,n.jsx)("span",{className:"action",onClick:()=>v(!1),children:(0,n.jsx)(Z.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):");if(null!==e){let t=parseFloat(e);!isNaN(t)&&t>=0&&t<=1?p(d,u,!0,t):alert("Invalid score. Please enter a value between 0.0 and 1.0.")}},children:(0,n.jsx)(Z.Z,{title:"Set test score",children:(0,n.jsx)("span",{children:"✏️"})})})]});return(0,n.jsxs)("div",{className:"cell",children:[o.pass&&(0,n.jsxs)("div",{className:"status pass",children:[(0,n.jsxs)("span",{className:"pill",children:["PASS",(0,n.jsx)("span",{className:"score",children:ec(o.score)})]}),(0,n.jsx)(X,{lookup:o.namedScores})," ",b]}),!o.pass&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"status fail",children:[(0,n.jsxs)("span",{className:"pill",children:["FAIL",o.score>0?" ":"",(0,n.jsx)("span",{className:"score",children:ec(o.score)})]}),(0,n.jsx)(X,{lookup:o.namedScores})," ",b]}),(0,n.jsx)("div",{className:"fail-reason",children:g[0].trim().split("\n").map((e,t)=>(0,n.jsxs)(l.Fragment,{children:[e,(0,n.jsx)("br",{})]},t))})]}),(0,n.jsx)(eu,{text:a||f,maxLength:c}),w]})}function eh(e){let{text:t,maxLength:s,expandedText:r,resourceId:a,className:i}=e,[o,c]=l.useState(!1);return(0,n.jsxs)("div",{className:"".concat(i||""),children:[(0,n.jsx)(eu,{text:t,maxLength:s}),r&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(Z.Z,{title:"View prompt",children:(0,n.jsx)("span",{className:"action",onClick:()=>{c(!0)},children:"\uD83D\uDD0E"})}),(0,n.jsx)(eo,{open:o,onClose:()=>{c(!1)},prompt:r}),a&&(0,n.jsx)(Z.Z,{title:"View other evals and datasets for this prompt",children:(0,n.jsx)("span",{className:"action",children:(0,n.jsx)(Y(),{href:"/prompts/?id=".concat(a),target:"_blank",children:(0,n.jsx)(G.Z,{fontSize:"small"})})})})]})]})}function em(e){let{maxTextLength:t,columnVisibility:s,wordBreak:a,filterMode:i,failureFilter:o,onFailureFilterToggle:c}=e,{table:d,setTable:u}=W();(0,r.Z)(d,"Table should be defined");let{head:h,body:x}=d,j=h.prompts.map((e,t)=>x.reduce((e,s)=>e+(s.outputs[t].pass?1:0),0)),f=h.prompts.map((e,t)=>x.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)),g=h.prompts.map((e,t)=>x.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)),v=(e,t,s,n)=>{let l=[...x],r={...l[e]},a=[...r.outputs];a[t].pass=s,a[t].score=void 0===n?s?1:0:n||0,r.outputs=a,l[e]=r,u({head:h,body:l})},y=j.reduce((e,t,s,n)=>t>n[e]?s:e,0),b=j[y],Z=(0,B.Cl)(),w=[];h.vars.length>0&&w.push(Z.group({id:"vars",header:()=>(0,n.jsx)("span",{children:"Variables"}),columns:h.vars.map((e,s)=>Z.accessor(e=>e.vars[s],{id:"Variable ".concat(s+1),header:()=>(0,n.jsx)(eh,{text:e,maxLength:t}),cell:e=>(0,n.jsx)(eu,{text:e.getValue(),maxLength:t}),size:50}))})),w.push(Z.group({id:"prompts",header:()=>(0,n.jsx)("span",{children:"Outputs"}),columns:h.prompts.map((e,s)=>Z.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,a,d,u,h,v;let y=j[s]&&x.length?(j[s]/x.length*100).toFixed(2):"0.00",Z=j[s]===b&&0!==b,w="Prompt ".concat(s+1),C=o[w]||!1;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eh,{className:"prompt-container",text:"string"==typeof e?e:e.display,expandedText:"string"==typeof e?void 0:e.raw,maxLength:t,resourceId:"string"==typeof e?void 0:e.id}),(0,n.jsxs)("div",{className:"summary",children:[(0,n.jsxs)("span",{className:"highlight ".concat(Z?"success":""),children:["Pass rate: ",(0,n.jsxs)("strong",{children:[y,"%"]})," (",j[s],"/",x.length," cases",f[s]?(0,n.jsxs)("span",{children:[", ",g[s],"/",f[s]," asserts"]}):null,")"]}),((null===(l=e.metrics)||void 0===l?void 0:l.totalLatencyMs)||(null===(a=e.metrics)||void 0===a?void 0:null===(r=a.tokenUsage)||void 0===r?void 0:r.total))&&(0,n.jsx)("span",{children:" avg"}),(null===(d=e.metrics)||void 0===d?void 0:d.totalLatencyMs)?(0,n.jsxs)("span",{children:[" ",Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(e.metrics.totalLatencyMs/x.length),"ms"]}):null,(null===(h=e.metrics)||void 0===h?void 0:null===(u=h.tokenUsage)||void 0===u?void 0:u.total)?(0,n.jsxs)("span",{children:[" ",Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(e.metrics.tokenUsage.total/x.length)," ","tokens"]}):null]}),(null===(v=e.metrics)||void 0===v?void 0:v.namedScores)&&Object.keys(e.metrics.namedScores).length>0?(0,n.jsx)("div",{style:{marginTop:"0.5rem"},children:(0,n.jsx)(X,{lookup:e.metrics.namedScores})}):null,"failures"===i&&(0,n.jsx)(m.Z,{sx:{"& .MuiFormControlLabel-label":{fontSize:"0.75rem"}},control:(0,n.jsx)(p.Z,{checked:C,onChange:e=>c(w,e.target.checked)}),label:"Show failures"})]})},cell:e=>(0,n.jsx)(ep,{output:e.getValue(),maxTextLength:t,rowIndex:e.row.index,promptIndex:s,onRating:v,firstOutput:S[e.row.index].outputs[0],filterMode:i})}))}));let C=x.some(e=>e.description);C&&w.splice(0,0,{accessorFn:e=>e.description||"",id:"description",header:()=>(0,n.jsx)("span",{children:"Description"}),cell:e=>(0,n.jsx)(eu,{text:String(e.getValue()),maxLength:t}),size:50});let S=l.useMemo(()=>"failures"===i?Object.values(o).every(e=>!e)?x:x.filter(e=>e.outputs.some((e,t)=>{let s=!e.pass;return o["Prompt ".concat(t+1)]&&s})):"different"===i?x.filter(e=>!e.outputs.every(t=>t.text===e.outputs[0].text)):x,[x,o,i]),k=(0,J.b7)({data:S,columns:w,columnResizeMode:"onChange",getCoreRowModel:(0,B.sC)(),state:{columnVisibility:s}});return(0,n.jsxs)("table",{className:"results-table ".concat(t<=25?"compact":""),style:{wordBreak:a},children:[(0,n.jsx)("thead",{children:k.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,J.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:k.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,J.ie)(e.column.columnDef.cell,e.getContext())},e.id)})},e.id)})})]})}s(2604);var ex=s(2481),ej=s(7175);function ef(e){let{open:t,onClose:r}=e,{config:a}=W(),i=l.useRef(null),[o,c]=l.useState(!1),[p,h]=l.useState("");l.useEffect(()=>{t&&(async()=>{let{default:e}=await s.e(339).then(s.bind(s,8339));h(e.dump(a))})()},[t,a]);let m=()=>{c(!1),r()};return(0,n.jsxs)(P.Z,{open:t,onClose:m,"aria-labelledby":"config-dialog-title",maxWidth:"md",fullWidth:!0,children:[(0,n.jsx)(E.Z,{id:"config-dialog-title",children:(0,n.jsxs)(u.Z,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[(0,n.jsx)(w.Z,{variant:"h6",style:{flexGrow:1},children:"Config"}),(0,n.jsxs)(u.Z,{children:[(0,n.jsx)(Z.Z,{title:"Copy to clipboard",children:(0,n.jsx)(V.Z,{onClick:()=>{i.current&&(i.current.select(),document.execCommand("copy"),c(!0))},children:o?(0,n.jsx)(ee.Z,{}):(0,n.jsx)(ej.Z,{})})}),(0,n.jsx)(Z.Z,{title:"Download .yaml",children:(0,n.jsx)(V.Z,{onClick:()=>{let e=new Blob([p],{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)(ex.Z,{})})})]})]})}),(0,n.jsx)(F.Z,{children:(0,n.jsx)(w.Z,{variant:"body1",component:"div",children:(0,n.jsx)("textarea",{ref:i,readOnly:!0,value:p,style:{width:"100%",minHeight:"400px",fontFamily:"monospace",border:"1px solid #ccc"}})})}),(0,n.jsx)($.Z,{children:(0,n.jsx)(d.Z,{onClick:m,color:"primary",children:"Close"})})]})}var eg=s(4173),ev=s(1975),ey=e=>{let{open:t,onClose:s,shareUrl:r}=e,a=(0,l.useRef)(null),[i,o]=(0,l.useState)(!1),c=()=>{s(),o(!1)};return(0,n.jsxs)(P.Z,{open:t,onClose:c,PaperProps:{style:{minWidth:"min(660px, 100%)"}},children:[(0,n.jsx)(E.Z,{children:"Your eval is ready to share"}),(0,n.jsxs)(F.Z,{children:[(0,n.jsx)(ev.Z,{inputRef:a,value:r,fullWidth:!0,InputProps:{readOnly:!0,endAdornment:(0,n.jsx)(V.Z,{onClick:()=>{a.current&&(a.current.select(),document.execCommand("copy"),o(!0))},children:i?(0,n.jsx)(ee.Z,{}):(0,n.jsx)(ej.Z,{})})}}),(0,n.jsx)(eg.Z,{sx:{fontSize:"0.75rem"},children:"Shared URLs are deleted after 1 week."})]}),(0,n.jsx)($.Z,{children:(0,n.jsx)(d.Z,{onClick:c,color:"primary",children:"Close"})})]})},eb=s(1938);let eZ=(0,R.Z)(b.Z)(e=>{let{theme:t}=e;return{maxWidth:"100%",flexWrap:"wrap",[t.breakpoints.down("sm")]:{flexDirection:"column"}}});function ew(e){let{recentEvals:t,onRecentEvalSelected:s,defaultEvalId:i}=e,c=(0,o.useRouter)(),{table:b,config:R}=W(),{setStateFromConfig:N}=(0,eb.o)(),[P,E]=l.useState(250),[F,L]=l.useState({}),[D,V]=l.useState([]),[I,M]=l.useState({}),[O,T]=l.useState("all"),[U,A]=l.useState("break-word"),[z,H]=l.useState(!1),[B,J]=l.useState(""),[G,q]=l.useState(!1),Y=async()=>{q(!0);try{let e=await fetch("https://api.promptfoo.dev/eval",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:{version:2,createdAt:new Date().toISOString(),results:{table:b},config:R}})}),{id:t}=await e.json(),s="https://app.promptfoo.dev/eval/".concat(t);J(s),H(!0)}catch(e){alert("Sorry, something went wrong.")}finally{q(!1)}},[X,$]=l.useState(!1);(0,r.Z)(b,"Table data must be loaded before rendering ResultsView");let{head:K}=b,Q=[...K.vars.map((e,t)=>({value:"Variable ".concat(t+1),label:"Var ".concat(t+1,": ").concat(K.vars[t].length>100?K.vars[t].slice(0,97)+"...":K.vars[t]),group:"Variables"})),...K.prompts.map((e,t)=>({value:"Prompt ".concat(t+1),label:"Prompt ".concat(t+1,": ").concat(K.prompts[t].display.length>100?K.prompts[t].display.slice(0,97)+"...":K.prompts[t].display),group:"Prompts"}))];return l.useEffect(()=>{V(Q.map(e=>e.value))},[K]),(0,n.jsxs)("div",{style:{marginLeft:"1rem",marginRight:"1rem"},children:[(0,n.jsx)(u.Z,{py:"md",children:(0,n.jsxs)(eZ,{direction:"row",spacing:4,alignItems:"center",children:[(0,n.jsx)(u.Z,{children:t&&t.length>0&&(0,n.jsxs)(h.Z,{sx:{m:1,minWidth:200},size:"small",children:[(0,n.jsx)(x.Z,{children:"View run"}),(0,n.jsx)(v.Z,{className:"recent-files",label:"Previous runs",defaultValue:i,onChange:e=>s(e.target.value),children:t.map(e=>(0,n.jsx)(f.Z,{value:e.id,children:e.label},e.id))},t.map(e=>e.id).join(","))]})}),(0,n.jsx)(u.Z,{children:(0,n.jsxs)(h.Z,{sx:{m:1,minWidth:200},size:"small",children:[(0,n.jsx)(x.Z,{id:"visible-columns-label",children:"Show columns"}),(0,n.jsx)(v.Z,{labelId:"visible-columns-label",id:"visible-columns",multiple:!0,value:D,onChange:e=>{let{target:{value:t}}=e;V("string"==typeof t?t.split(","):t);let s=[...K.vars.map((e,t)=>"Variable ".concat(t+1)),...K.prompts.map((e,t)=>"Prompt ".concat(t+1))],n={};s.forEach(e=>{n[e]=("string"==typeof t?t.split(","):t).includes(e)}),L(n)},input:(0,n.jsx)(g.Z,{label:"Visible columns"}),renderValue:e=>e.join(", "),children:Q.map(e=>(0,n.jsxs)(f.Z,{dense:!0,value:e.value,children:[(0,n.jsx)(p.Z,{checked:D.indexOf(e.value)>-1}),(0,n.jsx)(j.Z,{primary:e.label})]},e.value))})]})}),(0,n.jsx)(u.Z,{children:(0,n.jsxs)(h.Z,{sx:{minWidth:180},size:"small",children:[(0,n.jsx)(x.Z,{id:"failure-filter-mode-label",children:"Filter"}),(0,n.jsxs)(v.Z,{labelId:"filter-mode-label",id:"filter-mode",value:O,onChange:e=>{let t=e.target.value;T(t);let s={};K.prompts.forEach((e,n)=>{s["Prompt ".concat(n+1)]="failures"===t}),M(s)},label:"Filter",children:[(0,n.jsx)(f.Z,{value:"all",children:"Show all results"}),(0,n.jsx)(f.Z,{value:"failures",children:"Show failures only"}),(0,n.jsx)(f.Z,{value:"different",children:"Show different only"})]})]})}),(0,n.jsxs)(u.Z,{children:[(0,n.jsxs)(w.Z,{mt:2,children:["Max text length: ",P]}),(0,n.jsx)(y.ZP,{min:25,max:1e3,value:P,onChange:(e,t)=>E(t)})]}),(0,n.jsx)(u.Z,{children:(0,n.jsx)(Z.Z,{title:"Forcing line breaks makes it easier to adjust column widths to your liking",children:(0,n.jsx)(m.Z,{control:(0,n.jsx)(p.Z,{checked:"break-all"===U,onChange:e=>{A(e.target.checked?"break-all":"break-word")}}),label:"Force line breaks"})})}),(0,n.jsx)(u.Z,{flexGrow:1}),(0,n.jsx)(u.Z,{display:"flex",justifyContent:"flex-end",children:(0,n.jsxs)(eZ,{direction:"row",spacing:2,children:[R&&(0,n.jsx)(Z.Z,{title:"View config",children:(0,n.jsx)(d.Z,{color:"primary",onClick:()=>$(!0),startIcon:(0,n.jsx)(S.Z,{}),children:"View Config"})}),R&&(0,n.jsx)(Z.Z,{title:"Edit eval",children:(0,n.jsx)(d.Z,{color:"primary",onClick:()=>{N(R),c.push("/setup/")},startIcon:(0,n.jsx)(k.Z,{}),children:"Edit Eval"})}),(null==R?void 0:R.sharing)&&(0,n.jsx)(Z.Z,{title:"Generate a unique URL that others can access",children:(0,n.jsx)(d.Z,{color:"primary",onClick:Y,disabled:G,startIcon:G?(0,n.jsx)(a.Z,{size:16}):(0,n.jsx)(C.Z,{}),children:"Share"})})]})})]})}),(0,n.jsx)(_,{columnVisibility:F}),(0,n.jsx)(em,{maxTextLength:P,columnVisibility:F,wordBreak:U,filterMode:O,failureFilter:I,onFailureFilterToggle:(e,t)=>{M(s=>({...s,[e]:t}))}}),(0,n.jsx)(ef,{open:X,onClose:()=>$(!1)}),(0,n.jsx)(ey,{open:z,onClose:()=>H(!1),shareUrl:B})]})}var eC=s(2810),eS=s(279);async function ek(){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 eR(e){let t=(0,c.createClientComponentClient)(),{data:s,error:n}=await t.from("EvaluationResult").select("*").eq("id",e).single();return s}function eN(e){var t;let{fetchId:s,preloadedData:c,recentEvals:d,defaultEvalId:u}=e,p=(0,o.useRouter)(),{table:h,setTable:m,setConfig:x}=W(),[j,f]=l.useState(!1),[g,v]=l.useState(!1),[y,b]=l.useState(d||[]),Z=async()=>{(0,r.Z)(eS.T,"Cannot fetch recent files when not running locally");let e=await fetch("".concat(await (0,eC.b)(),"/results"),{cache:"no-store"}),t=await e.json();return b(t.data),t.data},w=async e=>{let t=await fetch("".concat(await (0,eC.b)(),"/results/").concat(e),{cache:"no-store"}),s=await t.json();m(s.data.results.table),x(s.data.config)},C=async e=>{eS.T?w(e):(f(!1),p.push("/eval/remote:".concat(encodeURIComponent(e))))},[S,k]=l.useState(u||(null===(t=y[0])||void 0===t?void 0:t.id)),R=(0,o.useSearchParams)(),N=R?R.get("file"):null;return(l.useEffect(()=>{if(N){let e=async()=>{await w(N),f(!0)};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=await fetch("https://api.promptfoo.dev/eval/".concat(s));if(!t.ok){v(!0);return}let n=await t.json();m(null===(e=n.data.results)||void 0===e?void 0:e.table),x(n.data.config),f(!0)};e()}else eS.T?(0,eC.b)().then(e=>{let t=(0,i.io)(e);return t.on("init",e=>{console.log("Initialized socket connection",e),f(!0),m(e.results.table),x(e.config),Z().then(e=>{var t;k(null===(t=e[0])||void 0===t?void 0:t.id)})}),t.on("update",e=>{console.log("Received data update",e),m(e.results.table),x(e.config),Z().then(e=>{var t;k(null===(t=e[0])||void 0===t?void 0:t.id)})}),()=>{t.disconnect()}}):ek().then(e=>{b(e.map(e=>({id:e.id,label:e.createdAt}))),e.length>0&&eR(e[0].id).then(t=>{(0,r.Z)(t,"Eval not found");let s=t.results,n=t.config;k(e[0].id),m(s.table),x(n),f(!0)})})},[s,m,x,c,k,N]),g)?(0,n.jsx)("div",{className:"loading",children:"404 Eval not found"}):j&&h?(0,n.jsx)(ew,{defaultEvalId:S,recentEvals:y,onRecentEvalSelected:C}):(0,n.jsxs)("div",{className:"loading",children:[(0,n.jsx)("div",{children:(0,n.jsx)(a.Z,{size:22})}),(0,n.jsx)("div",{children:"Loading eval data"})]})}s(5038)},279:function(e,t,s){"use strict";s.d(t,{T:function(){return l},e:function(){return r}});var n=s(2601);let l=!n.env.NEXT_PUBLIC_PROMPTFOO_BUILD_STANDALONE_SERVER,r=""},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(){},5777:function(){}}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[11],{9716:function(e,n,s){Promise.resolve().then(s.t.bind(s,6685,23)),Promise.resolve().then(s.bind(s,1860))}},function(e){e.O(0,[674,293,808,548,82,420,975,756,919,886,860,971,596,744],function(){return e(e.s=9716)}),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[413],{875:function(e,t,n){Promise.resolve().then(n.bind(n,2378))},2378:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return ec}});var a=n(7437),r=n(2265),i=n(5551),l=n(8938),o=n(3226),s=n(6507),c=n(3457),d=n(9394),p=n(2834),u=n(6337),h=n(4173),x=n(1797),m=n(4740),j=n(4033),g=n(6882),f=n(1938),v=n(279),Z=()=>{let e=(0,j.useRouter)(),{env:t,description:n,providers:l,prompts:o,testCases:s}=(0,f.o)(),[c,d]=(0,r.useState)(!1),[p,u]=(0,r.useState)(0),h=async()=>{d(!0);try{let a=await fetch("".concat(v.e,"/api/eval/"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:t,description:n,providers:l,prompts:o,tests:s})});if(!a.ok)throw Error("HTTP error! status: ".concat(a.status));let r=await a.json(),i=setInterval(async()=>{let t=await fetch("".concat(v.e,"/api/eval/").concat(r.id,"/"));if(!t.ok)throw clearInterval(i),Error("HTTP error! status: ".concat(t.status));let n=await t.json();if("complete"===n.status)clearInterval(i),d(!1),v.T?e.push("/eval"):e.push("/eval/remote:".concat(encodeURIComponent(r.id)));else if("failed"===n.status)throw clearInterval(i),d(!1),Error("Job failed");else{let e=0===n.total?0:Math.round(n.progress/n.total*100);u(e)}},1e3)}catch(e){console.error(e),d(!1),alert("An error occurred: ".concat(e.message))}};return(0,a.jsx)(i.Z,{variant:"contained",color:"primary",onClick:h,disabled:c,children:c?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(g.Z,{size:24,sx:{marginRight:2}}),p.toFixed(0),"% complete"]}):"Run Evaluation"})},b=n(2057),y=n(8768),C=n(5873),_=n(1975),k=n(3295),A=()=>{let{env:e,setEnv:t}=(0,f.o)(),[n,l]=(0,r.useState)(!1),[o,s]=(0,r.useState)(e),c=()=>{l(!1)};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.Z,{variant:"outlined",startIcon:(0,a.jsx)(k.Z,{}),onClick:()=>{l(!0)},children:"API keys"}),(0,a.jsxs)(d.Z,{open:n,onClose:c,fullWidth:!0,maxWidth:"md",children:[(0,a.jsx)(x.Z,{children:"Provider settings"}),(0,a.jsxs)(u.Z,{children:[(0,a.jsxs)(b.Z,{defaultExpanded:!0,children:[(0,a.jsx)(C.Z,{children:"OpenAI"}),(0,a.jsxs)(y.Z,{children:[(0,a.jsx)(_.Z,{label:"OpenAI API key",fullWidth:!0,margin:"normal",value:o.OPENAI_API_KEY,onChange:e=>s({...o,OPENAI_API_KEY:e.target.value})}),(0,a.jsx)(_.Z,{label:"OpenAI API host",fullWidth:!0,margin:"normal",value:o.OPENAI_API_HOST,onChange:e=>s({...o,OPENAI_API_HOST:e.target.value})}),(0,a.jsx)(_.Z,{label:"OpenAI organization",fullWidth:!0,margin:"normal",value:o.OPENAI_ORGANIZATION,onChange:e=>s({...o,OPENAI_ORGANIZATION:e.target.value})})]})]}),(0,a.jsxs)(b.Z,{children:[(0,a.jsx)(C.Z,{children:"Azure"}),(0,a.jsx)(y.Z,{children:(0,a.jsx)(_.Z,{label:"Azure API key",fullWidth:!0,margin:"normal",value:o.AZURE_OPENAI_API_KEY,onChange:e=>s({...o,AZURE_OPENAI_API_KEY:e.target.value})})})]}),(0,a.jsxs)(b.Z,{children:[(0,a.jsx)(C.Z,{children:"Amazon Bedrock"}),(0,a.jsx)(y.Z,{children:(0,a.jsx)(_.Z,{label:"Bedrock Region",fullWidth:!0,margin:"normal",value:o.AWS_BEDROCK_REGION,onChange:e=>s({...o,AWS_BEDROCK_REGION:e.target.value})})})]}),(0,a.jsxs)(b.Z,{children:[(0,a.jsx)(C.Z,{children:"Anthropic"}),(0,a.jsx)(y.Z,{children:(0,a.jsx)(_.Z,{label:"Anthropic API key",fullWidth:!0,margin:"normal",value:o.ANTHROPIC_API_KEY,onChange:e=>s({...o,ANTHROPIC_API_KEY:e.target.value})})})]}),(0,a.jsxs)(b.Z,{children:[(0,a.jsx)(C.Z,{children:"Google Vertex AI"}),(0,a.jsx)(y.Z,{children:(0,a.jsx)(_.Z,{label:"Vertex API Key",fullWidth:!0,margin:"normal",value:o.VERTEX_API_KEY,onChange:e=>s({...o,VERTEX_API_KEY:e.target.value})})}),(0,a.jsx)(y.Z,{children:(0,a.jsx)(_.Z,{label:"Vertex Project ID",fullWidth:!0,margin:"normal",value:o.VERTEX_PROJECT_ID,onChange:e=>s({...o,VERTEX_PROJECT_ID:e.target.value})})}),(0,a.jsx)(y.Z,{children:(0,a.jsx)(_.Z,{label:"Vertex Region",fullWidth:!0,margin:"normal",value:o.VERTEX_REGION,onChange:e=>s({...o,VERTEX_REGION:e.target.value})})})]}),(0,a.jsxs)(b.Z,{children:[(0,a.jsx)(C.Z,{children:"Replicate"}),(0,a.jsx)(y.Z,{children:(0,a.jsx)(_.Z,{label:"Replicate API key",fullWidth:!0,margin:"normal",value:o.REPLICATE_API_KEY,onChange:e=>s({...o,REPLICATE_API_KEY:e.target.value})})})]})]}),(0,a.jsxs)(p.Z,{children:[(0,a.jsx)(i.Z,{onClick:c,color:"primary",children:"Cancel"}),(0,a.jsx)(i.Z,{onClick:()=>{t(o),c()},color:"primary",variant:"contained",children:"Save"})]})]})]})},E=n(2653),I=n(3701),S=n(9279),P=n(666),O=n(5795),T=n(4147),w=n(8276),R=n(3391),N=n(6446),W=n(1280),z=n(9329),V=e=>{let{open:t,prompt:n,index:l,onAdd:o,onCancel:s}=e,[c,h]=r.useState(n),m=r.useRef(null);r.useEffect(()=>{h(n)},[n]);let j=e=>{o(c),h(""),e?s():m.current&&m.current.focus()};return(0,a.jsxs)(d.Z,{open:t,onClose:s,fullWidth:!0,maxWidth:"md",children:[(0,a.jsx)(x.Z,{children:"Edit Prompt ".concat(l+1)}),(0,a.jsx)(u.Z,{children:(0,a.jsx)(_.Z,{value:c,onChange:e=>h(e.target.value),fullWidth:!0,margin:"normal",multiline:!0,placeholder:"The quick brown {{animal1}} jumps over the lazy {{animal2}}.",helperText:"Tip: use the {{varname}} syntax to add variables to your prompt.",inputRef:m})}),(0,a.jsxs)(p.Z,{children:[(0,a.jsx)(i.Z,{onClick:j.bind(null,!0),color:"primary",variant:"contained",disabled:!c.length,children:"Add"}),(0,a.jsx)(i.Z,{onClick:j.bind(null,!1),color:"primary",variant:"contained",disabled:!c.length,children:"Add Another"}),(0,a.jsx)(i.Z,{onClick:s,color:"secondary",children:"Cancel"})]})]})};n(2280);var F=()=>{let[e,t]=(0,r.useState)(!1),[n,l]=(0,r.useState)(null),{prompts:s,setPrompts:d}=(0,f.o)(),p=(0,r.useRef)(null);(0,r.useEffect)(()=>{null!==n&&n>0&&p.current&&p.current.focus()},[n]);let u=e=>{l(e),t(!0)},h=(e,t)=>{e.stopPropagation();let n=s[t];d([...s,n])},x=(e,t)=>{d(s.map((n,a)=>a===e?t:n))},m=(e,t)=>{e.stopPropagation(),confirm("Are you sure you want to remove this prompt?")&&d(s.filter((e,n)=>n!==t))};return(0,a.jsxs)("div",{children:[(0,a.jsxs)(c.Z,{direction:"row",spacing:2,justifyContent:"space-between",children:[(0,a.jsx)(o.Z,{variant:"h5",children:"Prompts"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{htmlFor:"file-input-add-prompt",children:(0,a.jsx)(w.Z,{title:"Upload prompt from file",children:(0,a.jsxs)("span",{children:[(0,a.jsx)(E.Z,{component:"span",children:(0,a.jsx)(W.Z,{})}),(0,a.jsx)("input",{id:"file-input-add-prompt",type:"file",accept:".txt,.md",onChange:e=>{var t;e.stopPropagation(),e.preventDefault();let n=null===(t=e.target.files)||void 0===t?void 0:t[0];if(n){let e=new FileReader;e.onload=e=>{var t,n;let a=null===(n=e.target)||void 0===n?void 0:null===(t=n.result)||void 0===t?void 0:t.toString();a&&d([...s,a])},e.readAsText(n)}},style:{display:"none"}})]})})}),(0,a.jsx)(i.Z,{color:"primary",onClick:()=>{t(!0)},variant:"contained",children:"Add Prompt"})]})]}),(0,a.jsx)(O.Z,{children:(0,a.jsx)(I.Z,{children:(0,a.jsx)(S.Z,{children:0===s.length?(0,a.jsx)(T.Z,{children:(0,a.jsx)(P.Z,{colSpan:2,align:"center",children:"No prompts added yet."})}):s.map((e,t)=>(0,a.jsxs)(T.Z,{sx:{"&:hover":{backgroundColor:"rgba(0, 0, 0, 0.04)",cursor:"pointer"}},onClick:()=>u(t),children:[(0,a.jsx)(P.Z,{children:(0,a.jsxs)(o.Z,{variant:"body2",children:["Prompt #".concat(t+1,": "),(e.length>250?e.slice(0,250)+" ...":e).split(/({{\w+}})/g).map((e,t)=>/{{\w+}}/g.test(e)?(0,a.jsx)("span",{className:"prompt-var-highlight",children:e},t):e)]})}),(0,a.jsxs)(P.Z,{align:"right",sx:{minWidth:150},children:[(0,a.jsx)(E.Z,{onClick:()=>u(t),size:"small",children:(0,a.jsx)(R.Z,{})}),(0,a.jsx)(E.Z,{onClick:e=>h(e,t),size:"small",children:(0,a.jsx)(z.Z,{})}),(0,a.jsx)(E.Z,{onClick:e=>m(e,t),size:"small",children:(0,a.jsx)(N.Z,{})})]})]},t))})})}),(0,a.jsx)(V,{open:e,prompt:null!==n?s[n]:"",index:null!==n?n:0,onAdd:e=>{null!==n?x(n,e):d([...s,e]),l(null)},onCancel:()=>{l(null),t(!1)}})]})},L=n(6988),K=e=>{let{onAdd:t,varsList:n,initialValues:i}=e,[l,d]=r.useState(i||{});return(0,r.useEffect)(()=>{let e={};n.forEach(t=>{e[t]=(null==i?void 0:i[t])||""}),d(e)},[n,i]),(0,a.jsxs)(s.Z,{my:2,children:[(0,a.jsx)(o.Z,{variant:"h6",mb:2,children:"Vars"}),n.length>0?(0,a.jsx)(c.Z,{direction:"row",spacing:2,alignItems:"center",children:Object.keys(l).map((e,n)=>(0,a.jsx)(c.Z,{direction:"row",spacing:2,alignItems:"center",children:(0,a.jsx)(_.Z,{placeholder:e,label:e,value:l[e],fullWidth:!0,onChange:n=>{let a=n.target.value,r={...l,[e]:a};d(r),t(r)}})},n))}):(0,a.jsxs)(o.Z,{variant:"subtitle1",gutterBottom:!0,children:["Add variables to your prompt using the ","{{varname}}"," syntax."]})]})},B=n(8440);let Y=["equals","contains","icontains","contains-all","contains-any","starts-with","regex","is-json","contains-json","similar","llm-rubric","model-graded-closedqa","factuality","model-graded-factuality","webhook","rouge-n","rouge-s","rouge-l","not-equals","not-contains","not-icontains","not-contains-all","not-contains-any","not-starts-with","not-regex","not-is-json","not-contains-json","not-similar","not-webhook","not-rouge-n","not-rouge-s","not-rouge-l","is-valid-openai-function-call","is-valid-openai-tools-call","latency","perplexity","answer-relevance","context-faithfulness","context-recall","context-relevance"];var J=e=>{let{onAdd:t,initialValues:n}=e,[l,d]=(0,r.useState)(n||[]),p=e=>{let n=l.filter((t,n)=>n!==e);d(n),t(n)};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.Z,{variant:"h6",children:"Asserts"}),(0,a.jsx)(s.Z,{my:l.length>0?2:0,children:(0,a.jsx)(c.Z,{direction:"column",spacing:2,children:l.map((e,n)=>(0,a.jsxs)(c.Z,{direction:"row",spacing:2,alignItems:"center",children:[(0,a.jsx)(B.Z,{value:e.type,options:Y,sx:{minWidth:200},onChange:(e,a)=>{let r=l.map((e,t)=>t===n?{...e,type:a}:e);d(r),t(r)},renderInput:e=>(0,a.jsx)(_.Z,{...e,label:"Type"})}),(0,a.jsx)(_.Z,{label:"Value",value:e.value,fullWidth:!0,onChange:e=>{let a=e.target.value,r=l.map((e,t)=>t===n?{...e,value:a}:e);d(r),t(r)}}),(0,a.jsx)(E.Z,{onClick:()=>p(n),size:"small",children:(0,a.jsx)(N.Z,{})})]},n))})}),(0,a.jsx)(i.Z,{color:"primary",onClick:()=>{let e=[...l,{type:"equals",value:""}];d(e),t(e)},children:"Add Assert"})]})},U=e=>{let{open:t,onAdd:n,varsList:l,initialValues:o,onCancel:c}=e,[h,m]=(0,r.useState)((null==o?void 0:o.description)||""),[j,g]=(0,r.useState)((null==o?void 0:o.vars)||{}),[f,v]=(0,r.useState)((null==o?void 0:o.assert)||[]),[Z,b]=(0,r.useState)(0);r.useEffect(()=>{o?(m(o.description||""),g(o.vars||{}),v(o.assert||[])):(m(""),g({}),v([]))},[o]);let y=e=>{n({description:h,vars:j,assert:f},e),e&&c(),m(""),g({}),v([]),b(e=>e+1)};return(0,a.jsxs)(d.Z,{open:t,onClose:c,fullWidth:!0,maxWidth:"md",children:[(0,a.jsx)(x.Z,{children:o?"Edit Test Case":"Add Test Case"}),(0,a.jsx)(u.Z,{children:(0,a.jsxs)(s.Z,{children:[(0,a.jsx)(K,{onAdd:e=>g(e),varsList:l,initialValues:null==o?void 0:o.vars}),(0,a.jsx)(J,{onAdd:e=>v(e),initialValues:(null==o?void 0:o.assert)||[]},Z)]})}),(0,a.jsxs)(p.Z,{children:[(0,a.jsx)(i.Z,{onClick:y.bind(void 0,!0),color:"primary",variant:"contained",children:o?"Update Test Case":"Add Test Case"}),!o&&(0,a.jsx)(i.Z,{onClick:y.bind(void 0,!1),color:"primary",variant:"contained",children:"Add Another"}),(0,a.jsx)(i.Z,{onClick:c,color:"secondary",children:"Cancel"})]})]})},D=e=>{let{varsList:t}=e,{testCases:n,setTestCases:l}=(0,f.o)(),[s,d]=r.useState(null),[p,u]=r.useState(!1),h=(e,t)=>{e.stopPropagation(),confirm("Are you sure you want to delete this test case?")&&l(n.filter((e,n)=>n!==t))},x=(e,t)=>{e.stopPropagation();let a=JSON.parse(JSON.stringify(n[t]));l([...n,a])};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(c.Z,{direction:"row",spacing:2,justifyContent:"space-between",children:[(0,a.jsx)(o.Z,{variant:"h5",children:"Test Cases"}),(0,a.jsx)(i.Z,{color:"primary",onClick:()=>u(!0),variant:"contained",children:"Add Test Case"})]}),(0,a.jsx)(O.Z,{children:(0,a.jsxs)(I.Z,{children:[(0,a.jsx)(L.Z,{children:(0,a.jsxs)(T.Z,{children:[(0,a.jsx)(P.Z,{children:"Description"}),(0,a.jsx)(P.Z,{children:"Assertions"}),(0,a.jsx)(P.Z,{children:"Variables"}),(0,a.jsx)(P.Z,{align:"right"})]})}),(0,a.jsx)(S.Z,{children:0===n.length?(0,a.jsx)(T.Z,{children:(0,a.jsx)(P.Z,{colSpan:4,align:"center",children:"No test cases added yet."})}):n.map((e,t)=>{var n;return(0,a.jsxs)(T.Z,{sx:{"&:hover":{backgroundColor:"rgba(0, 0, 0, 0.04)",cursor:"pointer"}},onClick:()=>{d(t),u(!0)},children:[(0,a.jsx)(P.Z,{children:(0,a.jsx)(o.Z,{variant:"body2",children:e.description||"Test Case #".concat(t+1)})}),(0,a.jsxs)(P.Z,{children:[(null===(n=e.assert)||void 0===n?void 0:n.length)||0," assertions"]}),(0,a.jsx)(P.Z,{children:Object.entries(e.vars||{}).map(e=>{let[t,n]=e;return t+"="+n}).join(", ")}),(0,a.jsxs)(P.Z,{align:"right",sx:{minWidth:150},children:[(0,a.jsx)(E.Z,{onClick:()=>{d(t),u(!0)},size:"small",children:(0,a.jsx)(R.Z,{})}),(0,a.jsx)(E.Z,{onClick:e=>x(e,t),size:"small",children:(0,a.jsx)(z.Z,{})}),(0,a.jsx)(E.Z,{onClick:e=>h(e,t),size:"small",children:(0,a.jsx)(N.Z,{})})]})]},t)})})]})}),(0,a.jsx)(U,{open:p,onAdd:(e,t)=>{if(null===s)l([...n,e]);else{let t=n.map((t,n)=>n===s?e:t);l(t),d(null)}t&&u(!1)},varsList:t,initialValues:null!==s?n[s]:void 0,onCancel:()=>{d(null),u(!1)}})]})},q=n(7827),G=e=>{let{onChange:t,...n}=e,[i,l]=r.useState(""),[o,s]=r.useState(!1);return(0,a.jsx)(_.Z,{...n,error:o,helperText:o?"Invalid JSON":"",value:i,onChange:e=>{let n=e.target.value;try{let e=JSON.parse(n);l(n),s(!1),t&&t(e)}catch(e){l(n),s(!0)}}})},X=e=>{let{open:t,providerId:n,config:l,onClose:o,onSave:c}=e,[h,m]=r.useState(l);return r.useEffect(()=>{m(l)},[l]),(0,a.jsxs)(d.Z,{open:t,onClose:o,fullWidth:!0,maxWidth:"md",children:[(0,a.jsxs)(x.Z,{children:["Edit ",n.length>50?n.slice(0,50)+"...":n]}),(0,a.jsx)(u.Z,{children:Object.keys(h).map(e=>{let t;let n=h[e];return"number"==typeof n||"boolean"==typeof n||"string"==typeof n?(t="number"==typeof n?t=>m({...h,[e]:parseFloat(t.target.value)}):"boolean"==typeof n?t=>m({...h,[e]:"true"===t.target.value}):t=>{let n=t.target.value.trim();if(n.startsWith("{")||n.startsWith("["))try{m({...h,[e]:JSON.parse(n)})}catch(t){m({...h,[e]:n})}else"null"===n?m({...h,[e]:null}):"undefined"===n?m({...h,[e]:void 0}):m({...h,[e]:n})},(0,a.jsx)(s.Z,{my:2,children:(0,a.jsx)(_.Z,{label:e,value:n,onChange:t,fullWidth:!0,InputLabelProps:{shrink:!0},type:"number"==typeof n?"number":"text"})},e)):(0,a.jsx)(s.Z,{my:2,children:(0,a.jsx)(G,{label:e,defaultValue:JSON.stringify(n),onChange:t=>{m({...h,[e]:t})},fullWidth:!0,multiline:!0,minRows:2,InputLabelProps:{shrink:!0}})},e)})}),(0,a.jsxs)(p.Z,{children:[(0,a.jsx)(i.Z,{onClick:o,children:"Cancel"}),(0,a.jsx)(i.Z,{onClick:()=>{c(h)},children:"Save"})]})]})};let H=[].concat(["replicate:replicate/flan-t5-small:69716ad8c34274043bf4a135b7315c7c569ec931d8f23d6826e249e1c142a264"].map(e=>({id:e,config:{temperature:.5,max_length:1024,repetition_penality:1}}))).concat(["replicate:replicate/codellama-7b-instruct:0103579e86fc75ba0d65912890fa19ef03c84a68554635319accf2e0ba93d3ae","replicate:replicate/codellama-13b-instruct:da5676342de1a5a335b848383af297f592b816b950a43d251a0a9edd0113604b","replicate:replicate/llama-2-70b-chat:2796ee9483c3fd7aa2e171d38f4ca12251a30609463dcfd4cd76703f22e96cdf"].map(e=>({id:e,config:{system_prompt:"",temperature:.75,top_p:.9,top_k:50,max_new_tokens:128,min_new_tokens:-1}}))).concat(["replicate:replicate/codellama-7b:6880b103613a9cd23950c5fd6c140197e519905bd0dd00e448c4858bdd06090a","replicate:replicate/codellama-13b-python:09b87c02dfa403e0c3289166dece62286b3bce49bae39a9c9204713cf94b8b7d","replicate:replicate/codellama-13b:1c914d844307b0588599b8393480a3ba917b660c7e9dfae681542b5325f228db","replicate:replicate/codellama-34b-python:9048743d22a7b19cd0abb018066809ea6af4f2b4717bef9aad3c5ae21ceac00d","replicate:replicate/codellama-34b:0666717e5ead8557dff55ee8f11924b5c0309f5f1ca52f64bb8eec405fdb38a7"].map(e=>({id:e,config:{temperature:.75,top_p:.9,top_k:50,max_new_tokens:128,min_new_tokens:-1}}))).concat(["replicate:a16z-infra/llama-2-7b-chat:7b0bfc9aff140d5b75bacbed23e91fd3c34b01a1e958d32132de6e0a19796e2c","replicate:a16z-infra/llama-2-13b-chat:2a7f981751ec7fdf87b5b91ad4db53683a98082e9ff7bfd12c8cd5ea85980a52"].map(e=>({id:e,config:{temperature:.95,top_p:.95,top_k:250,max_new_tokens:500,min_new_tokens:-1,repetition_penality:1,system_prompt:""}}))).concat(["anthropic:claude-1","anthropic:claude-1-100k","anthropic:claude-instant-1","anthropic:claude-instant-1-100k"].map(e=>({id:e,config:{max_tokens_to_sample:256,temperature:.5}}))).concat(["bedrock:anthropic.claude-instant-v1","bedrock:anthropic.claude-v1","bedrock:anthropic.claude-v2"].map(e=>({id:e,config:{max_tokens_to_sample:256,temperature:.5}}))).concat(["openai:gpt-3.5-turbo","openai:gpt-3.5-turbo-0301","openai:gpt-3.5-turbo-0613","openai:gpt-3.5-turbo-16k","openai:gpt-3.5-turbo-16k-0613","openai:gpt-4","openai:gpt-4-0314","openai:gpt-4-0613","openai:gpt-4-32k","openai:gpt-4-32k-0314"].map(e=>({id:e,config:{organization:"",temperature:.5,max_tokens:1024,top_p:1,frequency_penalty:0,presence_penalty:0,function_call:void 0,functions:void 0,stop:void 0}}))).concat(["azureopenai:gpt-3.5-turbo","azureopenai:gpt-3.5-turbo-0301","azureopenai:gpt-3.5-turbo-0613","azureopenai:gpt-3.5-turbo-16k","azureopenai:gpt-3.5-turbo-16k-0613","azureopenai:gpt-4","azureopenai:gpt-4-0314","azureopenai:gpt-4-0613","azureopenai:gpt-4-32k","azureopenai:gpt-4-32k-0314"].map(e=>({id:e,config:{temperature:.5,max_tokens:1024,top_p:1,frequency_penalty:0,presence_penalty:0,function_call:void 0,functions:void 0,stop:void 0}}))).concat(["vertex:chat-bison@001","vertex:chat-bison","vertex:chat-bison-32k","vertex:chat-bison-32k@001"].map(e=>({id:e,config:{context:void 0,examples:void 0,temperature:0,maxOutputTokens:1024,topP:.95,topK:40,safetySettings:void 0,stopSequence:void 0}}))).sort((e,t)=>e.id.localeCompare(t.id)),M={anthropic:"Anthropic",bedrock:"Amazon Web Services",azureopenai:"Azure",openai:"OpenAI",replicate:"Replicate"};var Q=e=>{let{providers:t,onChange:n}=e,[i,l]=r.useState(null),o=e=>"string"==typeof e?e:e.id||"Unknown provider",c=(e,t)=>"string"==typeof e?e:e.id||t,d=e=>{"string"==typeof e?alert("Cannot edit custom providers"):e.config?l(e):alert("There is no config for this provider")};return(0,a.jsxs)(s.Z,{mt:2,children:[(0,a.jsx)(B.Z,{multiple:!0,freeSolo:!0,options:H,value:t,groupBy:e=>(function(e){if(!e)return"Other";let t=e.split(":")[0];return M[t]||t})(e.id),onChange:(e,t)=>{n(t.map(e=>"string"==typeof e?{id:e}:e))},getOptionLabel:e=>{if(!e)return"";let t="";"string"==typeof e&&(t=e),e.id&&"string"==typeof e.id&&(t=e.id);let n=t.split(":");return n.length>1?n[1]:"Unknown provider"},renderTags:(e,t)=>e.map((e,n)=>{let a=o(e),i=c(e,n);return(0,r.createElement)(q.Z,{variant:"outlined",label:a,...t({index:n}),key:i,onClick:()=>d(e)})}),renderInput:e=>(0,a.jsx)(_.Z,{...e,variant:"outlined",placeholder:"Select LLM providers",helperText:t.length>0?"Click a provider to configure its settings.":null})}),i&&i.id&&(0,a.jsx)(X,{open:!!i,providerId:i.id,config:i.config,onClose:()=>l(null),onSave:e=>{if(i){let a=t.map(t=>t.id===i.id?{...t,config:e}:t);n(a),l(null)}}})]})},$=n(3425),ee=n.n($),et=n(4759);n(5341),n(7555);var en=n(8339),ea=n(9963),er=n(1396),ei=n.n(er);n(695);var el=()=>{let{env:e,setEnv:t,description:n,setDescription:l,providers:c,setProviders:d,prompts:p,setPrompts:u,testCases:h,setTestCases:x}=(0,f.o)(),[m,j]=r.useState(""),[g,v]=r.useState(!0);r.useEffect(()=>{j(en.default.dump({env:e,description:n,providers:c,prompts:p,tests:h}))},[e,n,c,p,h]);let Z=e=>{t(e.env||{}),l(e.description||""),d(e.providers||[]),u(e.prompts||[]),x(e.tests||[])};return(0,a.jsxs)(s.Z,{mt:4,children:[(0,a.jsx)(o.Z,{variant:"h5",gutterBottom:!0,children:"Configuration"}),(0,a.jsxs)(o.Z,{variant:"body1",gutterBottom:!0,children:["This is the YAML config that defines the evaluation and is processed by promptfoo. See"," ",(0,a.jsx)(ei(),{target:"_blank",href:"https://promptfoo.dev/docs/configuration/guide",children:"configuration docs"})," ","to learn more."]}),(0,a.jsx)(i.Z,{variant:"text",color:"primary",startIcon:g?(0,a.jsx)(R.Z,{}):(0,a.jsx)(ea.Z,{}),onClick:()=>{if(!g)try{let e=en.default.load(m,{json:!0});Z(e)}catch(e){}v(!g)},children:g?"Edit YAML":"Save"}),(0,a.jsx)(ee(),{autoCapitalize:"off",value:m,onValueChange:e=>{g||j(e)},highlight:e=>(0,et.highlight)(e,et.languages.yaml),padding:10,style:{fontFamily:'"Fira code", "Fira Mono", monospace',fontSize:14},disabled:g,className:g?"":"glowing-border"})]})};n(284);var eo=n(2601);function es(e){let{error:t,resetErrorBoundary:n}=e;return(0,a.jsxs)("div",{role:"alert",children:[(0,a.jsx)("p",{children:"Something went wrong:"}),(0,a.jsx)("pre",{children:t.message}),(0,a.jsx)("button",{onClick:n,children:"Try again"})]})}var ec=()=>{let[e,t]=(0,r.useState)(!1),{description:n,setDescription:j,providers:g,setProviders:v,prompts:b,setPrompts:y,testCases:C,setTestCases:_}=(0,f.o)();if((0,r.useEffect)(()=>{f.o.persist.rehydrate()},[]),eo.env.NEXT_PUBLIC_NO_BROWSING)return null;let k=(e=>{let t=/{{(\w+)}}/g,n=new Set;return e.forEach(e=>{let a;for(;null!==(a=t.exec(e));)n.add(a[1])}),Array.from(n)})(b);return(0,a.jsxs)(l.Z,{maxWidth:"lg",sx:{marginTop:"2rem"},children:[(0,a.jsxs)(c.Z,{direction:"row",spacing:2,justifyContent:"space-between",children:[(0,a.jsx)(o.Z,{variant:"h4",children:"Set up an evaluation"}),(0,a.jsxs)(c.Z,{direction:"row",spacing:2,children:[(0,a.jsx)(Z,{}),(0,a.jsx)(A,{}),(0,a.jsx)(i.Z,{variant:"outlined",color:"primary",onClick:()=>t(!0),children:"Reset"})]})]}),(0,a.jsx)(s.Z,{mt:4}),(0,a.jsx)(s.Z,{mt:2,children:(0,a.jsx)(m.SV,{FallbackComponent:es,onReset:()=>{v([])},children:(0,a.jsxs)(c.Z,{direction:"column",spacing:2,justifyContent:"space-between",children:[(0,a.jsx)(o.Z,{variant:"h5",children:"Providers"}),(0,a.jsx)(Q,{providers:g,onChange:v})]})})}),(0,a.jsx)(s.Z,{mt:4}),(0,a.jsx)(m.SV,{FallbackComponent:es,onReset:()=>{y([])},children:(0,a.jsx)(F,{})}),(0,a.jsx)(s.Z,{mt:6}),(0,a.jsx)(m.SV,{FallbackComponent:es,onReset:()=>{_([])},children:(0,a.jsx)(D,{varsList:k})}),(0,a.jsx)(el,{}),(0,a.jsxs)(d.Z,{open:e,onClose:()=>t(!1),"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[(0,a.jsx)(x.Z,{id:"alert-dialog-title",children:"Confirm Reset"}),(0,a.jsx)(u.Z,{children:(0,a.jsx)(h.Z,{id:"alert-dialog-description",children:"Are you sure you want to reset all the fields? This action cannot be undone."})}),(0,a.jsxs)(p.Z,{children:[(0,a.jsx)(i.Z,{onClick:()=>t(!1),children:"Cancel"}),(0,a.jsx)(i.Z,{onClick:()=>{j(""),v([]),y([]),_([]),t(!1)},autoFocus:!0,children:"Reset"})]})]})]})}},279:function(e,t,n){"use strict";n.d(t,{T:function(){return r},e:function(){return i}});var a=n(2601);let r=!a.env.NEXT_PUBLIC_PROMPTFOO_BUILD_STANDALONE_SERVER,i=""},1938:function(e,t,n){"use strict";n.d(t,{o:function(){return i}});var a=n(4660),r=n(4810);let i=(0,a.Ue)()((0,r.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 n={};t.description&&(n.description=t.description||""),t.tests&&(n.testCases=t.tests),t.providers&&(n.providers=t.providers),t.prompts&&("string"==typeof t.prompts?n.prompts=[t.prompts]:Array.isArray(t.prompts)?n.prompts=t.prompts.filter(e=>!e.endsWith(".txt")&&!e.endsWith(".json")&&!e.endsWith(".yaml")):console.warn("Invalid prompts config",t.prompts)),e(n)},getTestSuite:()=>{let{description:e,testCases:n,providers:a,prompts:r,env:i}=t();return{env:i,description:e,providers:a,prompts:r,tests:n}}}),{name:"promptfoo",skipHydration:!0}))},2280:function(){},695:function(){},284:function(){}},function(e){e.O(0,[293,808,548,420,975,756,339,919,753,971,596,744],function(){return e(e.s=875)}),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- .custom-metric-container{display:inline-flex;flex-wrap:wrap;gap:.5rem;font-weight:400}.custom-metric-container>span{padding:.25rem .5rem;border-radius:4px;color:var(--text-color);border:1px solid var(--border-color);font-size:smaller;line-height:1.5}.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}.results-table th .action{cursor:pointer;margin-left:.5rem}.results-table th .action svg{vertical-align:middle}.results-table tr .cell{white-space:pre-wrap}.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 .cell-detail{font-weight:400;font-size:.75rem;color:#888}.results-table tr:hover .cell-actions,.results-table tr:hover .cell-detail{visibility:visible}.results-table tr .cell-actions .action{cursor:pointer}.results-table th .prompt-container>*{display:inline}.results-table th .summary{font-weight:400;font-size:1rem;line-height:1.5;margin-top:.75rem}.results-table th .summary .highlight{padding:.25rem .5rem;border-radius:4px;background-color:var(--neutral-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{display:flex;flex-wrap:wrap;gap:.5rem;align-items:center;font-weight:700;margin-bottom:.5rem}.results-table .status .pill{padding:.25rem .5rem;border-radius:4px}.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}.first-prompt-col{border-left:2px solid #888}.first-prompt-row{border-top:2px solid #888}.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}}body{background-color:var(--background-color);color:var(--text-color)}.loading{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:.5rem;font-weight:400}.custom-metric-container>span{padding:.25rem .5rem;border-radius:4px;color:var(--text-color);border:1px solid var(--border-color);font-size:smaller;line-height:1.5}.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}.results-table th .action{cursor:pointer;margin-left:.5rem}.results-table th .action svg{vertical-align:middle}.results-table tr .cell{white-space:pre-wrap}.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 .cell-detail{font-weight:400;font-size:.75rem;color:#888}.results-table tr:hover .cell-actions,.results-table tr:hover .cell-detail{visibility:visible}.results-table tr .cell-actions .action{cursor:pointer}.results-table th .prompt-container>*{display:inline}.results-table th .summary{font-weight:400;font-size:1rem;line-height:1.5;margin-top:.75rem}.results-table th .summary .highlight{padding:.25rem .5rem;border-radius:4px;background-color:var(--neutral-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{display:flex;flex-wrap:wrap;gap:.5rem;align-items:center;font-weight:700;margin-bottom:.5rem}.results-table .status .pill{padding:.25rem .5rem;border-radius:4px}.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}.first-prompt-col{border-left:2px solid #888}.first-prompt-row{border-top:2px solid #888}.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}}body{background-color:var(--background-color);color:var(--text-color)}.error,.loading{display:flex;flex-direction:column;gap:1.5rem;justify-content:center;align-items:center;height:9rem}.error{font-size:1.5rem}