promptfoo 0.86.0 → 0.87.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 (132) hide show
  1. package/dist/package.json +1 -1
  2. package/dist/src/commands/cache.d.ts.map +1 -1
  3. package/dist/src/commands/cache.js +0 -1
  4. package/dist/src/commands/cache.js.map +1 -1
  5. package/dist/src/commands/delete.d.ts.map +1 -1
  6. package/dist/src/commands/delete.js +0 -2
  7. package/dist/src/commands/delete.js.map +1 -1
  8. package/dist/src/commands/eval.d.ts.map +1 -1
  9. package/dist/src/commands/eval.js +5 -1
  10. package/dist/src/commands/eval.js.map +1 -1
  11. package/dist/src/commands/init.d.ts.map +1 -1
  12. package/dist/src/commands/init.js +0 -1
  13. package/dist/src/commands/init.js.map +1 -1
  14. package/dist/src/commands/list.d.ts.map +1 -1
  15. package/dist/src/commands/list.js +0 -3
  16. package/dist/src/commands/list.js.map +1 -1
  17. package/dist/src/commands/redteam/generate.d.ts.map +1 -1
  18. package/dist/src/commands/redteam/generate.js +0 -8
  19. package/dist/src/commands/redteam/generate.js.map +1 -1
  20. package/dist/src/commands/redteam/init.d.ts.map +1 -1
  21. package/dist/src/commands/redteam/init.js +0 -1
  22. package/dist/src/commands/redteam/init.js.map +1 -1
  23. package/dist/src/commands/share.d.ts.map +1 -1
  24. package/dist/src/commands/share.js +0 -1
  25. package/dist/src/commands/share.js.map +1 -1
  26. package/dist/src/commands/show.d.ts.map +1 -1
  27. package/dist/src/commands/show.js +0 -4
  28. package/dist/src/commands/show.js.map +1 -1
  29. package/dist/src/commands/view.d.ts.map +1 -1
  30. package/dist/src/commands/view.js +0 -1
  31. package/dist/src/commands/view.js.map +1 -1
  32. package/dist/src/config.d.ts.map +1 -1
  33. package/dist/src/config.js +4 -0
  34. package/dist/src/config.js.map +1 -1
  35. package/dist/src/database/tables.d.ts +5 -0
  36. package/dist/src/database/tables.d.ts.map +1 -1
  37. package/dist/src/evaluator.d.ts.map +1 -1
  38. package/dist/src/evaluator.js +20 -1
  39. package/dist/src/evaluator.js.map +1 -1
  40. package/dist/src/index.d.ts +2 -0
  41. package/dist/src/index.d.ts.map +1 -1
  42. package/dist/src/index.js +0 -1
  43. package/dist/src/index.js.map +1 -1
  44. package/dist/src/main.d.ts.map +1 -1
  45. package/dist/src/main.js +2 -0
  46. package/dist/src/main.js.map +1 -1
  47. package/dist/src/providers/openai.d.ts +1 -1
  48. package/dist/src/providers/openai.d.ts.map +1 -1
  49. package/dist/src/providers/promptfoo.d.ts +17 -3
  50. package/dist/src/providers/promptfoo.d.ts.map +1 -1
  51. package/dist/src/providers/promptfoo.js +48 -1
  52. package/dist/src/providers/promptfoo.js.map +1 -1
  53. package/dist/src/redteam/constants.d.ts +1 -1
  54. package/dist/src/redteam/constants.d.ts.map +1 -1
  55. package/dist/src/redteam/constants.js +2 -0
  56. package/dist/src/redteam/constants.js.map +1 -1
  57. package/dist/src/redteam/graders.d.ts +2 -0
  58. package/dist/src/redteam/graders.d.ts.map +1 -1
  59. package/dist/src/redteam/graders.js +2 -0
  60. package/dist/src/redteam/graders.js.map +1 -1
  61. package/dist/src/redteam/plugins/crossSessionLeak.d.ts +17 -0
  62. package/dist/src/redteam/plugins/crossSessionLeak.d.ts.map +1 -0
  63. package/dist/src/redteam/plugins/crossSessionLeak.js +116 -0
  64. package/dist/src/redteam/plugins/crossSessionLeak.js.map +1 -0
  65. package/dist/src/redteam/plugins/harmful.js +3 -3
  66. package/dist/src/redteam/plugins/harmful.js.map +1 -1
  67. package/dist/src/redteam/plugins/index.d.ts.map +1 -1
  68. package/dist/src/redteam/plugins/index.js +2 -0
  69. package/dist/src/redteam/plugins/index.js.map +1 -1
  70. package/dist/src/redteam/providers/crescendo/index.d.ts.map +1 -1
  71. package/dist/src/redteam/providers/crescendo/index.js +49 -12
  72. package/dist/src/redteam/providers/crescendo/index.js.map +1 -1
  73. package/dist/src/redteam/providers/iterative.d.ts.map +1 -1
  74. package/dist/src/redteam/providers/iterative.js +33 -4
  75. package/dist/src/redteam/providers/iterative.js.map +1 -1
  76. package/dist/src/redteam/providers/iterativeImage.js +1 -1
  77. package/dist/src/redteam/providers/iterativeImage.js.map +1 -1
  78. package/dist/src/redteam/providers/iterativeTree.d.ts.map +1 -1
  79. package/dist/src/redteam/providers/iterativeTree.js +38 -7
  80. package/dist/src/redteam/providers/iterativeTree.js.map +1 -1
  81. package/dist/src/redteam/strategies/multilingual.d.ts +1 -1
  82. package/dist/src/redteam/strategies/multilingual.d.ts.map +1 -1
  83. package/dist/src/redteam/strategies/multilingual.js +60 -27
  84. package/dist/src/redteam/strategies/multilingual.js.map +1 -1
  85. package/dist/src/table.d.ts +1 -1
  86. package/dist/src/table.d.ts.map +1 -1
  87. package/dist/src/table.js +3 -0
  88. package/dist/src/table.js.map +1 -1
  89. package/dist/src/telemetry.d.ts +4 -1
  90. package/dist/src/telemetry.d.ts.map +1 -1
  91. package/dist/src/telemetry.js +19 -0
  92. package/dist/src/telemetry.js.map +1 -1
  93. package/dist/src/testCases.d.ts.map +1 -1
  94. package/dist/src/testCases.js +13 -0
  95. package/dist/src/testCases.js.map +1 -1
  96. package/dist/src/types/index.d.ts +132 -0
  97. package/dist/src/types/index.d.ts.map +1 -1
  98. package/dist/src/types/index.js +2 -0
  99. package/dist/src/types/index.js.map +1 -1
  100. package/dist/src/util/index.d.ts +2 -0
  101. package/dist/src/util/index.d.ts.map +1 -1
  102. package/dist/src/validators/redteam.js +1 -1
  103. package/dist/src/validators/redteam.js.map +1 -1
  104. package/dist/src/web/nextui/404/index.html +1 -1
  105. package/dist/src/web/nextui/404.html +1 -1
  106. package/dist/src/web/nextui/_next/static/chunks/{86-77b7a9056116d4d0.js → 86-fcb0efd0a19bac7d.js} +1 -1
  107. package/dist/src/web/nextui/_next/static/chunks/app/{layout-2020c5f7a3d5d614.js → layout-ad06af684889c655.js} +1 -1
  108. package/dist/src/web/nextui/_next/static/chunks/app/report/page-f7c9e46492061e19.js +1 -0
  109. package/dist/src/web/nextui/auth/login/index.html +1 -1
  110. package/dist/src/web/nextui/auth/login/index.txt +2 -2
  111. package/dist/src/web/nextui/auth/signup/index.html +1 -1
  112. package/dist/src/web/nextui/auth/signup/index.txt +2 -2
  113. package/dist/src/web/nextui/datasets/index.html +1 -1
  114. package/dist/src/web/nextui/datasets/index.txt +2 -2
  115. package/dist/src/web/nextui/eval/index.html +1 -1
  116. package/dist/src/web/nextui/eval/index.txt +3 -3
  117. package/dist/src/web/nextui/index.html +1 -1
  118. package/dist/src/web/nextui/index.txt +2 -2
  119. package/dist/src/web/nextui/progress/index.html +1 -1
  120. package/dist/src/web/nextui/progress/index.txt +2 -2
  121. package/dist/src/web/nextui/prompts/index.html +1 -1
  122. package/dist/src/web/nextui/prompts/index.txt +2 -2
  123. package/dist/src/web/nextui/report/index.html +1 -1
  124. package/dist/src/web/nextui/report/index.txt +3 -3
  125. package/dist/src/web/nextui/setup/index.html +1 -1
  126. package/dist/src/web/nextui/setup/index.txt +2 -2
  127. package/dist/test/redteam/providers/iterativeTree.test.js +24 -6
  128. package/dist/test/redteam/providers/iterativeTree.test.js.map +1 -1
  129. package/package.json +1 -1
  130. package/dist/src/web/nextui/_next/static/chunks/app/report/page-734a2a4a67b756c4.js +0 -1
  131. /package/dist/src/web/nextui/_next/static/{esmgjQylizTs69qxSTyX7 → 9oePeu-Q4M9r_50nf_Dh9}/_buildManifest.js +0 -0
  132. /package/dist/src/web/nextui/_next/static/{esmgjQylizTs69qxSTyX7 → 9oePeu-Q4M9r_50nf_Dh9}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[86],{49532:function(e,t,n){"use strict";n.d(t,{t:function(){return l}});var s=n(82911);async function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{apiBaseUrl:n}=s.Z.getState();return fetch("".concat(n,"/api").concat(e),t)}},82086:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return ti}});var s=n(24004),l=n(14978),a=n(49532);let r=(0,l.createContext)(void 0),i=e=>{let{children:t}=e,[n,a]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{let e=e=>{"Shift"===e.key&&a(!0)},t=e=>{"Shift"===e.key&&a(!1)};return window.addEventListener("keydown",e),window.addEventListener("keyup",t),()=>{window.removeEventListener("keydown",e),window.removeEventListener("keyup",t)}},[]),(0,s.jsx)(r.Provider,{value:n,children:t})};var o=n(18960),c=n(67070);let d=(0,l.createContext)(void 0),u=()=>{let e=(0,l.useContext)(d);if(!e)throw Error("useToast must be used within a ToastProvider");return e},h=e=>{let{children:t}=e,[n,a]=(0,l.useState)({message:"",severity:"info",open:!1}),r=()=>{a(e=>({...e,open:!1}))};return(0,s.jsxs)(d.Provider,{value:{showToast:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info";a({message:e,severity:t,open:!0})}},children:[t,(0,s.jsx)(o.Z,{open:n.open,autoHideDuration:6e3,onClose:r,children:(0,s.jsx)(c.Z,{onClose:r,severity:n.severity,children:n.message})})]})};var p=n(52428),m=n(82911),x=n(6882),v=n(12594),g=n(28891),j=n(10804),f=n(93179),y=n(47887),b=n(88270),Z=n(11116),w=n(46446),C=n(13391),k=n(98507),S=n(93295),N=n(72467),E=n(95198),I=n(49605),R=n(79245),D=n(49050),F=n(27760),P=n(47827),T=n(84081),M=n(81679),L=n(50819),O=n(8864),A=n(38212),U=n(33932),W=n(74309),z=n(90923),V=n(10654),B=n(13457),J=n(21975),H=n(78276),_=n(72303),Y=n(72053),K=n(94106),G=n(89394),q=n(42834),X=n(26337),$=n(91797),Q=n(29872),ee=n(73701),et=n(39279),en=n(30666),es=n(15795),el=n(66988),ea=n(98489),er=n(43226),ei=n(32162),eo=n.n(ei),ec=e=>{let{open:t,onClose:n,recentEvals:a,onRecentEvalSelected:r,title:i,description:o}=e,[c,d]=(0,l.useState)(""),[u,h]=(0,l.useState)(-1),p=l.useRef(null),m=l.useRef(null),x=()=>{n(),d(""),h(-1)},v=a.filter(e=>eo()(c.toLowerCase(),e.label.toLowerCase())||"string"==typeof e.description&&eo()(c.toLowerCase(),e.description.toLowerCase())),g=e=>{r(e),x()},j=l.useCallback(()=>{if(u>=0&&m.current){let e=m.current.querySelectorAll("tbody tr"),t=Math.min(u+3,e.length-1);e[t]&&e[t].scrollIntoView({behavior:"smooth",block:"nearest"})}},[u]);l.useEffect(()=>{j()},[j]),l.useEffect(()=>{t&&(h(0),setTimeout(()=>{var e;null===(e=p.current)||void 0===e||e.focus()},0))},[t]);let f=l.useId();return(0,s.jsxs)(G.Z,{open:t,onClose:x,maxWidth:"md",fullWidth:!0,children:[i?(0,s.jsx)($.Z,{children:i}):null,(0,s.jsxs)(X.Z,{children:[o?(0,s.jsx)(R.Z,{sx:{mb:4},children:o}):null,(0,s.jsxs)(R.Z,{sx:{width:"100%",mt:2},children:[(0,s.jsx)(J.Z,{fullWidth:!0,variant:"outlined",placeholder:"Search",value:c,onChange:e=>{d(e.target.value),h(0)},onKeyDown:e=>{if(e.stopPropagation(),t)switch(e.key){case"ArrowDown":e.preventDefault(),h(e=>Math.min(e+1,v.length-1));break;case"ArrowUp":e.preventDefault(),h(e=>Math.max(e-1,0));break;case"Enter":e.preventDefault(),u>=0&&u<v.length?g(v[u].evalId):v.length>0&&g(v[0].evalId);break;case"Escape":e.preventDefault(),x()}},sx:{mb:2},inputRef:p,id:"eval-selector-search-".concat(f)}),(0,s.jsx)(es.Z,{component:Q.Z,sx:{height:"600px",overflow:"auto"},ref:m,children:(0,s.jsxs)(ee.Z,{stickyHeader:!0,children:[(0,s.jsx)(el.Z,{children:(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)(en.Z,{children:"Created"}),(0,s.jsx)(en.Z,{children:"Description"}),(0,s.jsx)(en.Z,{children:"# Tests"})]})}),(0,s.jsx)(et.Z,{children:v.length>0?v.map((e,t)=>(0,s.jsxs)(ea.Z,{hover:!0,onClick:()=>g(e.evalId),sx:{cursor:"pointer",backgroundColor:t===u?"rgba(255, 255, 0, 0.1)":"inherit"},children:[(0,s.jsx)(en.Z,{children:new Date(e.createdAt).toLocaleString()}),(0,s.jsx)(en.Z,{children:e.description||e.label}),(0,s.jsx)(en.Z,{children:e.numTests})]},e.evalId)):(0,s.jsx)(ea.Z,{children:(0,s.jsx)(en.Z,{colSpan:3,align:"center",sx:{py:4},children:(0,s.jsxs)(R.Z,{sx:{textAlign:"center",color:"text.secondary"},children:[(0,s.jsx)(R.Z,{sx:{fontSize:"3rem",mb:2},children:"\uD83D\uDD0D"}),(0,s.jsx)(er.Z,{variant:"h6",gutterBottom:!0,children:"No evaluations found"}),(0,s.jsx)(er.Z,{variant:"body2",children:"Try adjusting your search or create a new evaluation"})]})})})})]})})]})]}),(0,s.jsx)(q.Z,{children:(0,s.jsx)(D.Z,{onClick:x,children:"Cancel"})})]})},ed=n(37204),eu=n(94660),eh=n(74810);let ep={getItem:async e=>await (0,ed.U2)(e)||null,setItem:async(e,t)=>{await (0,ed.t8)(e,t)},removeItem:async e=>{await (0,ed.IV)(e)}},em=(0,eu.Ue)()((0,eh.tJ)((e,t)=>({evalId:null,setEvalId:t=>e(()=>({evalId:t})),author:null,setAuthor:t=>e(()=>({author: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})),showPrompts:!1,setShowPrompts:t=>e(()=>({showPrompts:t})),showPassFail:!0,setShowPassFail:t=>e(()=>({showPassFail:t})),inComparisonMode:!1,setInComparisonMode:t=>e(()=>({inComparisonMode:t})),columnStates:{},setColumnState:(t,n)=>e(e=>({columnStates:{...e.columnStates,[t]:n}}))}),{name:"ResultsViewStorage",storage:(0,eh.FL)(()=>ep)}));var ex=function(e){let{initialEvals:t,onComparisonEvalSelected:n}=e,{evalId:r}=em(),[i,o]=(0,l.useState)(!1),[c,d]=(0,l.useState)(t),u=async()=>{try{let e=r||t[0].evalId,n=await (0,a.t)("/results/".concat(e),{cache:"no-store"}),s=await n.json(),l=s.data.datasetId;if(!l){console.error("No datasetId found for current eval "+e);return}let i=await (0,a.t)("/results?datasetId=".concat(l),{cache:"no-store"}),o=await i.json();d(o.data.filter(t=>t.evalId!==e))}catch(e){console.error("Error fetching recent evals:",e)}},h=()=>{o(!1)};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(H.Z,{title:"Combine this eval with another eval run",placement:"left",children:(0,s.jsxs)(W.Z,{onClick:()=>{u(),o(!0)},children:[(0,s.jsx)(O.Z,{children:(0,s.jsx)(K.Z,{fontSize:"small"})}),(0,s.jsx)(A.Z,{children:"Compare with another eval"})]})}),(0,s.jsx)(ec,{open:i,onClose:h,recentEvals:c,onRecentEvalSelected:e=>{n(e),h()},title:"Select an eval to compare",description:"Only evals with the same dataset can be compared."})]})},ev=n(54719),eg=n(52481),ej=n(7175),ef=n(52653);function ey(e){let{open:t,onClose:a}=e,{config:r}=em(),i=l.useRef(null),[o,c]=l.useState(!1),[d,u]=l.useState("");l.useEffect(()=>{t&&(async()=>{let{default:e}=await Promise.resolve().then(n.bind(n,34235));u(e.dump(r))})()},[t,r]);let h=()=>{c(!1),a()};return(0,s.jsxs)(G.Z,{open:t,onClose:h,"aria-labelledby":"config-dialog-title",maxWidth:"md",fullWidth:!0,children:[(0,s.jsx)($.Z,{id:"config-dialog-title",children:(0,s.jsxs)(R.Z,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[(0,s.jsx)(er.Z,{variant:"h6",style:{flexGrow:1},children:"Config"}),(0,s.jsxs)(R.Z,{children:[(0,s.jsx)(H.Z,{title:"Copy to clipboard",children:(0,s.jsx)(ef.Z,{onClick:()=>{i.current&&(i.current.select(),document.execCommand("copy"),c(!0))},children:o?(0,s.jsx)(ev.Z,{}):(0,s.jsx)(ej.Z,{})})}),(0,s.jsx)(H.Z,{title:"Download .yaml",children:(0,s.jsx)(ef.Z,{onClick:()=>{let e=new Blob([d],{type:"text/yaml;charset=utf-8"}),t=URL.createObjectURL(e),n=document.createElement("a");n.href=t,n.download="config.yaml",document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)},children:(0,s.jsx)(eg.Z,{})})})]})]})}),(0,s.jsx)(X.Z,{children:(0,s.jsx)(er.Z,{variant:"body1",component:"div",children:(0,s.jsx)("textarea",{ref:i,readOnly:!0,value:d,style:{width:"100%",minHeight:"400px",fontFamily:"monospace",border:"1px solid #ccc"}})})}),(0,s.jsx)(q.Z,{children:(0,s.jsx)(D.Z,{onClick:h,color:"primary",children:"Close"})})]})}var eb=n(54986),eZ=n(79715),ew=n(34235),eC=function(){let{table:e,config:t,evalId:n}=em(),[a,r]=l.useState(!1),i=(e,t)=>{let n=URL.createObjectURL(e),s=document.createElement("a");s.href=n,s.download=t,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(n)},o=()=>{r(!1)},c=()=>{let e=ew.default.dump(t),n=new Blob([e],{type:"text/yaml;charset=utf-8"});i(n,"promptfooconfig.yaml"),o()},d=()=>{if(!e){alert("No table data");return}let t=e.body.map((t,n)=>({chosen:t.outputs.filter(e=>e.pass).map(e=>e.text),rejected:t.outputs.filter(e=>!e.pass).map(e=>e.text),vars:t.test.vars,providers:e.head.prompts.map(e=>e.provider),prompts:e.head.prompts.map(e=>e.label||e.display||e.raw)})),s=new Blob([JSON.stringify(t,null,2)],{type:"application/json"});i(s,"".concat(n,"-dpo.json")),o()},u=()=>{if(!e){alert("No table data");return}let t=new Blob([JSON.stringify(e,null,2)],{type:"application/json"});i(t,"".concat(n,"-table.json")),o()},h=()=>{if(!e){alert("No table data");return}let t=[],s=[...e.head.vars,...e.head.prompts.map(e=>"[".concat(e.provider,"] ").concat(e.label))];t.push(s),e.body.forEach(e=>{let n=[...e.vars,...e.outputs.map(e=>{let{pass:t,text:n}=e;return(t?"[PASS] ":"[FAIL] ")+n})];t.push(n)});let l=(0,eZ.P)(t),a=new Blob([l],{type:"text/csv;charset=utf-8;"});i(a,"".concat(n,"-table.csv")),o()},p=()=>{if(!e){alert("No table data");return}let t=e.body.filter(e=>e.outputs.some(e=>null!==e.pass)).map(e=>({vars:{...e.test.vars,output:e.outputs[0].text.includes("---")?e.outputs[0].text.split("---\n")[1]:e.outputs[0].text},assert:[{type:"javascript",value:"".concat(e.outputs[0].pass?"":"!","JSON.parse(output).pass")}],metadata:e.test.metadata})),s=ew.default.dump(t),l=new Blob([s],{type:"application/x-yaml"});i(l,"".concat(n,"-human-eval-cases.yaml")),o()},m=l.useCallback(e=>{if("Escape"===e.key)o();else if(a&&!e.altKey&&!e.ctrlKey&&!e.metaKey)switch(e.key){case"1":c();break;case"2":h();break;case"3":u();break;case"4":d();break;case"5":p()}},[a]);return l.useEffect(()=>{let e=e=>{a&&m(e)};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[m,a]),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(W.Z,{onClick:()=>{r(!0)},children:[(0,s.jsx)(O.Z,{children:(0,s.jsx)(eg.Z,{fontSize:"small"})}),(0,s.jsx)(A.Z,{children:"Download"})]}),(0,s.jsxs)(G.Z,{onClose:o,open:a,onKeyDown:m,children:[(0,s.jsx)($.Z,{children:"Download Options"}),(0,s.jsx)(X.Z,{children:(0,s.jsxs)(B.Z,{direction:"column",spacing:2,sx:{width:"100%"},children:[(0,s.jsx)(H.Z,{title:"Download the YAML configuration file",children:(0,s.jsx)(D.Z,{onClick:c,startIcon:(0,s.jsx)(eg.Z,{}),variant:"contained",color:"primary",fullWidth:!0,children:"Download YAML Config"})}),(0,s.jsx)(eb.Z,{}),(0,s.jsx)(er.Z,{variant:"subtitle1",children:"Table Data"}),(0,s.jsx)(H.Z,{title:"Download table data in CSV format",children:(0,s.jsx)(D.Z,{onClick:h,startIcon:(0,s.jsx)(eg.Z,{}),variant:"outlined",fullWidth:!0,children:"Download Table CSV"})}),(0,s.jsx)(H.Z,{title:"Download table data in JSON format",children:(0,s.jsx)(D.Z,{onClick:u,startIcon:(0,s.jsx)(eg.Z,{}),variant:"outlined",fullWidth:!0,children:"Download Table JSON"})}),(0,s.jsx)(eb.Z,{}),(0,s.jsx)(er.Z,{variant:"subtitle1",children:"Advanced Options"}),(0,s.jsx)(H.Z,{title:"Download Direct Preference Optimization JSON",children:(0,s.jsx)(D.Z,{onClick:d,startIcon:(0,s.jsx)(eg.Z,{}),variant:"outlined",color:"secondary",fullWidth:!0,children:"Download DPO JSON"})}),(0,s.jsx)(H.Z,{title:"Download Evaluation Test Cases in YAML format",children:(0,s.jsx)(D.Z,{onClick:p,startIcon:(0,s.jsx)(eg.Z,{}),variant:"outlined",color:"secondary",fullWidth:!0,children:"Download Human Eval Test YAML"})})]})})]})]})},ek=e=>{let{recentEvals:t,onRecentEvalSelected:n}=e,[a,r]=(0,l.useState)(!1),i=()=>{r(!0)};return l.useEffect(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&"k"===e.key&&(e.preventDefault(),i())};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}},[]),(0,s.jsx)(ec,{title:"Open an Eval",open:a,onClose:()=>{r(!1)},recentEvals:t,onRecentEvalSelected:n})},eS=n(69179),eN=n(33533),eE=n(41101),eI=n(36001);let eR=["#fd7f6f","#7eb0d5","#b2e061","#bd7ebe","#ffb55a","#ffee65","#beb9db","#fdcce5","#8bd3c7"];function eD(e){let{table:t}=e,n=(0,l.useRef)(null),a=(0,l.useRef)(null);return(0,l.useEffect)(()=>{if(!n.current)return;a.current&&a.current.destroy();let e=t.body.flatMap(e=>e.outputs.map(e=>e.score)),s=Math.min(...e),l=(Math.ceil(Math.max(...e))-Math.floor(s))/10,r=Array.from({length:11},(e,t)=>Number.parseFloat((Math.floor(s)+t*l).toFixed(2))),i=t.head.prompts.map((e,n)=>{let s=t.body.flatMap(e=>e.outputs[n].score),a=r.map(e=>s.filter(t=>t>=e&&t<e+l).length);return{label:"Column ".concat(n+1),data:a,backgroundColor:eR[n%eR.length]}});a.current=new eI.kL(n.current,{type:"bar",data:{labels:r,datasets:i},options:{animation:!1,plugins:{title:{display:!0,text:"Score Distribution"},legend:{display:!1},tooltip:{callbacks:{title(e){let t=e[0].datasetIndex;return"Column ".concat(t+1)},label(e){let t=e.dataIndex,n=r[t],s=r[t+1];return s?"".concat(n," <= score < ").concat(s):"".concat(n," <= score")}}}}}})},[t]),(0,s.jsx)("canvas",{ref:n,style:{maxHeight:"300px"}})}function eF(e){let{table:t}=e,n=(0,l.useRef)(null),a=(0,l.useRef)(null);return(0,l.useEffect)(()=>{if(!n.current)return;a.current&&a.current.destroy();let e=t.head.prompts.map((e,n)=>{let s=t.body.flatMap(e=>e.outputs[n]),l=s.filter(e=>e.pass).length,a=l/s.length*100;return{label:"Column ".concat(n+1),data:[a],backgroundColor:eR[n%eR.length]}});a.current=new eI.kL(n.current,{type:"bar",data:{labels:["Pass Rate (%)"],datasets:e},options:{animation:!1,plugins:{title:{display:!0,text:"Pass rate"},legend:{display:!0}}}})},[t]),(0,s.jsx)("canvas",{ref:n,style:{maxHeight:"300px"}})}function eP(e){let{table:t}=e,n=(0,l.useRef)(null),a=(0,l.useRef)(null),[r,i]=(0,l.useState)(0),[o,c]=(0,l.useState)(1),[d,u]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{if(!n.current)return;a.current&&a.current.destroy();let e=t.body.flatMap(e=>e.outputs.map(e=>e.score)),s=Math.min(...e),l=Math.max(...e),i=t.body.map(e=>{let t=e.outputs[r].score,n=e.outputs[o].score;return{x:t,y:n,backgroundColor:n>t?"green":n<t?"red":"gray"}});a.current=new eI.kL(n.current,{type:"scatter",data:{datasets:[{data:i,backgroundColor:i.map(e=>e.backgroundColor)},{type:"line",data:[{x:s,y:s},{x:l,y:l}],borderColor:"gray",borderWidth:1,borderDash:[5,5],pointRadius:0}]},options:{animation:!1,plugins:{legend:{display:!1},tooltip:{callbacks:{label(e){let n=t.body[e.dataIndex],s=n.outputs[0].text,l=n.outputs[1].text;return s.length>30&&(s=s.substring(0,30)+"..."),l.length>30&&(l=l.substring(0,30)+"..."),"Output 1: ".concat(s,"\nOutput 2: ").concat(l)}}}},scales:{x:{title:{display:!0,text:"Prompt ".concat(r+1," Score")},ticks:{callback(e,t,n){let s=String(Math.round(100*Number(e)));return t===n.length-1&&(s+="%"),s}}},y:{title:{display:!0,text:"Prompt ".concat(o+1," Score")},ticks:{callback(e,t,n){let s=String(Math.round(100*Number(e)));return t===n.length-1&&(s+="%"),s}}}}}})},[t,r,o]),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(G.Z,{open:d,onClose:()=>u(!1),children:[(0,s.jsx)($.Z,{children:"Compare prompt outputs"}),(0,s.jsxs)(X.Z,{children:[(0,s.jsx)(T.Z,{sx:{m:1,minWidth:120},children:(0,s.jsx)(V.Z,{value:r,onChange:e=>i(Number(e.target.value)),children:t.head.prompts.map((e,t)=>(0,s.jsxs)(W.Z,{value:t,children:["Prompt ",t+1]},t))})}),(0,s.jsx)(T.Z,{sx:{m:1,minWidth:120},children:(0,s.jsx)(V.Z,{value:o,onChange:e=>c(Number(e.target.value)),children:t.head.prompts.map((e,t)=>(0,s.jsxs)(W.Z,{value:t,children:["Prompt ",t+1]},t))})})]})]}),(0,s.jsx)("canvas",{ref:n,style:{maxHeight:"300px",cursor:"pointer"},onClick:()=>u(!0)})]})}function eT(e){let{table:t}=e,n=(0,l.useRef)(null),a=(0,l.useRef)(null);return(0,l.useEffect)(()=>{var e;if(!n.current)return;a.current&&a.current.destroy();let s=Object.keys((null===(e=t.head.prompts[0].metrics)||void 0===e?void 0:e.namedScores)||{}),l=t.head.prompts.map((e,n)=>{let l=s.map(n=>{var s;let l=(null===(s=e.metrics)||void 0===s?void 0:s.namedScores[n])||0,a=Math.max(...t.head.prompts.map(e=>{var t;return(null===(t=e.metrics)||void 0===t?void 0:t.namedScores[n])||0}));return l/a});return{label:"".concat(t.head.prompts[n].provider),data:l,backgroundColor:eR[n%eR.length]}});a.current=new eI.kL(n.current,{type:"bar",data:{labels:s,datasets:l},options:{scales:{x:{grid:{display:!1}},y:{ticks:{callback(e,t,n){let s=String(Math.round(100*Number(e)));return t===n.length-1&&(s+="%"),s}}}},plugins:{tooltip:{callbacks:{title:e=>e[0].dataset.label,label(e){let t=e.parsed.y;return"".concat(s[e.dataIndex],": ").concat((100*t).toFixed(2),"% pass rate")}}}}}})},[t]),(0,s.jsx)("canvas",{ref:n,style:{maxHeight:"300px"}})}eI.kL.register(eI.vn,eI.ST,eI.ho,eI.uw,eI.f$,eI.ZL,eI.jn,eI.od,eI.u,eI.wL);var eM=l.memo(function(e){var t;let{columnVisibility:n}=e,a=(0,eE.Z)();eI.kL.defaults.color="dark"===a.palette.mode?"#aaa":"#666";let[r,i]=(0,l.useState)(!0),{table:o}=em();if(!o||!r||o.head.prompts.length<2)return null;let c=o.body.flatMap(e=>e.outputs.map(e=>e.score)),d=new Set(c);return 1===d.size?null:(0,s.jsx)(eS.SV,{fallback:null,children:(0,s.jsxs)(Q.Z,{sx:{position:"relative",padding:3,mt:2},children:[(0,s.jsx)(ef.Z,{style:{position:"absolute",right:0,top:0},onClick:()=>i(!1),children:(0,s.jsx)(eN.Z,{})}),(0,s.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[(0,s.jsx)("div",{style:{width:"33%"},children:(0,s.jsx)(eF,{table:o})}),(0,s.jsx)("div",{style:{width:"33%"},children:d.size<=3&&Object.keys((null===(t=o.head.prompts[0].metrics)||void 0===t?void 0:t.namedScores)||{}).length>1?(0,s.jsx)(eT,{table:o}):(0,s.jsx)(eD,{table:o})}),(0,s.jsx)("div",{style:{width:"33%"},children:(0,s.jsx)(eP,{table:o})})]})]})})}),eL=n(7660),eO=n(3216),eA=n(5971);n(55974);var eU=e=>{let{lookup:t,metricTotals:n,onSearchTextChange:a}=e,[r,i]=l.useState(!1);if(!t||!Object.keys(t).length)return null;let o=Object.entries(t),c=r?o:o.slice(0,10);return(0,s.jsxs)("div",{className:"custom-metric-container",children:[c.map(e=>{let[t,l]=e;return t&&void 0!==l?(0,s.jsxs)("span",{onClick:()=>a&&a("metric=".concat(t,":")),className:a?"clickable":"",children:[t,":"," ",n&&n[t]?(0,s.jsxs)(s.Fragment,{children:[(l/n[t]*100).toFixed(2),"% (",l.toFixed(2),"/",n[t].toFixed(2),")"]}):l.toFixed(2)]},t):null}),o.length>10&&(0,s.jsx)("span",{className:"clickable",onClick:()=>i(!r),children:r?"Show less":"Show more..."})]})},eW=n(39329),ez=n(64748);function eV(e,t){return e.length<=t?e:e.slice(0,t)+"..."}function eB(e){let{gradingResults:t}=e,[n,a]=(0,l.useState)({});if(!t)return null;let r=e=>{a(t=>({...t,[e]:!t[e]}))};return(0,s.jsxs)(R.Z,{mt:2,children:[(0,s.jsx)(er.Z,{variant:"subtitle1",children:"Assertions"}),(0,s.jsx)(es.Z,{children:(0,s.jsxs)(ee.Z,{children:[(0,s.jsx)(el.Z,{children:(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)(en.Z,{style:{fontWeight:"bold"},children:"Pass"}),(0,s.jsx)(en.Z,{style:{fontWeight:"bold"},children:"Score"}),(0,s.jsx)(en.Z,{style:{fontWeight:"bold"},children:"Type"}),(0,s.jsx)(en.Z,{style:{fontWeight:"bold"},children:"Value"}),(0,s.jsx)(en.Z,{style:{fontWeight:"bold"},children:"Reason"})]})}),(0,s.jsx)(et.Z,{children:t.map((e,t)=>{var l,a,i;if(!e)return null;let o=(null===(l=e.assertion)||void 0===l?void 0:l.value)?"object"==typeof e.assertion.value?JSON.stringify(e.assertion.value,null,2):String(e.assertion.value):"-",c=eV(o,300),d=n[t]||!1;return(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)(en.Z,{children:e.pass?"✅":"❌"}),(0,s.jsx)(en.Z,{children:null===(a=e.score)||void 0===a?void 0:a.toFixed(2)}),(0,s.jsx)(en.Z,{children:(null===(i=e.assertion)||void 0===i?void 0:i.type)||""}),(0,s.jsx)(en.Z,{style:{whiteSpace:"pre-wrap",cursor:"pointer"},onClick:()=>r(t),children:d?o:c}),(0,s.jsx)(en.Z,{style:{whiteSpace:"pre-wrap"},children:e.reason})]},t)})})]})})]})}function eJ(e){let{open:t,onClose:n,prompt:a,provider:r,output:i,gradingResults:o,metadata:c}=e,[d,u]=(0,l.useState)(!1),[h,p]=(0,l.useState)({});(0,l.useEffect)(()=>{u(!1)},[a]);let m=async e=>{await navigator.clipboard.writeText(e),u(!0)},x=e=>{p(t=>({...t,[e]:!t[e]}))};return(0,s.jsxs)(G.Z,{open:t,onClose:n,fullWidth:!0,maxWidth:"lg",children:[(0,s.jsxs)($.Z,{children:["Details",r&&": ".concat(r)]}),(0,s.jsxs)(X.Z,{children:[(0,s.jsxs)(R.Z,{mb:2,children:[(0,s.jsx)(er.Z,{variant:"subtitle1",style:{marginBottom:"1rem"},children:"Prompt"}),(0,s.jsx)(ez.Z,{readOnly:!0,value:a,style:{width:"100%",padding:"0.75rem"},maxRows:20}),(0,s.jsx)(ef.Z,{onClick:()=>m(a),style:{position:"absolute",right:"10px",top:"10px"},children:d?(0,s.jsx)(ev.Z,{}):(0,s.jsx)(eW.Z,{})})]}),(null==c?void 0:c.redteamFinalPrompt)&&(0,s.jsxs)(R.Z,{my:2,children:[(0,s.jsx)(er.Z,{variant:"subtitle1",style:{marginBottom:"1rem",marginTop:"1rem"},children:"Modified User Input (Red Team)"}),(0,s.jsx)(ez.Z,{readOnly:!0,maxRows:20,value:c.redteamFinalPrompt,style:{width:"100%",padding:"0.75rem"}})]}),i&&(0,s.jsxs)(R.Z,{my:2,children:[(0,s.jsx)(er.Z,{variant:"subtitle1",style:{marginBottom:"1rem",marginTop:"1rem"},children:"Output"}),(0,s.jsx)(ez.Z,{readOnly:!0,maxRows:20,value:i,style:{width:"100%",padding:"0.75rem"}})]}),(0,s.jsx)(eB,{gradingResults:o}),c&&Object.keys(c).length>0&&(0,s.jsxs)(R.Z,{my:2,children:[(0,s.jsx)(er.Z,{variant:"subtitle1",style:{marginBottom:"1rem",marginTop:"1rem"},children:"Metadata"}),(0,s.jsx)(es.Z,{children:(0,s.jsxs)(ee.Z,{size:"small",children:[(0,s.jsx)(el.Z,{children:(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)(en.Z,{children:(0,s.jsx)("strong",{children:"Key"})}),(0,s.jsx)(en.Z,{children:(0,s.jsx)("strong",{children:"Value"})})]})}),(0,s.jsx)(et.Z,{children:Object.entries(c).map(e=>{let[t,n]=e,l="string"==typeof n?n:JSON.stringify(n),a=eV(l,300),r=h[t]||!1;return(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)(en.Z,{children:t}),(0,s.jsx)(en.Z,{style:{whiteSpace:"pre-wrap",cursor:"pointer"},onClick:()=>x(t),children:r?l:a})]},t)})})]})})]})]}),(0,s.jsx)(q.Z,{children:(0,s.jsx)(D.Z,{onClick:n,children:"Close"})})]})}var eH=n(89396),e_=n(64173),eY=function(){let e=(0,eE.Z)(),[t,n]=l.useState(!1),a=()=>{n(!1)};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{style:{textAlign:"center",marginTop:20,marginBottom:40},children:(0,s.jsx)(D.Z,{variant:"text",color:"primary",startIcon:(0,s.jsx)(eH.Z,{}),onClick:()=>{n(!0)},children:"Generate test cases"})}),(0,s.jsxs)(G.Z,{open:t,onClose:a,children:[(0,s.jsx)($.Z,{children:"Run on Command Line"}),(0,s.jsx)(X.Z,{children:(0,s.jsxs)(e_.Z,{children:[(0,s.jsx)("p",{children:"This feature is in beta. UI coming soon."}),(0,s.jsxs)("p",{children:["Run"," ",(0,s.jsx)(R.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,s.jsx)(q.Z,{children:(0,s.jsx)(D.Z,{onClick:a,color:"primary",children:"Close"})})]})]})};function eK(e){return"string"==typeof e||"number"==typeof e?e.toString().length:Array.isArray(e)?e.reduce((e,t)=>e+eK(t),0):l.isValidElement(e)&&e.props.children?l.Children.toArray(e.props.children).reduce((e,t)=>e+eK(t),0):0}let eG=l.memo(function(e){let t,{text:n,maxLength:a}=e,[r,i]=l.useState(!0),o=()=>{i(!r)},c=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if("string"==typeof e||"number"==typeof e){let n=e.toString();return n.slice(0,a-t)}if(Array.isArray(e)){let n=[],s=t;for(let t of e){let e=eK(t);if(s+e>a){n.push(c(t,s));break}n.push(t),s+=e}return n}if(l.isValidElement(e)&&e.props.children){let n=eK(e.props.children);if(n>a-t)return l.cloneElement(e,{...e.props,children:c(e.props.children,t)})}return e};t=l.isValidElement(n)||"string"==typeof n?n:JSON.stringify(n);let d=r?c(t):t,u=eK(t)>a;return(0,s.jsxs)("div",{style:{cursor:u?"pointer":"normal"},onMouseDown:e=>{let t=e.clientX,n=e.clientY,s=e=>{let l=e.clientX,a=e.clientY;5>Math.abs(l-t)&&5>Math.abs(a-n)&&o(),document.removeEventListener("mouseup",s)};document.addEventListener("mouseup",s)},children:[d,r&&eK(t)>a&&(0,s.jsx)("span",{children:"..."})]})});var eq=n(45391),eX=n(40182),e$=n(38640),eQ=n.n(e$),e0=n(33352),e1=n(15014),e2=n(65101);n(16658);var e3=e=>{let{failReasons:t}=e,[n,a]=(0,l.useState)(0);return t.length<1?null:(0,s.jsxs)("div",{className:"fail-reason",children:[t.length>1&&(0,s.jsxs)("span",{className:"fail-reason-carousel-controls",children:[(0,s.jsx)(ef.Z,{onClick:()=>{a(e=>e>0?e-1:t.length-1)},children:(0,s.jsx)(e1.Z,{sx:{fontSize:12}})}),(0,s.jsxs)("span",{children:[n+1,"/",t.length]}),(0,s.jsx)(ef.Z,{onClick:()=>{a(e=>e<t.length-1?e+1:0)},children:(0,s.jsx)(e2.Z,{sx:{fontSize:12}})})]}),t[n].trim().split("\n").map((e,t)=>(0,s.jsxs)(l.Fragment,{children:[e,(0,s.jsx)("br",{})]},t))]})},e5=e=>{let{open:t,contextText:n,commentText:l,onClose:a,onSave:r,onChange:i}=e,o="dark"===(0,eE.Z)().palette.mode;return(0,s.jsxs)(G.Z,{open:t,onClose:a,fullWidth:!0,maxWidth:"sm",children:[(0,s.jsx)($.Z,{children:"Edit Comment"}),(0,s.jsxs)(X.Z,{children:[(0,s.jsx)(R.Z,{sx:{backgroundColor:o?"#1e1e1e":"#f0f0f0",padding:2,marginBottom:2},children:n}),(0,s.jsx)(J.Z,{autoFocus:!0,margin:"dense",type:"text",fullWidth:!0,multiline:!0,rows:4,value:l,onChange:e=>i(e.target.value)})]}),(0,s.jsxs)(q.Z,{children:[(0,s.jsx)(D.Z,{onClick:r,color:"primary",variant:"contained",children:"Save"}),(0,s.jsx)(D.Z,{onClick:a,color:"primary",children:"Cancel"})]})]})};let e4=()=>{let e=(0,l.useContext)(r);if(void 0===e)throw Error("useShiftKey must be used within a ShiftKeyProvider");return e};var e8=n(68192);let e7=l.memo(function(e){var t,n,a,r,i,o,c,d,u,h,p,m,x;let v,g,j,f,y,b,{output:Z,maxTextLength:w,rowIndex:C,promptIndex:k,onRating:S,firstOutput:N,showDiffs:E,searchText:I,showStats:R}=e,{renderMarkdown:D,prettifyJson:F,showPrompts:P,showPassFail:T}=em(),[M,L]=l.useState(!1),[O,A]=l.useState(!1),[U,W]=l.useState(null),z=e=>{W(e||null),A(!O)},[V,B]=l.useState(!1),[J,_]=l.useState((null===(t=Z.gradingResult)||void 0===t?void 0:t.comment)||""),Y=()=>{B(!0)},K="string"==typeof Z.text?Z.text:JSON.stringify(Z.text),G=[];if(!Z.pass&&K.includes("---")&&(G=((null===(h=Z.gradingResult)||void 0===h?void 0:h.componentResults)||[]).filter(e=>!!e&&!e.pass).map(e=>e.reason),K=K.split("---").slice(1).join("---")),E&&N){let e,t="string"==typeof N.text?N.text:JSON.stringify(N.text);t.includes("---")&&(t=t.split("---").slice(1).join("---"));try{JSON.parse(t),JSON.parse(K),e=(0,e8.CT)(t,K)}catch(n){e=t.includes(". ")&&K.includes(". ")?(0,e8.SY)(t,K):(0,e8.NV)(t,K)}v=(0,s.jsx)(s.Fragment,{children:e.map((e,t)=>e.added?(0,s.jsx)("ins",{children:e.value},t):e.removed?(0,s.jsx)("del",{children:e.value},t):(0,s.jsx)("span",{children:e.value},t))})}if(I)try{let e;let t=RegExp(I,"gi"),n=[];for(;null!==(e=t.exec(K));)n.push({start:e.index,end:t.lastIndex});v=(0,s.jsx)(s.Fragment,{children:n.length>0?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{children:K.substring(0,n[0].start)},"text-before"),n.map((e,t)=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"search-highlight",children:K.substring(e.start,e.end)},"match-"+t),(0,s.jsx)("span",{children:K.substring(e.end,n[t+1]?n[t+1].start:K.length)},"text-after-"+t)]}))]}):(0,s.jsx)("span",{children:K},"no-match")})}catch(e){console.error("Invalid regular expression:",e.message)}else if(D&&!E)v=(0,s.jsx)(eA.U,{remarkPlugins:[e0.Z],components:{img:e=>{let{src:t,alt:n}=e;return(0,s.jsx)("img",{loading:"lazy",src:t,alt:n,onClick:()=>z(t),style:{cursor:"pointer"}})}},children:K});else if(F)try{v=(0,s.jsx)("pre",{children:JSON.stringify(JSON.parse(K),null,2)})}catch(e){}let q=l.useCallback(e=>{var t;S(e,void 0,null===(t=Z.gradingResult)||void 0===t?void 0:t.comment)},[S,null===(n=Z.gradingResult)||void 0===n?void 0:n.comment]),X=l.useCallback(()=>{let e=prompt("Set test score (0.0 - 1.0):",String(Z.score));if(null!==e){let n=Number.parseFloat(e);if(!Number.isNaN(n)&&n>=0&&n<=1){var t;S(void 0,n,null===(t=Z.gradingResult)||void 0===t?void 0:t.comment)}else alert("Invalid score. Please enter a value between 0.0 and 1.0.")}},[S,Z.score,null===(a=Z.gradingResult)||void 0===a?void 0:a.comment]),[$,Q]=l.useState(!1),ee=l.useCallback(()=>{navigator.clipboard.writeText(Z.text),Q(!0)},[Z.text]);if(Z.latencyMs&&(j=(0,s.jsxs)("span",{children:[Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(Z.latencyMs)," ms"]})),null===(r=Z.tokenUsage)||void 0===r?void 0:r.completion){let e=Z.tokenUsage.completion/(Z.latencyMs/1e3);f=(0,s.jsx)("span",{children:Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(e)})}if(Z.cost&&(y=(0,s.jsxs)("span",{children:["$",Z.cost.toPrecision(2)]})),null===(i=Z.tokenUsage)||void 0===i?void 0:i.cached)g=(0,s.jsxs)("span",{children:[Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(Z.tokenUsage.cached)," ","(cached)"]});else if(null===(o=Z.tokenUsage)||void 0===o?void 0:o.total){let e=Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(null!==(p=Z.tokenUsage.prompt)&&void 0!==p?p:0),t=Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(null!==(m=Z.tokenUsage.completion)&&void 0!==m?m:0),n=Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(Z.tokenUsage.total);g=(0,s.jsx)(H.Z,{title:"".concat(e," prompt tokens + ").concat(t," completion tokens = ").concat(n," total"),children:(0,s.jsxs)("span",{children:[n,("0"!==e||"0"!==t)&&" (".concat(e,"+").concat(t,")")]})})}let et=(null===(c=Z.gradingResult)||void 0===c?void 0:c.comment)&&"!highlight"!==Z.gradingResult.comment?(0,s.jsx)("div",{className:"comment",onClick:Y,children:Z.gradingResult.comment}):null,en=R?(0,s.jsxs)("div",{className:"cell-detail",children:[g&&(0,s.jsxs)("div",{className:"stat-item",children:[(0,s.jsx)("strong",{children:"Tokens:"})," ",g]}),j&&(0,s.jsxs)("div",{className:"stat-item",children:[(0,s.jsx)("strong",{children:"Latency:"})," ",j]}),f&&(0,s.jsxs)("div",{className:"stat-item",children:[(0,s.jsx)("strong",{children:"Tokens/Sec:"})," ",f]}),y&&(0,s.jsxs)("div",{className:"stat-item",children:[(0,s.jsx)("strong",{children:"Cost:"})," ",y]})]}):null,es=e4(),el=(0,s.jsxs)("div",{className:"cell-actions",children:[es&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"action",onClick:ee,onMouseDown:e=>e.preventDefault(),children:(0,s.jsx)(H.Z,{title:"Copy output to clipboard",children:(0,s.jsx)("span",{children:$?"✅":"\uD83D\uDCCB"})})}),(0,s.jsx)("span",{className:"action",onClick:()=>{let e;J.startsWith("!highlight")?S(void 0,void 0,e=J.slice(10).trim()):S(void 0,void 0,e=("!highlight "+J).trim()),_(e)},onMouseDown:e=>e.preventDefault(),children:(0,s.jsx)(H.Z,{title:"Toggle test highlight",children:(0,s.jsx)("span",{children:"\uD83C\uDF1F"})})})]}),Z.prompt&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"action",onClick:()=>{L(!0)},children:(0,s.jsx)(H.Z,{title:"View output and test details",children:(0,s.jsx)("span",{children:"\uD83D\uDD0E"})})}),(0,s.jsx)(eJ,{open:M,onClose:()=>{L(!1)},prompt:Z.prompt,provider:Z.provider,gradingResults:null===(d=Z.gradingResult)||void 0===d?void 0:d.componentResults,output:K,metadata:Z.metadata})]}),(0,s.jsx)("span",{className:"action",onClick:()=>q(!0),children:(0,s.jsx)(H.Z,{title:"Mark test passed (score 1.0)",children:(0,s.jsx)("span",{children:"\uD83D\uDC4D"})})}),(0,s.jsx)("span",{className:"action",onClick:()=>q(!1),children:(0,s.jsx)(H.Z,{title:"Mark test failed (score 0.0)",children:(0,s.jsx)("span",{children:"\uD83D\uDC4E"})})}),(0,s.jsx)("span",{className:"action",onClick:X,children:(0,s.jsx)(H.Z,{title:"Set test score",children:(0,s.jsx)("span",{children:"\uD83D\uDD22"})})}),(0,s.jsx)("span",{className:"action",onClick:Y,children:(0,s.jsx)(H.Z,{title:"Edit comment",children:(0,s.jsx)("span",{children:"✏️"})})})]}),ea={};(null===(u=Z.gradingResult)||void 0===u?void 0:u.comment)==="!highlight"&&(ea.backgroundColor="#ffffeb");let er=0,ei=0,eo=Z.gradingResult;if(eo?eo.componentResults?eo.componentResults.forEach(e=>{(null==e?void 0:e.pass)?er++:ei++}):(er=eo.pass?1:0,ei=eo.pass?0:1):Z.pass?er=1:Z.pass||(ei=1),1===ei&&1===er)b=(0,s.jsxs)(s.Fragment,{children:["".concat(ei," FAIL")," ","".concat(er," PASS")]});else{let e="";ei>1||er>1&&ei>0?e="".concat(ei," FAIL"):1===ei&&(e="FAIL");let t="";er>1||ei>1&&er>0?t="".concat(er," PASS"):1===er&&0===ei&&(t="PASS");let n=e&&t?" ":"";b=(0,s.jsxs)(s.Fragment,{children:[e,n,t]})}let ec=null===(x=Z.score)||0===x||1===x?"":"(".concat(x.toFixed(2),")");return(0,s.jsxs)("div",{className:"cell",style:ea,children:[T&&(0,s.jsx)(s.Fragment,{children:Z.pass?(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)("div",{className:"status pass",children:[(0,s.jsxs)("div",{className:"pill",children:[b,ec&&(0,s.jsxs)("span",{className:"score",children:[" ",ec]})]}),(0,s.jsx)(eU,{lookup:Z.namedScores})]})}):(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)("div",{className:"status fail",children:[(0,s.jsxs)("div",{className:"pill",children:[b,ec&&(0,s.jsxs)("span",{className:"score",children:[" ",ec]})]}),(0,s.jsx)(eU,{lookup:Z.namedScores}),(0,s.jsx)("span",{className:"fail-reason",children:(0,s.jsx)(e3,{failReasons:G})})]})})}),P&&N.prompt&&(0,s.jsxs)("div",{className:"prompt",children:[(0,s.jsx)("span",{className:"pill",children:"Prompt"}),Z.prompt]}),(0,s.jsx)(eG,{text:v||K,maxLength:w}),et,en,el,O&&U&&(0,s.jsx)("div",{className:"lightbox",onClick:()=>z(),children:(0,s.jsx)("img",{src:U,alt:"Lightbox"})}),(0,s.jsx)(e5,{open:V,contextText:Z.text,commentText:J,onClose:()=>{B(!1)},onSave:()=>{S(void 0,void 0,J),B(!1)},onChange:_})]})});function e6(e){let{text:t,maxLength:n,expandedText:a,resourceId:r,className:i}=e,[o,c]=l.useState(!1);return(0,s.jsxs)("div",{className:"".concat(i||""),children:[(0,s.jsx)(eG,{text:t,maxLength:n}),a&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(H.Z,{title:"View prompt",children:(0,s.jsx)("span",{className:"action",onClick:()=>{c(!0)},children:"\uD83D\uDD0E"})}),(0,s.jsx)(eJ,{open:o,onClose:()=>{c(!1)},prompt:a}),r&&(0,s.jsx)(H.Z,{title:"View other evals and datasets for this prompt",children:(0,s.jsx)("span",{className:"action",children:(0,s.jsx)(eQ(),{href:"/prompts/?id=".concat(r),target:"_blank",children:(0,s.jsx)(eq.Z,{fontSize:"small"})})})})]})]})}n(93207);var e9=l.memo(function(e){let{maxTextLength:t,columnVisibility:n,wordBreak:r,filterMode:i,failureFilter:o,searchText:c,showStats:d,onFailureFilterToggle:h,onSearchTextChange:p}=e,{evalId:m,table:x,setTable:v,config:g,inComparisonMode:j}=em(),{showToast:y}=u();(0,f.Z)(x,"Table should be defined");let{head:b,body:Z}=x,w=l.useCallback(async(e,t,n,s,l)=>{var r,i;let o=[...Z],c={...o[e]},d=[...c.outputs],u=null!=n?n:d[t].pass,h=void 0===s?n?1:0:s||0;d[t].pass=u,d[t].score=h;let p=(null===(r=d[t].gradingResult)||void 0===r?void 0:r.componentResults)||[];if(void 0!==n){let e=p.findIndex(e=>{var t;return(null===(t=e.assertion)||void 0===t?void 0:t.type)==="human"}),t={pass:u,score:h,reason:"Manual result (overrides all other grading results)",comment:l,assertion:{type:"human"}};-1===e?p.push(t):p[e]=t}let x={...d[t].gradingResult||{},pass:u,score:h,reason:"Manual result (overrides all other grading results)",comment:l,assertion:(null===(i=d[t].gradingResult)||void 0===i?void 0:i.assertion)||null,componentResults:p};d[t].gradingResult=x,c.outputs=d,o[e]=c;let g={head:b,body:o};if(v(g),j)y("Ratings are not saved in comparison mode","warning");else try{let e=await (0,a.t)("/eval/".concat(m),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({table:g})});if(!e.ok)throw Error("Network response was not ok")}catch(e){console.error("Failed to update table:",e)}},[Z,b,v,m,j,y]),C=Object.keys(n).length>0,k=l.useMemo(()=>{try{return RegExp(c,"i")}catch(e){return console.error("Invalid regular expression:",e.message),null}},[c]),S=l.useMemo(()=>{try{return Z.map((e,t)=>({...e,outputs:e.outputs.map((e,n)=>({...e,originalRowIndex:t,originalPromptIndex:n}))})).filter(e=>{let t=!0;return"failures"===i?t=e.outputs.some((e,t)=>{let s="Prompt ".concat(t+1);return o[s]&&!e.pass&&(!C||n[s])}):"different"===i?t=!e.outputs.every(t=>t.text===e.outputs[0].text):"highlights"===i&&(console.log(e.outputs[0].text),t=e.outputs.some(e=>{var t,n;return null===(n=e.gradingResult)||void 0===n?void 0:null===(t=n.comment)||void 0===t?void 0:t.startsWith("!highlight")})),!!t&&(!c||!k||e.outputs.some(t=>{var n,s;let l=e.vars.map(e=>"var=".concat(e)).join(" "),a="".concat(t.text," ").concat(Object.keys(t.namedScores).map(e=>"metric=".concat(e,":").concat(t.namedScores[e])).join(" ")," ").concat((null===(n=t.gradingResult)||void 0===n?void 0:n.reason)||""," ").concat((null===(s=t.gradingResult)||void 0===s?void 0:s.comment)||""),r="".concat(l," ").concat(a);return k.test(r)}))})}catch(e){return console.error("Invalid regular expression:",e.message),Z}},[Z,o,i,c,n,C,k]),[N,E]=l.useState({pageIndex:0,pageSize:50});l.useEffect(()=>{E(e=>({...e,pageIndex:0}))},[o,i,c]);let I=l.useMemo(()=>b.prompts.map((e,t)=>Z.reduce((e,n)=>e+(n.outputs[t].pass?1:0),0)),[b.prompts,Z]),P=l.useMemo(()=>b.prompts.map((e,t)=>Z.reduce((e,n)=>{var s,l;return e+((null===(l=n.outputs[t].gradingResult)||void 0===l?void 0:null===(s=l.componentResults)||void 0===s?void 0:s.length)||0)},0)),[b.prompts,Z]),T=l.useMemo(()=>b.prompts.map((e,t)=>Z.reduce((e,n)=>{var s;let l=null===(s=n.outputs[t].gradingResult)||void 0===s?void 0:s.componentResults;return e+(l?l.filter(e=>null==e?void 0:e.pass).length:0)},0)),[b.prompts,Z]),M=l.useMemo(()=>I.reduce((e,t,n,s)=>t>s[e]?n:e,0),[I]),L=I[M],O=l.useMemo(()=>(0,eL.Cl)(),[]),{renderMarkdown:A}=em(),U=l.useMemo(()=>b.vars.length>0?[O.group({id:"vars",header:()=>(0,s.jsx)("span",{className:"font-bold",children:"Variables"}),columns:b.vars.map((e,n)=>O.accessor(e=>e.vars[n],{id:"Variable ".concat(n+1),header:()=>(0,s.jsx)(e6,{text:e,maxLength:t,className:"font-bold"}),cell:e=>{let n=e.getValue();return(0,s.jsx)("div",{className:"cell",children:A?(0,s.jsx)(eA.U,{remarkPlugins:[e0.Z],children:n}):(0,s.jsx)(eG,{text:n,maxLength:t})})},size:50}))})]:[],[O,b.vars,t,A]),z=l.useCallback((e,t)=>S[e].outputs[t],[S]),B=l.useCallback(e=>S[e].outputs[0],[S]),_=l.useMemo(()=>{let e={};return null==x||x.body.forEach(t=>{var n;null===(n=t.test.assert)||void 0===n||n.forEach(t=>{t.metric&&(e[t.metric]=(e[t.metric]||0)+1),"assert"in t&&Array.isArray(t.assert)&&t.assert.forEach(t=>{"metric"in t&&t.metric&&(e[t.metric]=(e[t.metric]||0)+1)})})}),e},[x]),Y=l.useMemo(()=>[O.group({id:"prompts",header:()=>(0,s.jsx)("span",{className:"font-bold",children:"Outputs"}),columns:b.prompts.map((e,n)=>O.accessor(e=>(function(e){if("string"==typeof e){let t=e.startsWith("[PASS]"),n=e;return e.startsWith("[PASS]")?n=n.slice(6):e.startsWith("[FAIL]")&&(n=n.slice(6)),{text:n,pass:t,score:t?1:0}}return e})(e.outputs[n]),{id:"Prompt ".concat(n+1),header:()=>{var l,a,r,c,u,m,x,v;let j=I[n]&&Z.length?(I[n]/Z.length*100).toFixed(2):"0.00",f=I[n]===L&&0!==L,y="Prompt ".concat(n+1),b=o[y]||!1,w=d?(0,s.jsxs)("div",{className:"prompt-detail",children:[P[n]?(0,s.jsxs)("div",{children:[(0,s.jsx)("strong",{children:"Asserts:"})," ",T[n],"/",P[n]," passed"]}):null,(null===(l=e.metrics)||void 0===l?void 0:l.totalLatencyMs)?(0,s.jsxs)("div",{children:[(0,s.jsx)("strong",{children:"Avg Latency:"})," ",Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(e.metrics.totalLatencyMs/Z.length)," ","ms"]}):null,(null===(r=e.metrics)||void 0===r?void 0:null===(a=r.tokenUsage)||void 0===a?void 0:a.total)?(0,s.jsxs)("div",{children:[(0,s.jsx)("strong",{children:"Avg Tokens:"})," ",Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(e.metrics.tokenUsage.total/Z.length)]}):null,(null===(c=e.metrics)||void 0===c?void 0:c.totalLatencyMs)&&(null===(m=e.metrics)||void 0===m?void 0:null===(u=m.tokenUsage)||void 0===u?void 0:u.completion)?(0,s.jsxs)("div",{children:[(0,s.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,s.jsxs)("div",{children:[(0,s.jsx)("strong",{children:"Cost:"})," $",e.metrics.cost.toPrecision(2)]}):null]}):null,C=Array.isArray(null==g?void 0:g.providers)?g.providers[n]:void 0,k=e.provider?e.provider.split(":"):[],S=(0,s.jsx)(H.Z,{title:C?(0,s.jsx)("pre",{children:ew.default.dump(C)}):"",children:k.length>1?(0,s.jsxs)(s.Fragment,{children:[k[0],":",(0,s.jsx)("strong",{children:k.slice(1).join(":")})]}):(0,s.jsx)("strong",{children:e.provider})});return(0,s.jsxs)("div",{className:"output-header",children:[(0,s.jsxs)("div",{className:"pills",children:[e.provider?(0,s.jsx)("div",{className:"provider",children:S}):null,(0,s.jsx)("div",{className:"summary",children:(0,s.jsxs)("div",{className:"highlight ".concat(f?"success":""),children:[(0,s.jsxs)("strong",{children:[j,"% passing"]})," (",I[n],"/",Z.length," cases)"]})}),(null===(v=e.metrics)||void 0===v?void 0:v.namedScores)&&Object.keys(e.metrics.namedScores).length>0?(0,s.jsx)(eU,{lookup:e.metrics.namedScores,metricTotals:_,onSearchTextChange:p}):null]}),(0,s.jsx)(e6,{className:"prompt-container",text:e.label||e.display||e.raw,expandedText:e.raw,maxLength:t,resourceId:e.id}),w,"failures"===i&&(0,s.jsx)(eX.Z,{sx:{"& .MuiFormControlLabel-label":{fontSize:"0.75rem"}},control:(0,s.jsx)(F.Z,{checked:b,onChange:e=>h(y,e.target.checked)}),label:"Show failures"})]})},cell:e=>{var l,a;let r=z(e.row.index,n);return(0,s.jsx)(e7,{output:r,maxTextLength:t,rowIndex:e.row.index,promptIndex:n,onRating:w.bind(null,null!==(l=r.originalRowIndex)&&void 0!==l?l:e.row.index,null!==(a=r.originalPromptIndex)&&void 0!==a?a:n),firstOutput:B(e.row.index),showDiffs:"different"===i,searchText:c,showStats:d})}}))})],[Z.length,null==g?void 0:g.providers,O,o,i,B,z,w,b.prompts,L,t,_,P,T,I,h,p,c,d]),K=l.useMemo(()=>{let e=Z.some(e=>e.description);return e?{accessorFn:e=>e.description||"",id:"description",header:()=>(0,s.jsx)("span",{className:"font-bold",children:"Description"}),cell:e=>(0,s.jsx)("div",{className:"cell",children:(0,s.jsx)(eG,{text:String(e.getValue()),maxLength:t})}),size:50}:null},[Z,t]),G=l.useMemo(()=>{let e=[];return K&&e.push(K),e.push(...U,...Y),e},[K,U,Y]),q=(0,eO.b7)({data:S,columns:G,columnResizeMode:"onChange",getCoreRowModel:(0,eL.sC)(),getPaginationRowModel:(0,eL.G_)(),state:{columnVisibility:n,pagination:N}});return(0,s.jsxs)("div",{children:[(0,s.jsxs)("table",{className:"results-table firefox-fix ".concat(t<=25?"compact":""),style:{wordBreak:r},children:[(0,s.jsx)("thead",{children:q.getHeaderGroups().map(e=>(0,s.jsx)("tr",{className:"header",children:e.headers.map(e=>(0,s.jsxs)("th",{colSpan:e.colSpan,style:{width:e.getSize()},children:[e.isPlaceholder?null:(0,eO.ie)(e.column.columnDef.header,e.getContext()),(0,s.jsx)("div",{onMouseDown:e.getResizeHandler(),onTouchStart:e.getResizeHandler(),className:"resizer ".concat(e.column.getIsResizing()?"isResizing":"")})]},e.id))},e.id))}),(0,s.jsx)("tbody",{children:q.getRowModel().rows.map((e,t)=>{let n=!1;return(0,s.jsx)("tr",{children:e.getVisibleCells().map(e=>{let l=e.column.id.startsWith("Variable")||"description"===e.column.id,a=!l&&!n;return a&&(n=!0),(0,s.jsx)("td",{style:{width:e.column.getSize()},className:"".concat(l?"variable":""," ").concat(0!==t||l?"":"first-prompt-row"," ").concat(a?"first-prompt-col":""),children:(0,eO.ie)(e.column.columnDef.cell,e.getContext())},e.id)})},e.id)})})]}),q.getPageCount()>1&&(0,s.jsxs)(R.Z,{className:"pagination",mx:1,sx:{display:"flex",alignItems:"center",gap:2},children:[(0,s.jsx)(D.Z,{onClick:()=>{E(e=>({...e,pageIndex:Math.max(e.pageIndex-1,0)})),window.scrollTo(0,0)},disabled:0===q.getState().pagination.pageIndex,variant:"contained",children:"Previous"}),(0,s.jsxs)(er.Z,{component:"span",sx:{display:"flex",alignItems:"center",gap:1},children:["Page",(0,s.jsx)(J.Z,{size:"small",type:"number",value:q.getState().pagination.pageIndex+1,onChange:e=>{let t=e.target.value?Number(e.target.value)-1:0;E(e=>({...e,pageIndex:Math.min(Math.max(t,0),q.getPageCount()-1)}))},InputProps:{style:{width:"60px",textAlign:"center"}},variant:"outlined"}),(0,s.jsxs)("span",{children:["of ",q.getPageCount()]})]}),(0,s.jsx)(D.Z,{onClick:()=>{E(e=>({...e,pageIndex:Math.min(e.pageIndex+1,q.getPageCount()-1)})),window.scrollTo(0,0)},disabled:q.getState().pagination.pageIndex+1>=q.getPageCount(),variant:"contained",children:"Next"}),(0,s.jsxs)(er.Z,{component:"span",sx:{display:"flex",alignItems:"center",gap:1},children:[(0,s.jsxs)(V.Z,{value:N.pageSize,onChange:e=>{E({pageIndex:0,pageSize:Number(e.target.value)}),window.scrollTo(0,0)},displayEmpty:!0,inputProps:{"aria-label":"Results per page"},size:"small",sx:{m:1,minWidth:80},children:[(0,s.jsx)(W.Z,{value:10,children:"10"}),(0,s.jsx)(W.Z,{value:50,children:"50"}),(0,s.jsx)(W.Z,{value:100,children:"100"}),(0,s.jsx)(W.Z,{value:500,children:"500"}),(0,s.jsx)(W.Z,{value:1e3,children:"1000"})]}),(0,s.jsx)("span",{children:"results per page"})]})]}),(0,s.jsx)(eY,{})]})}),te=n(4451),tt=e=>{let{open:t,onClose:n}=e,{maxTextLength:l,setMaxTextLength:a,wordBreak:r,setWordBreak:i,showInferenceDetails:o,setShowInferenceDetails:c,renderMarkdown:d,setRenderMarkdown:u,prettifyJson:h,setPrettifyJson:p,showPrompts:m,setShowPrompts:x,showPassFail:v,setShowPassFail:g}=em();return(0,s.jsxs)(G.Z,{open:t,onClose:n,fullWidth:!0,maxWidth:"sm",children:[(0,s.jsx)($.Z,{children:"Table View Settings"}),(0,s.jsxs)(X.Z,{children:[(0,s.jsx)(R.Z,{children:(0,s.jsx)(H.Z,{title:"Forcing line breaks makes it easier to adjust column widths to your liking",placement:"right",children:(0,s.jsx)(eX.Z,{control:(0,s.jsx)(F.Z,{checked:"break-all"===r,onChange:e=>i(e.target.checked?"break-all":"break-word")}),label:"Force line breaks"})})}),(0,s.jsx)(R.Z,{children:(0,s.jsx)(eX.Z,{control:(0,s.jsx)(F.Z,{checked:d,onChange:e=>u(e.target.checked)}),label:"Render model outputs as Markdown"})}),(0,s.jsx)(R.Z,{children:(0,s.jsx)(eX.Z,{control:(0,s.jsx)(F.Z,{checked:h,onChange:e=>p(e.target.checked)}),label:"Prettify JSON outputs"})}),(0,s.jsx)(R.Z,{children:(0,s.jsx)(H.Z,{title:"Show the final prompt that produced the output in each cell.",placement:"right",children:(0,s.jsx)(eX.Z,{control:(0,s.jsx)(F.Z,{checked:m,onChange:e=>x(e.target.checked)}),label:"Show full prompt in output cell"})})}),(0,s.jsx)(R.Z,{children:(0,s.jsx)(H.Z,{title:"Show pass/fail status for each output.",placement:"right",children:(0,s.jsx)(eX.Z,{control:(0,s.jsx)(F.Z,{checked:v,onChange:e=>g(e.target.checked)}),label:"Show pass/fail status"})})}),(0,s.jsx)(R.Z,{children:(0,s.jsx)(H.Z,{title:"Show detailed inference statistics such as latency, tokens used, cost, etc.",placement:"right",children:(0,s.jsx)(eX.Z,{control:(0,s.jsx)(F.Z,{checked:o,onChange:e=>c(e.target.checked)}),label:"Show inference details"})})}),(0,s.jsxs)(R.Z,{maxWidth:"sm",children:[(0,s.jsxs)(er.Z,{mt:2,children:["Max text length: ",l]}),(0,s.jsx)(te.ZP,{min:25,max:1e3,value:l,onChange:(e,t)=>a(t)})]})]}),(0,s.jsx)(q.Z,{children:(0,s.jsx)(D.Z,{onClick:n,children:"Close"})})]})},tn=e=>{let{open:t,onClose:n,shareUrl:a}=e,r=(0,l.useRef)(null),[i,o]=(0,l.useState)(!1),c=()=>{n(),o(!1)};return(0,s.jsxs)(G.Z,{open:t,onClose:c,PaperProps:{style:{minWidth:"min(660px, 100%)"}},children:[(0,s.jsx)($.Z,{children:"Your eval is ready to share"}),(0,s.jsxs)(X.Z,{children:[(0,s.jsx)(J.Z,{inputRef:r,value:a,fullWidth:!0,InputProps:{readOnly:!0,endAdornment:(0,s.jsx)(ef.Z,{onClick:()=>{r.current&&(r.current.select(),document.execCommand("copy"),o(!0))},children:i?(0,s.jsx)(ev.Z,{}):(0,s.jsx)(ej.Z,{})})}}),(0,s.jsx)(e_.Z,{sx:{fontSize:"0.75rem"},children:"Shared URLs are deleted after 2 weeks."})]}),(0,s.jsx)(q.Z,{children:(0,s.jsx)(D.Z,{onClick:c,color:"primary",children:"Close"})})]})};n(58022);let ts=(0,_.Z)(B.Z)(e=>{let{theme:t}=e;return{maxWidth:"100%",flexWrap:"wrap",[t.breakpoints.down("sm")]:{flexDirection:"column"}}});function tl(e){var t;let{recentEvals:n,onRecentEvalSelected:r,defaultEvalId:i}=e,c=(0,g.useRouter)(),d=(0,g.useSearchParams)(),{author:u,table:h,setTable:m,config:v,setConfig:j,maxTextLength:B,wordBreak:_,showInferenceDetails:K,evalId:G,setInComparisonMode:q,columnStates:X,setColumnState:$}=em(),{setStateFromConfig:Q}=(0,y.o)(),[ee,et]=l.useState((null==d?void 0:d.get("search"))||""),[en]=(0,Y.Nr)(ee,1e3),es=e=>{et(e)},[el,ea]=l.useState({}),er=l.useCallback((e,t)=>{ea(n=>({...n,[e]:t}))},[ea]);(0,f.Z)(h,"Table data must be loaded before rendering ResultsView");let{head:ei}=h,[eo,ed]=l.useState("all"),[eu,eh]=l.useState(!1),[ep,ev]=l.useState(""),[eg,ej]=l.useState(!1),[ef,eb]=l.useState(null),{apiShareBaseUrl:eZ}=(0,b.Z)(),ew=(0,b.Y)(),eS=G||i||"default",eN=async()=>{ej(!0);let e="";try{if(p.T){let t=await fetch("".concat(eZ,"/api/eval"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:{version:2,createdAt:new Date().toISOString(),results:{table:h},config:v}})}),{id:n}=await t.json();e="".concat(ew,"/eval/").concat(n)}else e="".concat(window.location.host,"/eval/?evalId=").concat(eS);ev(e),eh(!0)}catch(e){alert("Sorry, something went wrong.")}finally{ej(!1)}},eE=async e=>{eb(null);try{var t;let n=await (0,a.t)("/results/".concat(e),{cache:"no-store"}),s=await n.json(),l=s.data.results.table,r={head:{prompts:[...h.head.prompts.map(e=>({...e,label:"[".concat(G||i||"Eval A","] ").concat(e.label||"")})),...l.head.prompts.map(t=>({...t,label:"[".concat(e,"] ").concat(t.label||"")}))],vars:h.head.vars},body:h.body.map((e,t)=>{var n;return{...e,outputs:[...e.outputs,...(null===(n=l.body[t])||void 0===n?void 0:n.outputs)||[]]}})};m(r),j({...v,...s.data.config,description:'Combined: "'.concat((null==v?void 0:v.description)||"Eval A",'" and "').concat((null===(t=s.data.config)||void 0===t?void 0:t.description)||"Eval B",'"')}),q(!0)}catch(e){console.error("Error fetching comparison eval:",e),alert("Failed to load comparison eval. Please try again.")}},eI=l.useMemo(()=>h.body.some(e=>e.description),[h.body]),eR=ei.prompts.map((e,t)=>{let n=e.label||e.display||e.raw;return{value:"Prompt ".concat(t+1),label:"Prompt ".concat(t+1,": ").concat(n&&n.length>100?n.slice(0,100)+"...":n||""),group:"Prompts"}}),eD=l.useMemo(()=>[...eI?[{value:"description",label:"Description"}]:[],...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"})),...eR],[ei.vars,eR,eI]),[eF,eP]=l.useState(!1),[eT,eL]=l.useState(!1),eO=l.useMemo(()=>[...eI?["description"]:[],...ei.vars.map((e,t)=>"Variable ".concat(t+1)),...ei.prompts.map((e,t)=>"Prompt ".concat(t+1))],[eI,ei.vars,ei.prompts]),eA=X[eS]||{selectedColumns:[],columnVisibility:{}},eU=l.useCallback(e=>{let t={};eO.forEach(n=>{t[n]=e.includes(n)}),$(eS,{selectedColumns:e,columnVisibility:t})},[eO,$,eS]);l.useEffect(()=>{0!==eA.selectedColumns.length&&eA.selectedColumns.every(e=>eO.includes(e))||eU(eO)},[eO,eA.selectedColumns,eU]);let eW=l.useCallback(e=>{let t=Array.isArray(e.target.value)?e.target.value:e.target.value.split(",");eU(t)},[eU]),ez=async()=>{(0,f.Z)(v,"Config must be loaded before clicking its description");let e=window.prompt("Enter new description:",v.description);if(null!==e&&e!==v.description){let t={...v,description:e};try{let e=await (0,a.t)("/api/eval/".concat(G),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({config:t})});if(!e.ok)throw Error("Network response was not ok");j(t)}catch(e){console.error("Failed to update table:",e)}}},eV=async()=>{if(window.confirm("Are you sure you want to delete this evaluation?"))try{let e=await (0,a.t)("/eval/".concat(G),{method:"DELETE"});if(!e.ok)throw Error("Network response was not ok");c.push("/")}catch(e){console.error("Failed to delete evaluation:",e),alert("Failed to delete evaluation")}},[eB,eJ]=l.useState(!1),[eH,e_]=l.useState(!1),eY=async()=>{G&&(await navigator.clipboard.writeText(G),eJ(!0),setTimeout(()=>{eJ(!1)},1e3))};return(0,s.jsxs)("div",{style:{marginLeft:"1rem",marginRight:"1rem"},children:[(0,s.jsxs)(ts,{direction:"row",mb:3,spacing:1,alignItems:"center",className:"eval-header",children:[(0,s.jsxs)(R.Z,{sx:{display:"flex",alignItems:"center",width:"100%",maxWidth:250},children:[(0,s.jsx)(J.Z,{variant:"outlined",size:"small",fullWidth:!0,value:(null==v?void 0:v.description)||G||"",InputProps:{readOnly:!0,startAdornment:(0,s.jsx)(M.Z,{position:"start",children:(0,s.jsx)(E.Z,{})}),endAdornment:(0,s.jsx)(M.Z,{position:"end",children:(0,s.jsx)(Z.Z,{})})},onClick:()=>e_(!0),placeholder:"Search or select an eval...",sx:{cursor:"pointer"}}),(0,s.jsx)(ec,{open:eH,onClose:()=>e_(!1),recentEvals:n,onRecentEvalSelected:r,title:"Select an Eval"})]}),(null==v?void 0:v.description)&&G&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(H.Z,{title:"Click to copy",children:(0,s.jsx)(P.Z,{size:"small",label:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("strong",{children:"ID:"})," ",G]}),sx:{opacity:.7,cursor:"pointer"},onClick:eY})}),(0,s.jsx)(o.Z,{open:eB,autoHideDuration:1e3,onClose:()=>eJ(!1),message:"Eval id copied to clipboard"})]}),(0,s.jsx)(H.Z,{title:u?"":"Set eval author with `promptfoo config set email`",children:(0,s.jsx)(P.Z,{size:"small",label:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("strong",{children:"Author:"})," ",u||"Unknown"]}),sx:{opacity:.7}})}),Object.keys((null==v?void 0:v.tags)||{}).map(e=>{var t;return(0,s.jsx)(P.Z,{size:"small",label:"".concat(e,": ").concat(null==v?void 0:null===(t=v.tags)||void 0===t?void 0:t[e]),sx:{opacity:.7}},e)})]}),(0,s.jsxs)(ts,{direction:"row",spacing:1,alignItems:"center",children:[(0,s.jsx)(R.Z,{children:(0,s.jsxs)(T.Z,{sx:{minWidth:200,maxWidth:350},size:"small",children:[(0,s.jsx)(L.Z,{id:"visible-columns-label",children:"Columns"}),(0,s.jsx)(V.Z,{labelId:"visible-columns-label",id:"visible-columns",multiple:!0,value:eA.selectedColumns,onChange:eW,input:(0,s.jsx)(z.Z,{label:"Visible columns"}),renderValue:e=>e.join(", "),children:eD.map(e=>(0,s.jsxs)(W.Z,{dense:!0,value:e.value,children:[(0,s.jsx)(F.Z,{checked:eA.selectedColumns.includes(e.value)}),(0,s.jsx)(A.Z,{primary:e.label})]},e.value))})]})}),(0,s.jsx)(R.Z,{children:(0,s.jsxs)(T.Z,{sx:{minWidth:180},size:"small",children:[(0,s.jsx)(L.Z,{id:"failure-filter-mode-label",children:"Display"}),(0,s.jsxs)(V.Z,{labelId:"filter-mode-label",id:"filter-mode",value:eo,onChange:e=>{let t=e.target.value;ed(t);let n={};ei.prompts.forEach((e,s)=>{n["Prompt ".concat(s+1)]="failures"===t}),ea(n)},label:"Filter",children:[(0,s.jsx)(W.Z,{value:"all",children:"Show all results"}),(0,s.jsx)(W.Z,{value:"failures",children:"Show failures only"}),(0,s.jsx)(W.Z,{value:"different",children:"Show different only"}),(0,s.jsx)(W.Z,{value:"highlights",children:"Show highlights only"})]})]})}),(0,s.jsx)(R.Z,{children:(0,s.jsx)(J.Z,{sx:{minWidth:180},size:"small",label:"Search",placeholder:"Text or regex",value:ee,onChange:e=>es(e.target.value)})}),(0,s.jsx)(R.Z,{flexGrow:1}),(0,s.jsx)(R.Z,{display:"flex",justifyContent:"flex-end",children:(0,s.jsxs)(ts,{direction:"row",spacing:2,children:[(0,s.jsx)(D.Z,{color:"primary",onClick:e=>{eb(e.currentTarget)},startIcon:(0,s.jsx)(Z.Z,{}),children:"Eval actions"}),v&&(0,s.jsxs)(U.Z,{id:"eval-actions-menu",anchorEl:ef,keepMounted:!0,open:!!ef,onClose:()=>{eb(null)},children:[(0,s.jsx)(H.Z,{title:"Edit the name of this eval",placement:"left",children:(0,s.jsxs)(W.Z,{onClick:ez,children:[(0,s.jsx)(O.Z,{children:(0,s.jsx)(C.Z,{fontSize:"small"})}),"Edit name"]})}),(0,s.jsx)(H.Z,{title:"Edit this eval in the web UI",placement:"left",children:(0,s.jsxs)(W.Z,{onClick:()=>{Q(v),c.push("/setup/")},children:[(0,s.jsx)(O.Z,{children:(0,s.jsx)(k.Z,{fontSize:"small"})}),"Edit and re-run"]})}),(0,s.jsx)(ex,{initialEvals:n,onComparisonEvalSelected:eE}),(0,s.jsx)(H.Z,{title:"View the configuration that defines this eval",placement:"left",children:(0,s.jsxs)(W.Z,{onClick:()=>eP(!0),children:[(0,s.jsx)(O.Z,{children:(0,s.jsx)(I.Z,{fontSize:"small"})}),"View YAML"]})}),(0,s.jsx)(eC,{}),(null==v?void 0:v.sharing)&&(0,s.jsx)(H.Z,{title:"Generate a unique URL that others can access",placement:"left",children:(0,s.jsxs)(W.Z,{onClick:eN,disabled:eg,children:[(0,s.jsx)(O.Z,{children:eg?(0,s.jsx)(x.Z,{size:16}):(0,s.jsx)(N.Z,{fontSize:"small"})}),"Share"]})}),(0,s.jsx)(H.Z,{title:"Delete this eval",placement:"left",children:(0,s.jsxs)(W.Z,{onClick:eV,children:[(0,s.jsx)(O.Z,{children:(0,s.jsx)(w.Z,{fontSize:"small"})}),"Delete"]})})]}),(0,s.jsx)(H.Z,{title:"Edit table view settings",placement:"bottom",children:(0,s.jsx)(D.Z,{color:"primary",onClick:()=>eL(!0),startIcon:(0,s.jsx)(S.Z,{}),children:"Table Settings"})}),((null==v?void 0:v.redteam)||(null==v?void 0:null===(t=v.metadata)||void 0===t?void 0:t.redteam))&&(0,s.jsx)(H.Z,{title:"View vulnerability scan report",placement:"bottom",children:(0,s.jsx)(D.Z,{color:"primary",variant:"contained",startIcon:(0,s.jsx)(I.Z,{}),onClick:()=>c.push("/report/?evalId=".concat(G||i)),children:"Vulnerability Report"})})]})})]}),(0,s.jsx)(eM,{columnVisibility:eA.columnVisibility}),(0,s.jsx)(e9,{maxTextLength:B,columnVisibility:eA.columnVisibility,wordBreak:_,showStats:K,filterMode:eo,failureFilter:el,searchText:en,onFailureFilterToggle:er,onSearchTextChange:es}),(0,s.jsx)(ey,{open:eF,onClose:()=>eP(!1)}),(0,s.jsx)(tn,{open:eu,onClose:()=>eh(!1),shareUrl:ep}),(0,s.jsx)(tt,{open:eT,onClose:()=>eL(!1)}),(0,s.jsx)(ek,{recentEvals:n,onRecentEvalSelected:r})]})}async function ta(){let e=(0,v.createClientComponentClient)(),{data:{user:t}}=await e.auth.getUser();(0,f.Z)(t,"User not logged in");let{data:n}=await e.from("EvaluationResult").select("id, createdAt").eq("user_id",t.id).order("createdAt",{ascending:!1}).limit(100);return n||[]}async function tr(e){let t=(0,v.createClientComponentClient)(),{data:n}=await t.from("EvaluationResult").select("*").eq("id",e).single();return n}function ti(e){var t;let{fetchId:n,preloadedData:r,recentEvals:o,defaultEvalId:c}=e,d=(0,g.useRouter)(),{apiBaseUrl:u}=(0,m.Z)(),{table:v,setTable:y,config:b,setConfig:Z,evalId:w,setEvalId:C,setAuthor:k,setInComparisonMode:S}=em(),[N,E]=l.useState(!1),[I,R]=l.useState(!1),[D,F]=l.useState(o||[]),P=async()=>{let e=await (0,a.t)("/results",{cache:"no-store"});if(!e.ok){R(!0);return}let t=await e.json();return F(t.data),t.data},T=l.useCallback(async e=>{let t=await (0,a.t)("/results/".concat(e),{cache:"no-store"}),n=await t.json();y(n.data.results.table),Z(n.data.config),k(n.data.author),C(e)},[y,Z,C,k]),M=async e=>{p.O?(E(!1),d.push("/eval/remote:".concat(encodeURIComponent(e)))):d.push("/eval/".concat(encodeURIComponent(e)))},[L,O]=l.useState(c||(null===(t=D[0])||void 0===t?void 0:t.evalId)),A=(0,g.useSearchParams)(),U=A?A.get("evalId"):null;return(l.useEffect(()=>{let e=U||n;if(e){console.log("Eval init: Fetching eval by id",{searchEvalId:U,fetchId:n});let t=async()=>{await T(e),E(!0),O(e),P()};t()}else if(r){var t;console.log("Eval init: Using preloaded data"),y(null===(t=r.data.results)||void 0===t?void 0:t.table),Z(r.data.config),k(r.data.author||null),E(!0)}else if(p.T){console.log("Eval init: Using local server websocket");let e=(0,j.io)(u||"");return e.on("init",e=>{console.log("Initialized socket connection",e),E(!0),y(null==e?void 0:e.results.table),Z(null==e?void 0:e.config),k((null==e?void 0:e.author)||null),P().then(e=>{if(e&&e.length>0){var t,n,s;O(null===(t=e[0])||void 0===t?void 0:t.evalId),C(null===(n=e[0])||void 0===n?void 0:n.evalId),console.log("setting default eval id",null===(s=e[0])||void 0===s?void 0:s.evalId)}})}),e.on("update",e=>{console.log("Received data update",e),y(e.results.table),Z(e.config),k(e.author||null),P().then(e=>{if(e&&e.length>0){var t;let n=null===(t=e[0])||void 0===t?void 0:t.evalId;n&&(O(n),C(n))}})}),()=>{e.disconnect()}}else if(p.O)console.log("Eval init: Using Supabase"),ta().then(e=>{F(e.map(e=>({evalId:e.id,datasetId:null,label:e.createdAt,createdAt:new Date(e.createdAt).getTime(),description:"None",numTests:-1}))),e.length>0&&tr(e[0].id).then(t=>{(0,f.Z)(t,"Eval not found");let n=t.results,s=t.config;O(e[0].id),y(n.table),Z(s),k(null),E(!0)})});else{console.log("Eval init: Fetching eval via recent");let e=async()=>{let e=await P();if(!e||!(e.length>0))return(0,s.jsx)("div",{className:"notice",children:"No evals yet. Share some evals to this server and they will appear here."});{let t=e[0].evalId,n=await (0,a.t)("/results/".concat(t)),s=await n.json();y(s.data.results.table),Z(s.data.config),k(s.data.author||null),E(!0),O(t),C(t)}};e()}S(!1)},[u,n,y,Z,k,C,T,r,O,U,S]),l.useEffect(()=>{document.title="".concat((null==b?void 0:b.description)||w||"Eval"," | promptfoo")},[b,w]),I)?(0,s.jsx)("div",{className:"notice",children:"404 Eval not found"}):N&&v?(0,s.jsx)(h,{children:(0,s.jsx)(i,{children:(0,s.jsx)(tl,{defaultEvalId:L,recentEvals:D,onRecentEvalSelected:M})})}):(0,s.jsxs)("div",{className:"notice",children:[(0,s.jsx)("div",{children:(0,s.jsx)(x.Z,{size:22})}),(0,s.jsx)("div",{children:"Waiting for eval data"})]})}n(94455)},52428:function(e,t,n){"use strict";n.d(t,{O:function(){return a},T:function(){return l}});var s=n(77580);let l=!s.env.NEXT_PUBLIC_HOSTED,a=!!s.env.NEXT_PUBLIC_PROMPTFOO_USE_SUPABASE},82911:function(e,t,n){"use strict";var s=n(94660),l=n(74810);let a=(0,s.Ue)()((0,l.tJ)(e=>({apiBaseUrl:"",setApiBaseUrl:t=>e({apiBaseUrl:t}),fetchingPromise:null,setFetchingPromise:t=>e({fetchingPromise:t})}),{name:"api-config-storage",partialize:e=>({apiBaseUrl:e.apiBaseUrl})}));t.Z=a},47887:function(e,t,n){"use strict";n.d(t,{o:function(){return a}});var s=n(94660),l=n(74810);let a=(0,s.Ue)()((0,l.tJ)((e,t)=>({env:{},testCases:[],description:"",providers:[],prompts:[],defaultTest:{},evaluateOptions:{},scenarios:[],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}),setDefaultTest:t=>e({defaultTest:t}),setEvaluateOptions:t=>e({evaluateOptions:t}),setScenarios:t=>e({scenarios: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=>"string"==typeof e&&!e.endsWith(".txt")&&!e.endsWith(".json")&&!e.endsWith(".yaml")):console.warn("Invalid prompts config",t.prompts)),t.defaultTest&&(n.defaultTest=t.defaultTest),t.evaluateOptions&&(n.evaluateOptions=t.evaluateOptions),t.scenarios&&(n.scenarios=t.scenarios),e(n)},getTestSuite:()=>{let{description:e,testCases:n,providers:s,prompts:l,env:a,scenarios:r}=t();return{env:a,description:e,providers:s,prompts:l,tests:n,scenarios:r}}}),{name:"promptfoo",skipHydration:!0}))},88270:function(e,t,n){"use strict";n.d(t,{Y:function(){return r}});var s=n(94660),l=n(74810);let a=(0,s.Ue)()((0,l.tJ)(e=>({apiShareBaseUrl:"https://api.promptfoo.dev",setApiShareBaseUrl:t=>e({apiShareBaseUrl:t}),appShareBaseUrl:"https://app.promptfoo.dev",setAppShareBaseUrl:t=>e({appShareBaseUrl:t})}),{name:"share-config-storage"}));function r(){let{appShareBaseUrl:e}=a();return e||"".concat(window.location.protocol,"//").concat(window.location.host)}t.Z=a},55974:function(){},94455:function(){},16658:function(){},93207:function(){},58022:function(){}}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[86],{49532:function(e,t,n){"use strict";n.d(t,{t:function(){return l}});var s=n(82911);async function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{apiBaseUrl:n}=s.Z.getState();return fetch("".concat(n,"/api").concat(e),t)}},82086:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return ti}});var s=n(24004),l=n(14978),a=n(49532);let r=(0,l.createContext)(void 0),i=e=>{let{children:t}=e,[n,a]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{let e=e=>{"Shift"===e.key&&a(!0)},t=e=>{"Shift"===e.key&&a(!1)};return window.addEventListener("keydown",e),window.addEventListener("keyup",t),()=>{window.removeEventListener("keydown",e),window.removeEventListener("keyup",t)}},[]),(0,s.jsx)(r.Provider,{value:n,children:t})};var o=n(18960),c=n(67070);let d=(0,l.createContext)(void 0),u=()=>{let e=(0,l.useContext)(d);if(!e)throw Error("useToast must be used within a ToastProvider");return e},h=e=>{let{children:t}=e,[n,a]=(0,l.useState)({message:"",severity:"info",open:!1}),r=()=>{a(e=>({...e,open:!1}))};return(0,s.jsxs)(d.Provider,{value:{showToast:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info";a({message:e,severity:t,open:!0})}},children:[t,(0,s.jsx)(o.Z,{open:n.open,autoHideDuration:6e3,onClose:r,children:(0,s.jsx)(c.Z,{onClose:r,severity:n.severity,children:n.message})})]})};var p=n(52428),m=n(82911),x=n(6882),v=n(12594),g=n(28891),j=n(10804),f=n(93179),y=n(47887),b=n(88270),Z=n(11116),w=n(46446),C=n(13391),k=n(98507),S=n(93295),N=n(72467),E=n(95198),I=n(49605),R=n(79245),D=n(49050),F=n(27760),P=n(47827),T=n(84081),M=n(81679),L=n(50819),O=n(8864),A=n(38212),U=n(33932),W=n(74309),z=n(90923),V=n(10654),B=n(13457),J=n(21975),H=n(78276),_=n(72303),Y=n(72053),K=n(94106),G=n(89394),q=n(42834),X=n(26337),$=n(91797),Q=n(29872),ee=n(73701),et=n(39279),en=n(30666),es=n(15795),el=n(66988),ea=n(98489),er=n(43226),ei=n(32162),eo=n.n(ei),ec=e=>{let{open:t,onClose:n,recentEvals:a,onRecentEvalSelected:r,title:i,description:o}=e,[c,d]=(0,l.useState)(""),[u,h]=(0,l.useState)(-1),p=l.useRef(null),m=l.useRef(null),x=()=>{n(),d(""),h(-1)},v=a.filter(e=>eo()(c.toLowerCase(),e.label.toLowerCase())||"string"==typeof e.description&&eo()(c.toLowerCase(),e.description.toLowerCase())),g=e=>{r(e),x()},j=l.useCallback(()=>{if(u>=0&&m.current){let e=m.current.querySelectorAll("tbody tr"),t=Math.min(u+3,e.length-1);e[t]&&e[t].scrollIntoView({behavior:"smooth",block:"nearest"})}},[u]);l.useEffect(()=>{j()},[j]),l.useEffect(()=>{t&&(h(0),setTimeout(()=>{var e;null===(e=p.current)||void 0===e||e.focus()},0))},[t]);let f=l.useId();return(0,s.jsxs)(G.Z,{open:t,onClose:x,maxWidth:"md",fullWidth:!0,children:[i?(0,s.jsx)($.Z,{children:i}):null,(0,s.jsxs)(X.Z,{children:[o?(0,s.jsx)(R.Z,{sx:{mb:4},children:o}):null,(0,s.jsxs)(R.Z,{sx:{width:"100%",mt:2},children:[(0,s.jsx)(J.Z,{fullWidth:!0,variant:"outlined",placeholder:"Search",value:c,onChange:e=>{d(e.target.value),h(0)},onKeyDown:e=>{if(e.stopPropagation(),t)switch(e.key){case"ArrowDown":e.preventDefault(),h(e=>Math.min(e+1,v.length-1));break;case"ArrowUp":e.preventDefault(),h(e=>Math.max(e-1,0));break;case"Enter":e.preventDefault(),u>=0&&u<v.length?g(v[u].evalId):v.length>0&&g(v[0].evalId);break;case"Escape":e.preventDefault(),x()}},sx:{mb:2},inputRef:p,id:"eval-selector-search-".concat(f)}),(0,s.jsx)(es.Z,{component:Q.Z,sx:{height:"600px",overflow:"auto"},ref:m,children:(0,s.jsxs)(ee.Z,{stickyHeader:!0,children:[(0,s.jsx)(el.Z,{children:(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)(en.Z,{children:"Created"}),(0,s.jsx)(en.Z,{children:"Description"}),(0,s.jsx)(en.Z,{children:"# Tests"})]})}),(0,s.jsx)(et.Z,{children:v.length>0?v.map((e,t)=>(0,s.jsxs)(ea.Z,{hover:!0,onClick:()=>g(e.evalId),sx:{cursor:"pointer",backgroundColor:t===u?"rgba(255, 255, 0, 0.1)":"inherit"},children:[(0,s.jsx)(en.Z,{children:new Date(e.createdAt).toLocaleString()}),(0,s.jsx)(en.Z,{children:e.description||e.label}),(0,s.jsx)(en.Z,{children:e.numTests})]},e.evalId)):(0,s.jsx)(ea.Z,{children:(0,s.jsx)(en.Z,{colSpan:3,align:"center",sx:{py:4},children:(0,s.jsxs)(R.Z,{sx:{textAlign:"center",color:"text.secondary"},children:[(0,s.jsx)(R.Z,{sx:{fontSize:"3rem",mb:2},children:"\uD83D\uDD0D"}),(0,s.jsx)(er.Z,{variant:"h6",gutterBottom:!0,children:"No evaluations found"}),(0,s.jsx)(er.Z,{variant:"body2",children:"Try adjusting your search or create a new evaluation"})]})})})})]})})]})]}),(0,s.jsx)(q.Z,{children:(0,s.jsx)(D.Z,{onClick:x,children:"Cancel"})})]})},ed=n(37204),eu=n(94660),eh=n(74810);let ep={getItem:async e=>await (0,ed.U2)(e)||null,setItem:async(e,t)=>{await (0,ed.t8)(e,t)},removeItem:async e=>{await (0,ed.IV)(e)}},em=(0,eu.Ue)()((0,eh.tJ)((e,t)=>({evalId:null,setEvalId:t=>e(()=>({evalId:t})),author:null,setAuthor:t=>e(()=>({author: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})),showPrompts:!1,setShowPrompts:t=>e(()=>({showPrompts:t})),showPassFail:!0,setShowPassFail:t=>e(()=>({showPassFail:t})),inComparisonMode:!1,setInComparisonMode:t=>e(()=>({inComparisonMode:t})),columnStates:{},setColumnState:(t,n)=>e(e=>({columnStates:{...e.columnStates,[t]:n}}))}),{name:"ResultsViewStorage",storage:(0,eh.FL)(()=>ep)}));var ex=function(e){let{initialEvals:t,onComparisonEvalSelected:n}=e,{evalId:r}=em(),[i,o]=(0,l.useState)(!1),[c,d]=(0,l.useState)(t),u=async()=>{try{let e=r||t[0].evalId,n=await (0,a.t)("/results/".concat(e),{cache:"no-store"}),s=await n.json(),l=s.data.datasetId;if(!l){console.error("No datasetId found for current eval "+e);return}let i=await (0,a.t)("/results?datasetId=".concat(l),{cache:"no-store"}),o=await i.json();d(o.data.filter(t=>t.evalId!==e))}catch(e){console.error("Error fetching recent evals:",e)}},h=()=>{o(!1)};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(H.Z,{title:"Combine this eval with another eval run",placement:"left",children:(0,s.jsxs)(W.Z,{onClick:()=>{u(),o(!0)},children:[(0,s.jsx)(O.Z,{children:(0,s.jsx)(K.Z,{fontSize:"small"})}),(0,s.jsx)(A.Z,{children:"Compare with another eval"})]})}),(0,s.jsx)(ec,{open:i,onClose:h,recentEvals:c,onRecentEvalSelected:e=>{n(e),h()},title:"Select an eval to compare",description:"Only evals with the same dataset can be compared."})]})},ev=n(54719),eg=n(52481),ej=n(7175),ef=n(52653);function ey(e){let{open:t,onClose:a}=e,{config:r}=em(),i=l.useRef(null),[o,c]=l.useState(!1),[d,u]=l.useState("");l.useEffect(()=>{t&&(async()=>{let{default:e}=await Promise.resolve().then(n.bind(n,34235));u(e.dump(r))})()},[t,r]);let h=()=>{c(!1),a()};return(0,s.jsxs)(G.Z,{open:t,onClose:h,"aria-labelledby":"config-dialog-title",maxWidth:"md",fullWidth:!0,children:[(0,s.jsx)($.Z,{id:"config-dialog-title",children:(0,s.jsxs)(R.Z,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[(0,s.jsx)(er.Z,{variant:"h6",style:{flexGrow:1},children:"Config"}),(0,s.jsxs)(R.Z,{children:[(0,s.jsx)(H.Z,{title:"Copy to clipboard",children:(0,s.jsx)(ef.Z,{onClick:()=>{i.current&&(i.current.select(),document.execCommand("copy"),c(!0))},children:o?(0,s.jsx)(ev.Z,{}):(0,s.jsx)(ej.Z,{})})}),(0,s.jsx)(H.Z,{title:"Download .yaml",children:(0,s.jsx)(ef.Z,{onClick:()=>{let e=new Blob([d],{type:"text/yaml;charset=utf-8"}),t=URL.createObjectURL(e),n=document.createElement("a");n.href=t,n.download="config.yaml",document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)},children:(0,s.jsx)(eg.Z,{})})})]})]})}),(0,s.jsx)(X.Z,{children:(0,s.jsx)(er.Z,{variant:"body1",component:"div",children:(0,s.jsx)("textarea",{ref:i,readOnly:!0,value:d,style:{width:"100%",minHeight:"400px",fontFamily:"monospace",border:"1px solid #ccc"}})})}),(0,s.jsx)(q.Z,{children:(0,s.jsx)(D.Z,{onClick:h,color:"primary",children:"Close"})})]})}var eb=n(54986),eZ=n(79715),ew=n(34235),eC=function(){let{table:e,config:t,evalId:n}=em(),[a,r]=l.useState(!1),i=(e,t)=>{let n=URL.createObjectURL(e),s=document.createElement("a");s.href=n,s.download=t,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(n)},o=()=>{r(!1)},c=()=>{let e=ew.default.dump(t),n=new Blob([e],{type:"text/yaml;charset=utf-8"});i(n,"promptfooconfig.yaml"),o()},d=()=>{if(!e){alert("No table data");return}let t=e.body.map((t,n)=>({chosen:t.outputs.filter(e=>e.pass).map(e=>e.text),rejected:t.outputs.filter(e=>!e.pass).map(e=>e.text),vars:t.test.vars,providers:e.head.prompts.map(e=>e.provider),prompts:e.head.prompts.map(e=>e.label||e.display||e.raw)})),s=new Blob([JSON.stringify(t,null,2)],{type:"application/json"});i(s,"".concat(n,"-dpo.json")),o()},u=()=>{if(!e){alert("No table data");return}let t=new Blob([JSON.stringify(e,null,2)],{type:"application/json"});i(t,"".concat(n,"-table.json")),o()},h=()=>{if(!e){alert("No table data");return}let t=[],s=[...e.head.vars,...e.head.prompts.map(e=>"[".concat(e.provider,"] ").concat(e.label))];t.push(s),e.body.forEach(e=>{let n=[...e.vars,...e.outputs.map(e=>{let{pass:t,text:n}=e;return(t?"[PASS] ":"[FAIL] ")+n})];t.push(n)});let l=(0,eZ.P)(t),a=new Blob([l],{type:"text/csv;charset=utf-8;"});i(a,"".concat(n,"-table.csv")),o()},p=()=>{if(!e){alert("No table data");return}let t=e.body.filter(e=>e.outputs.some(e=>null!==e.pass)).map(e=>({vars:{...e.test.vars,output:e.outputs[0].text.includes("---")?e.outputs[0].text.split("---\n")[1]:e.outputs[0].text},assert:[{type:"javascript",value:"".concat(e.outputs[0].pass?"":"!","JSON.parse(output).pass")}],metadata:e.test.metadata})),s=ew.default.dump(t),l=new Blob([s],{type:"application/x-yaml"});i(l,"".concat(n,"-human-eval-cases.yaml")),o()},m=l.useCallback(e=>{if("Escape"===e.key)o();else if(a&&!e.altKey&&!e.ctrlKey&&!e.metaKey)switch(e.key){case"1":c();break;case"2":h();break;case"3":u();break;case"4":d();break;case"5":p()}},[a]);return l.useEffect(()=>{let e=e=>{a&&m(e)};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[m,a]),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(W.Z,{onClick:()=>{r(!0)},children:[(0,s.jsx)(O.Z,{children:(0,s.jsx)(eg.Z,{fontSize:"small"})}),(0,s.jsx)(A.Z,{children:"Download"})]}),(0,s.jsxs)(G.Z,{onClose:o,open:a,onKeyDown:m,children:[(0,s.jsx)($.Z,{children:"Download Options"}),(0,s.jsx)(X.Z,{children:(0,s.jsxs)(B.Z,{direction:"column",spacing:2,sx:{width:"100%"},children:[(0,s.jsx)(H.Z,{title:"Download the YAML configuration file",children:(0,s.jsx)(D.Z,{onClick:c,startIcon:(0,s.jsx)(eg.Z,{}),variant:"contained",color:"primary",fullWidth:!0,children:"Download YAML Config"})}),(0,s.jsx)(eb.Z,{}),(0,s.jsx)(er.Z,{variant:"subtitle1",children:"Table Data"}),(0,s.jsx)(H.Z,{title:"Download table data in CSV format",children:(0,s.jsx)(D.Z,{onClick:h,startIcon:(0,s.jsx)(eg.Z,{}),variant:"outlined",fullWidth:!0,children:"Download Table CSV"})}),(0,s.jsx)(H.Z,{title:"Download table data in JSON format",children:(0,s.jsx)(D.Z,{onClick:u,startIcon:(0,s.jsx)(eg.Z,{}),variant:"outlined",fullWidth:!0,children:"Download Table JSON"})}),(0,s.jsx)(eb.Z,{}),(0,s.jsx)(er.Z,{variant:"subtitle1",children:"Advanced Options"}),(0,s.jsx)(H.Z,{title:"Download Direct Preference Optimization JSON",children:(0,s.jsx)(D.Z,{onClick:d,startIcon:(0,s.jsx)(eg.Z,{}),variant:"outlined",color:"secondary",fullWidth:!0,children:"Download DPO JSON"})}),(0,s.jsx)(H.Z,{title:"Download Evaluation Test Cases in YAML format",children:(0,s.jsx)(D.Z,{onClick:p,startIcon:(0,s.jsx)(eg.Z,{}),variant:"outlined",color:"secondary",fullWidth:!0,children:"Download Human Eval Test YAML"})})]})})]})]})},ek=e=>{let{recentEvals:t,onRecentEvalSelected:n}=e,[a,r]=(0,l.useState)(!1),i=()=>{r(!0)};return l.useEffect(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&"k"===e.key&&(e.preventDefault(),i())};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}},[]),(0,s.jsx)(ec,{title:"Open an Eval",open:a,onClose:()=>{r(!1)},recentEvals:t,onRecentEvalSelected:n})},eS=n(69179),eN=n(33533),eE=n(41101),eI=n(36001);let eR=["#fd7f6f","#7eb0d5","#b2e061","#bd7ebe","#ffb55a","#ffee65","#beb9db","#fdcce5","#8bd3c7"];function eD(e){let{table:t}=e,n=(0,l.useRef)(null),a=(0,l.useRef)(null);return(0,l.useEffect)(()=>{if(!n.current)return;a.current&&a.current.destroy();let e=t.body.flatMap(e=>e.outputs.map(e=>e.score)),s=Math.min(...e),l=(Math.ceil(Math.max(...e))-Math.floor(s))/10,r=Array.from({length:11},(e,t)=>Number.parseFloat((Math.floor(s)+t*l).toFixed(2))),i=t.head.prompts.map((e,n)=>{let s=t.body.flatMap(e=>e.outputs[n].score),a=r.map(e=>s.filter(t=>t>=e&&t<e+l).length);return{label:"Column ".concat(n+1),data:a,backgroundColor:eR[n%eR.length]}});a.current=new eI.kL(n.current,{type:"bar",data:{labels:r,datasets:i},options:{animation:!1,plugins:{title:{display:!0,text:"Score Distribution"},legend:{display:!1},tooltip:{callbacks:{title(e){let t=e[0].datasetIndex;return"Column ".concat(t+1)},label(e){let t=e.dataIndex,n=r[t],s=r[t+1];return s?"".concat(n," <= score < ").concat(s):"".concat(n," <= score")}}}}}})},[t]),(0,s.jsx)("canvas",{ref:n,style:{maxHeight:"300px"}})}function eF(e){let{table:t}=e,n=(0,l.useRef)(null),a=(0,l.useRef)(null);return(0,l.useEffect)(()=>{if(!n.current)return;a.current&&a.current.destroy();let e=t.head.prompts.map((e,n)=>{let s=t.body.flatMap(e=>e.outputs[n]),l=s.filter(e=>e.pass).length,a=l/s.length*100;return{label:"Column ".concat(n+1),data:[a],backgroundColor:eR[n%eR.length]}});a.current=new eI.kL(n.current,{type:"bar",data:{labels:["Pass Rate (%)"],datasets:e},options:{animation:!1,plugins:{title:{display:!0,text:"Pass rate"},legend:{display:!0}}}})},[t]),(0,s.jsx)("canvas",{ref:n,style:{maxHeight:"300px"}})}function eP(e){let{table:t}=e,n=(0,l.useRef)(null),a=(0,l.useRef)(null),[r,i]=(0,l.useState)(0),[o,c]=(0,l.useState)(1),[d,u]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{if(!n.current)return;a.current&&a.current.destroy();let e=t.body.flatMap(e=>e.outputs.map(e=>e.score)),s=Math.min(...e),l=Math.max(...e),i=t.body.map(e=>{let t=e.outputs[r].score,n=e.outputs[o].score;return{x:t,y:n,backgroundColor:n>t?"green":n<t?"red":"gray"}});a.current=new eI.kL(n.current,{type:"scatter",data:{datasets:[{data:i,backgroundColor:i.map(e=>e.backgroundColor)},{type:"line",data:[{x:s,y:s},{x:l,y:l}],borderColor:"gray",borderWidth:1,borderDash:[5,5],pointRadius:0}]},options:{animation:!1,plugins:{legend:{display:!1},tooltip:{callbacks:{label(e){let n=t.body[e.dataIndex],s=n.outputs[0].text,l=n.outputs[1].text;return s.length>30&&(s=s.substring(0,30)+"..."),l.length>30&&(l=l.substring(0,30)+"..."),"Output 1: ".concat(s,"\nOutput 2: ").concat(l)}}}},scales:{x:{title:{display:!0,text:"Prompt ".concat(r+1," Score")},ticks:{callback(e,t,n){let s=String(Math.round(100*Number(e)));return t===n.length-1&&(s+="%"),s}}},y:{title:{display:!0,text:"Prompt ".concat(o+1," Score")},ticks:{callback(e,t,n){let s=String(Math.round(100*Number(e)));return t===n.length-1&&(s+="%"),s}}}}}})},[t,r,o]),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(G.Z,{open:d,onClose:()=>u(!1),children:[(0,s.jsx)($.Z,{children:"Compare prompt outputs"}),(0,s.jsxs)(X.Z,{children:[(0,s.jsx)(T.Z,{sx:{m:1,minWidth:120},children:(0,s.jsx)(V.Z,{value:r,onChange:e=>i(Number(e.target.value)),children:t.head.prompts.map((e,t)=>(0,s.jsxs)(W.Z,{value:t,children:["Prompt ",t+1]},t))})}),(0,s.jsx)(T.Z,{sx:{m:1,minWidth:120},children:(0,s.jsx)(V.Z,{value:o,onChange:e=>c(Number(e.target.value)),children:t.head.prompts.map((e,t)=>(0,s.jsxs)(W.Z,{value:t,children:["Prompt ",t+1]},t))})})]})]}),(0,s.jsx)("canvas",{ref:n,style:{maxHeight:"300px",cursor:"pointer"},onClick:()=>u(!0)})]})}function eT(e){let{table:t}=e,n=(0,l.useRef)(null),a=(0,l.useRef)(null);return(0,l.useEffect)(()=>{var e;if(!n.current)return;a.current&&a.current.destroy();let s=Object.keys((null===(e=t.head.prompts[0].metrics)||void 0===e?void 0:e.namedScores)||{}),l=t.head.prompts.map((e,n)=>{let l=s.map(n=>{var s;let l=(null===(s=e.metrics)||void 0===s?void 0:s.namedScores[n])||0,a=Math.max(...t.head.prompts.map(e=>{var t;return(null===(t=e.metrics)||void 0===t?void 0:t.namedScores[n])||0}));return l/a});return{label:"".concat(t.head.prompts[n].provider),data:l,backgroundColor:eR[n%eR.length]}});a.current=new eI.kL(n.current,{type:"bar",data:{labels:s,datasets:l},options:{scales:{x:{grid:{display:!1}},y:{ticks:{callback(e,t,n){let s=String(Math.round(100*Number(e)));return t===n.length-1&&(s+="%"),s}}}},plugins:{tooltip:{callbacks:{title:e=>e[0].dataset.label,label(e){let t=e.parsed.y;return"".concat(s[e.dataIndex],": ").concat((100*t).toFixed(2),"% pass rate")}}}}}})},[t]),(0,s.jsx)("canvas",{ref:n,style:{maxHeight:"300px"}})}eI.kL.register(eI.vn,eI.ST,eI.ho,eI.uw,eI.f$,eI.ZL,eI.jn,eI.od,eI.u,eI.wL);var eM=l.memo(function(e){var t;let{columnVisibility:n}=e,a=(0,eE.Z)();eI.kL.defaults.color="dark"===a.palette.mode?"#aaa":"#666";let[r,i]=(0,l.useState)(!0),{table:o}=em();if(!o||!r||o.head.prompts.length<2)return null;let c=o.body.flatMap(e=>e.outputs.map(e=>e.score)),d=new Set(c);return 1===d.size?null:(0,s.jsx)(eS.SV,{fallback:null,children:(0,s.jsxs)(Q.Z,{sx:{position:"relative",padding:3,mt:2},children:[(0,s.jsx)(ef.Z,{style:{position:"absolute",right:0,top:0},onClick:()=>i(!1),children:(0,s.jsx)(eN.Z,{})}),(0,s.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[(0,s.jsx)("div",{style:{width:"33%"},children:(0,s.jsx)(eF,{table:o})}),(0,s.jsx)("div",{style:{width:"33%"},children:d.size<=3&&Object.keys((null===(t=o.head.prompts[0].metrics)||void 0===t?void 0:t.namedScores)||{}).length>1?(0,s.jsx)(eT,{table:o}):(0,s.jsx)(eD,{table:o})}),(0,s.jsx)("div",{style:{width:"33%"},children:(0,s.jsx)(eP,{table:o})})]})]})})}),eL=n(7660),eO=n(3216),eA=n(5971);n(55974);var eU=e=>{let{lookup:t,metricTotals:n,onSearchTextChange:a}=e,[r,i]=l.useState(!1);if(!t||!Object.keys(t).length)return null;let o=Object.entries(t),c=r?o:o.slice(0,10);return(0,s.jsxs)("div",{className:"custom-metric-container",children:[c.map(e=>{let[t,l]=e;return t&&void 0!==l?(0,s.jsxs)("span",{onClick:()=>a&&a("metric=".concat(t,":")),className:a?"clickable":"",children:[t,":"," ",n&&n[t]?(0,s.jsxs)(s.Fragment,{children:[(l/n[t]*100).toFixed(2),"% (",l.toFixed(2),"/",n[t].toFixed(2),")"]}):l.toFixed(2)]},t):null}),o.length>10&&(0,s.jsx)("span",{className:"clickable",onClick:()=>i(!r),children:r?"Show less":"Show more..."})]})},eW=n(39329),ez=n(64748);function eV(e,t){return e.length<=t?e:e.slice(0,t)+"..."}function eB(e){let{gradingResults:t}=e,[n,a]=(0,l.useState)({});if(!t)return null;let r=e=>{a(t=>({...t,[e]:!t[e]}))};return(0,s.jsxs)(R.Z,{mt:2,children:[(0,s.jsx)(er.Z,{variant:"subtitle1",children:"Assertions"}),(0,s.jsx)(es.Z,{children:(0,s.jsxs)(ee.Z,{children:[(0,s.jsx)(el.Z,{children:(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)(en.Z,{style:{fontWeight:"bold"},children:"Pass"}),(0,s.jsx)(en.Z,{style:{fontWeight:"bold"},children:"Score"}),(0,s.jsx)(en.Z,{style:{fontWeight:"bold"},children:"Type"}),(0,s.jsx)(en.Z,{style:{fontWeight:"bold"},children:"Value"}),(0,s.jsx)(en.Z,{style:{fontWeight:"bold"},children:"Reason"})]})}),(0,s.jsx)(et.Z,{children:t.map((e,t)=>{var l,a,i;if(!e)return null;let o=(null===(l=e.assertion)||void 0===l?void 0:l.value)?"object"==typeof e.assertion.value?JSON.stringify(e.assertion.value,null,2):String(e.assertion.value):"-",c=eV(o,300),d=n[t]||!1;return(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)(en.Z,{children:e.pass?"✅":"❌"}),(0,s.jsx)(en.Z,{children:null===(a=e.score)||void 0===a?void 0:a.toFixed(2)}),(0,s.jsx)(en.Z,{children:(null===(i=e.assertion)||void 0===i?void 0:i.type)||""}),(0,s.jsx)(en.Z,{style:{whiteSpace:"pre-wrap",cursor:"pointer"},onClick:()=>r(t),children:d?o:c}),(0,s.jsx)(en.Z,{style:{whiteSpace:"pre-wrap"},children:e.reason})]},t)})})]})})]})}function eJ(e){let{open:t,onClose:n,prompt:a,provider:r,output:i,gradingResults:o,metadata:c}=e,[d,u]=(0,l.useState)(!1),[h,p]=(0,l.useState)({});(0,l.useEffect)(()=>{u(!1)},[a]);let m=async e=>{await navigator.clipboard.writeText(e),u(!0)},x=e=>{p(t=>({...t,[e]:!t[e]}))};return(0,s.jsxs)(G.Z,{open:t,onClose:n,fullWidth:!0,maxWidth:"lg",children:[(0,s.jsxs)($.Z,{children:["Details",r&&": ".concat(r)]}),(0,s.jsxs)(X.Z,{children:[(0,s.jsxs)(R.Z,{mb:2,children:[(0,s.jsx)(er.Z,{variant:"subtitle1",style:{marginBottom:"1rem"},children:"Prompt"}),(0,s.jsx)(ez.Z,{readOnly:!0,value:a,style:{width:"100%",padding:"0.75rem"},maxRows:20}),(0,s.jsx)(ef.Z,{onClick:()=>m(a),style:{position:"absolute",right:"10px",top:"10px"},children:d?(0,s.jsx)(ev.Z,{}):(0,s.jsx)(eW.Z,{})})]}),(null==c?void 0:c.redteamFinalPrompt)&&(0,s.jsxs)(R.Z,{my:2,children:[(0,s.jsx)(er.Z,{variant:"subtitle1",style:{marginBottom:"1rem",marginTop:"1rem"},children:"Modified User Input (Red Team)"}),(0,s.jsx)(ez.Z,{readOnly:!0,maxRows:20,value:c.redteamFinalPrompt,style:{width:"100%",padding:"0.75rem"}})]}),i&&(0,s.jsxs)(R.Z,{my:2,children:[(0,s.jsx)(er.Z,{variant:"subtitle1",style:{marginBottom:"1rem",marginTop:"1rem"},children:"Output"}),(0,s.jsx)(ez.Z,{readOnly:!0,maxRows:20,value:i,style:{width:"100%",padding:"0.75rem"}})]}),(0,s.jsx)(eB,{gradingResults:o}),c&&Object.keys(c).length>0&&(0,s.jsxs)(R.Z,{my:2,children:[(0,s.jsx)(er.Z,{variant:"subtitle1",style:{marginBottom:"1rem",marginTop:"1rem"},children:"Metadata"}),(0,s.jsx)(es.Z,{children:(0,s.jsxs)(ee.Z,{size:"small",children:[(0,s.jsx)(el.Z,{children:(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)(en.Z,{children:(0,s.jsx)("strong",{children:"Key"})}),(0,s.jsx)(en.Z,{children:(0,s.jsx)("strong",{children:"Value"})})]})}),(0,s.jsx)(et.Z,{children:Object.entries(c).map(e=>{let[t,n]=e,l="string"==typeof n?n:JSON.stringify(n),a=eV(l,300),r=h[t]||!1;return(0,s.jsxs)(ea.Z,{children:[(0,s.jsx)(en.Z,{children:t}),(0,s.jsx)(en.Z,{style:{whiteSpace:"pre-wrap",cursor:"pointer"},onClick:()=>x(t),children:r?l:a})]},t)})})]})})]})]}),(0,s.jsx)(q.Z,{children:(0,s.jsx)(D.Z,{onClick:n,children:"Close"})})]})}var eH=n(89396),e_=n(64173),eY=function(){let e=(0,eE.Z)(),[t,n]=l.useState(!1),a=()=>{n(!1)};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{style:{textAlign:"center",marginTop:20,marginBottom:40},children:(0,s.jsx)(D.Z,{variant:"text",color:"primary",startIcon:(0,s.jsx)(eH.Z,{}),onClick:()=>{n(!0)},children:"Generate test cases"})}),(0,s.jsxs)(G.Z,{open:t,onClose:a,children:[(0,s.jsx)($.Z,{children:"Run on Command Line"}),(0,s.jsx)(X.Z,{children:(0,s.jsxs)(e_.Z,{children:[(0,s.jsx)("p",{children:"This feature is in beta. UI coming soon."}),(0,s.jsxs)("p",{children:["Run"," ",(0,s.jsx)(R.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,s.jsx)(q.Z,{children:(0,s.jsx)(D.Z,{onClick:a,color:"primary",children:"Close"})})]})]})};function eK(e){return"string"==typeof e||"number"==typeof e?e.toString().length:Array.isArray(e)?e.reduce((e,t)=>e+eK(t),0):l.isValidElement(e)&&e.props.children?l.Children.toArray(e.props.children).reduce((e,t)=>e+eK(t),0):0}let eG=l.memo(function(e){let t,{text:n,maxLength:a}=e,[r,i]=l.useState(!0),o=()=>{i(!r)},c=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if("string"==typeof e||"number"==typeof e){let n=e.toString();return n.slice(0,a-t)}if(Array.isArray(e)){let n=[],s=t;for(let t of e){let e=eK(t);if(s+e>a){n.push(c(t,s));break}n.push(t),s+=e}return n}if(l.isValidElement(e)&&e.props.children){let n=eK(e.props.children);if(n>a-t)return l.cloneElement(e,{...e.props,children:c(e.props.children,t)})}return e};t=l.isValidElement(n)||"string"==typeof n?n:JSON.stringify(n);let d=r?c(t):t,u=eK(t)>a;return(0,s.jsxs)("div",{style:{cursor:u?"pointer":"normal"},onMouseDown:e=>{let t=e.clientX,n=e.clientY,s=e=>{let l=e.clientX,a=e.clientY;5>Math.abs(l-t)&&5>Math.abs(a-n)&&o(),document.removeEventListener("mouseup",s)};document.addEventListener("mouseup",s)},children:[d,r&&eK(t)>a&&(0,s.jsx)("span",{children:"..."})]})});var eq=n(45391),eX=n(40182),e$=n(38640),eQ=n.n(e$),e0=n(33352),e1=n(15014),e2=n(65101);n(16658);var e3=e=>{let{failReasons:t}=e,[n,a]=(0,l.useState)(0);return t.length<1?null:(0,s.jsxs)("div",{className:"fail-reason",children:[t.length>1&&(0,s.jsxs)("span",{className:"fail-reason-carousel-controls",children:[(0,s.jsx)(ef.Z,{onClick:()=>{a(e=>e>0?e-1:t.length-1)},children:(0,s.jsx)(e1.Z,{sx:{fontSize:12}})}),(0,s.jsxs)("span",{children:[n+1,"/",t.length]}),(0,s.jsx)(ef.Z,{onClick:()=>{a(e=>e<t.length-1?e+1:0)},children:(0,s.jsx)(e2.Z,{sx:{fontSize:12}})})]}),t[n].trim().split("\n").map((e,t)=>(0,s.jsxs)(l.Fragment,{children:[e,(0,s.jsx)("br",{})]},t))]})},e5=e=>{let{open:t,contextText:n,commentText:l,onClose:a,onSave:r,onChange:i}=e,o="dark"===(0,eE.Z)().palette.mode;return(0,s.jsxs)(G.Z,{open:t,onClose:a,fullWidth:!0,maxWidth:"sm",children:[(0,s.jsx)($.Z,{children:"Edit Comment"}),(0,s.jsxs)(X.Z,{children:[(0,s.jsx)(R.Z,{sx:{backgroundColor:o?"#1e1e1e":"#f0f0f0",padding:2,marginBottom:2},children:n}),(0,s.jsx)(J.Z,{autoFocus:!0,margin:"dense",type:"text",fullWidth:!0,multiline:!0,rows:4,value:l,onChange:e=>i(e.target.value)})]}),(0,s.jsxs)(q.Z,{children:[(0,s.jsx)(D.Z,{onClick:r,color:"primary",variant:"contained",children:"Save"}),(0,s.jsx)(D.Z,{onClick:a,color:"primary",children:"Cancel"})]})]})};let e4=()=>{let e=(0,l.useContext)(r);if(void 0===e)throw Error("useShiftKey must be used within a ShiftKeyProvider");return e};var e8=n(68192);let e7=l.memo(function(e){var t,n,a,r,i,o,c,d,u,h,p,m,x;let v,g,j,f,y,b,{output:Z,maxTextLength:w,rowIndex:C,promptIndex:k,onRating:S,firstOutput:N,showDiffs:E,searchText:I,showStats:R}=e,{renderMarkdown:D,prettifyJson:F,showPrompts:P,showPassFail:T}=em(),[M,L]=l.useState(!1),[O,A]=l.useState(!1),[U,W]=l.useState(null),z=e=>{W(e||null),A(!O)},[V,B]=l.useState(!1),[J,_]=l.useState((null===(t=Z.gradingResult)||void 0===t?void 0:t.comment)||""),Y=()=>{B(!0)},K="string"==typeof Z.text?Z.text:JSON.stringify(Z.text),G=[];if(!Z.pass&&K.includes("---")&&(G=((null===(h=Z.gradingResult)||void 0===h?void 0:h.componentResults)||[]).filter(e=>!!e&&!e.pass).map(e=>e.reason),K=K.split("---").slice(1).join("---")),E&&N){let e,t="string"==typeof N.text?N.text:JSON.stringify(N.text);t.includes("---")&&(t=t.split("---").slice(1).join("---"));try{JSON.parse(t),JSON.parse(K),e=(0,e8.CT)(t,K)}catch(n){e=t.includes(". ")&&K.includes(". ")?(0,e8.SY)(t,K):(0,e8.NV)(t,K)}v=(0,s.jsx)(s.Fragment,{children:e.map((e,t)=>e.added?(0,s.jsx)("ins",{children:e.value},t):e.removed?(0,s.jsx)("del",{children:e.value},t):(0,s.jsx)("span",{children:e.value},t))})}if(I)try{let e;let t=RegExp(I,"gi"),n=[];for(;null!==(e=t.exec(K));)n.push({start:e.index,end:t.lastIndex});v=(0,s.jsx)(s.Fragment,{children:n.length>0?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{children:K.substring(0,n[0].start)},"text-before"),n.map((e,t)=>(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"search-highlight",children:K.substring(e.start,e.end)},"match-"+t),(0,s.jsx)("span",{children:K.substring(e.end,n[t+1]?n[t+1].start:K.length)},"text-after-"+t)]}))]}):(0,s.jsx)("span",{children:K},"no-match")})}catch(e){console.error("Invalid regular expression:",e.message)}else if(D&&!E)v=(0,s.jsx)(eA.U,{remarkPlugins:[e0.Z],components:{img:e=>{let{src:t,alt:n}=e;return(0,s.jsx)("img",{loading:"lazy",src:t,alt:n,onClick:()=>z(t),style:{cursor:"pointer"}})}},children:K});else if(F)try{v=(0,s.jsx)("pre",{children:JSON.stringify(JSON.parse(K),null,2)})}catch(e){}let q=l.useCallback(e=>{var t;S(e,void 0,null===(t=Z.gradingResult)||void 0===t?void 0:t.comment)},[S,null===(n=Z.gradingResult)||void 0===n?void 0:n.comment]),X=l.useCallback(()=>{let e=prompt("Set test score (0.0 - 1.0):",String(Z.score));if(null!==e){let n=Number.parseFloat(e);if(!Number.isNaN(n)&&n>=0&&n<=1){var t;S(void 0,n,null===(t=Z.gradingResult)||void 0===t?void 0:t.comment)}else alert("Invalid score. Please enter a value between 0.0 and 1.0.")}},[S,Z.score,null===(a=Z.gradingResult)||void 0===a?void 0:a.comment]),[$,Q]=l.useState(!1),ee=l.useCallback(()=>{navigator.clipboard.writeText(Z.text),Q(!0)},[Z.text]);if(Z.latencyMs&&(j=(0,s.jsxs)("span",{children:[Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(Z.latencyMs)," ms"]})),null===(r=Z.tokenUsage)||void 0===r?void 0:r.completion){let e=Z.tokenUsage.completion/(Z.latencyMs/1e3);f=(0,s.jsx)("span",{children:Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(e)})}if(Z.cost&&(y=(0,s.jsxs)("span",{children:["$",Z.cost.toPrecision(2)]})),null===(i=Z.tokenUsage)||void 0===i?void 0:i.cached)g=(0,s.jsxs)("span",{children:[Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(Z.tokenUsage.cached)," ","(cached)"]});else if(null===(o=Z.tokenUsage)||void 0===o?void 0:o.total){let e=Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(null!==(p=Z.tokenUsage.prompt)&&void 0!==p?p:0),t=Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(null!==(m=Z.tokenUsage.completion)&&void 0!==m?m:0),n=Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(Z.tokenUsage.total);g=(0,s.jsx)(H.Z,{title:"".concat(e," prompt tokens + ").concat(t," completion tokens = ").concat(n," total"),children:(0,s.jsxs)("span",{children:[n,("0"!==e||"0"!==t)&&" (".concat(e,"+").concat(t,")")]})})}let et=(null===(c=Z.gradingResult)||void 0===c?void 0:c.comment)&&"!highlight"!==Z.gradingResult.comment?(0,s.jsx)("div",{className:"comment",onClick:Y,children:Z.gradingResult.comment}):null,en=R?(0,s.jsxs)("div",{className:"cell-detail",children:[g&&(0,s.jsxs)("div",{className:"stat-item",children:[(0,s.jsx)("strong",{children:"Tokens:"})," ",g]}),j&&(0,s.jsxs)("div",{className:"stat-item",children:[(0,s.jsx)("strong",{children:"Latency:"})," ",j]}),f&&(0,s.jsxs)("div",{className:"stat-item",children:[(0,s.jsx)("strong",{children:"Tokens/Sec:"})," ",f]}),y&&(0,s.jsxs)("div",{className:"stat-item",children:[(0,s.jsx)("strong",{children:"Cost:"})," ",y]})]}):null,es=e4(),el=(0,s.jsxs)("div",{className:"cell-actions",children:[es&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"action",onClick:ee,onMouseDown:e=>e.preventDefault(),children:(0,s.jsx)(H.Z,{title:"Copy output to clipboard",children:(0,s.jsx)("span",{children:$?"✅":"\uD83D\uDCCB"})})}),(0,s.jsx)("span",{className:"action",onClick:()=>{let e;J.startsWith("!highlight")?S(void 0,void 0,e=J.slice(10).trim()):S(void 0,void 0,e=("!highlight "+J).trim()),_(e)},onMouseDown:e=>e.preventDefault(),children:(0,s.jsx)(H.Z,{title:"Toggle test highlight",children:(0,s.jsx)("span",{children:"\uD83C\uDF1F"})})})]}),Z.prompt&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"action",onClick:()=>{L(!0)},children:(0,s.jsx)(H.Z,{title:"View output and test details",children:(0,s.jsx)("span",{children:"\uD83D\uDD0E"})})}),(0,s.jsx)(eJ,{open:M,onClose:()=>{L(!1)},prompt:Z.prompt,provider:Z.provider,gradingResults:null===(d=Z.gradingResult)||void 0===d?void 0:d.componentResults,output:K,metadata:Z.metadata})]}),(0,s.jsx)("span",{className:"action",onClick:()=>q(!0),children:(0,s.jsx)(H.Z,{title:"Mark test passed (score 1.0)",children:(0,s.jsx)("span",{children:"\uD83D\uDC4D"})})}),(0,s.jsx)("span",{className:"action",onClick:()=>q(!1),children:(0,s.jsx)(H.Z,{title:"Mark test failed (score 0.0)",children:(0,s.jsx)("span",{children:"\uD83D\uDC4E"})})}),(0,s.jsx)("span",{className:"action",onClick:X,children:(0,s.jsx)(H.Z,{title:"Set test score",children:(0,s.jsx)("span",{children:"\uD83D\uDD22"})})}),(0,s.jsx)("span",{className:"action",onClick:Y,children:(0,s.jsx)(H.Z,{title:"Edit comment",children:(0,s.jsx)("span",{children:"✏️"})})})]}),ea={};(null===(u=Z.gradingResult)||void 0===u?void 0:u.comment)==="!highlight"&&(ea.backgroundColor="#ffffeb");let er=0,ei=0,eo=Z.gradingResult;if(eo?eo.componentResults?eo.componentResults.forEach(e=>{(null==e?void 0:e.pass)?er++:ei++}):(er=eo.pass?1:0,ei=eo.pass?0:1):Z.pass?er=1:Z.pass||(ei=1),1===ei&&1===er)b=(0,s.jsxs)(s.Fragment,{children:["".concat(ei," FAIL")," ","".concat(er," PASS")]});else{let e="";ei>1||er>1&&ei>0?e="".concat(ei," FAIL"):1===ei&&(e="FAIL");let t="";er>1||ei>1&&er>0?t="".concat(er," PASS"):1===er&&0===ei&&(t="PASS");let n=e&&t?" ":"";b=(0,s.jsxs)(s.Fragment,{children:[e,n,t]})}let ec=null===(x=Z.score)||0===x||1===x?"":"(".concat(x.toFixed(2),")");return(0,s.jsxs)("div",{className:"cell",style:ea,children:[T&&(0,s.jsx)(s.Fragment,{children:Z.pass?(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)("div",{className:"status pass",children:[(0,s.jsxs)("div",{className:"pill",children:[b,ec&&(0,s.jsxs)("span",{className:"score",children:[" ",ec]})]}),(0,s.jsx)(eU,{lookup:Z.namedScores})]})}):(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)("div",{className:"status fail",children:[(0,s.jsxs)("div",{className:"pill",children:[b,ec&&(0,s.jsxs)("span",{className:"score",children:[" ",ec]})]}),(0,s.jsx)(eU,{lookup:Z.namedScores}),(0,s.jsx)("span",{className:"fail-reason",children:(0,s.jsx)(e3,{failReasons:G})})]})})}),P&&N.prompt&&(0,s.jsxs)("div",{className:"prompt",children:[(0,s.jsx)("span",{className:"pill",children:"Prompt"}),Z.prompt]}),(0,s.jsx)(eG,{text:v||K,maxLength:w}),et,en,el,O&&U&&(0,s.jsx)("div",{className:"lightbox",onClick:()=>z(),children:(0,s.jsx)("img",{src:U,alt:"Lightbox"})}),(0,s.jsx)(e5,{open:V,contextText:Z.text,commentText:J,onClose:()=>{B(!1)},onSave:()=>{S(void 0,void 0,J),B(!1)},onChange:_})]})});function e6(e){let{text:t,maxLength:n,expandedText:a,resourceId:r,className:i}=e,[o,c]=l.useState(!1);return(0,s.jsxs)("div",{className:"".concat(i||""),children:[(0,s.jsx)(eG,{text:t,maxLength:n}),a&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(H.Z,{title:"View prompt",children:(0,s.jsx)("span",{className:"action",onClick:()=>{c(!0)},children:"\uD83D\uDD0E"})}),(0,s.jsx)(eJ,{open:o,onClose:()=>{c(!1)},prompt:a}),r&&(0,s.jsx)(H.Z,{title:"View other evals and datasets for this prompt",children:(0,s.jsx)("span",{className:"action",children:(0,s.jsx)(eQ(),{href:"/prompts/?id=".concat(r),target:"_blank",children:(0,s.jsx)(eq.Z,{fontSize:"small"})})})})]})]})}n(93207);var e9=l.memo(function(e){let{maxTextLength:t,columnVisibility:n,wordBreak:r,filterMode:i,failureFilter:o,searchText:c,showStats:d,onFailureFilterToggle:h,onSearchTextChange:p}=e,{evalId:m,table:x,setTable:v,config:g,inComparisonMode:j}=em(),{showToast:y}=u();(0,f.Z)(x,"Table should be defined");let{head:b,body:Z}=x,w=l.useCallback(async(e,t,n,s,l)=>{var r,i;let o=[...Z],c={...o[e]},d=[...c.outputs],u=null!=n?n:d[t].pass,h=void 0===s?n?1:0:s||0;d[t].pass=u,d[t].score=h;let p=(null===(r=d[t].gradingResult)||void 0===r?void 0:r.componentResults)||[];if(void 0!==n){let e=p.findIndex(e=>{var t;return(null===(t=e.assertion)||void 0===t?void 0:t.type)==="human"}),t={pass:u,score:h,reason:"Manual result (overrides all other grading results)",comment:l,assertion:{type:"human"}};-1===e?p.push(t):p[e]=t}let x={...d[t].gradingResult||{},pass:u,score:h,reason:"Manual result (overrides all other grading results)",comment:l,assertion:(null===(i=d[t].gradingResult)||void 0===i?void 0:i.assertion)||null,componentResults:p};d[t].gradingResult=x,c.outputs=d,o[e]=c;let g={head:b,body:o};if(v(g),j)y("Ratings are not saved in comparison mode","warning");else try{let e=await (0,a.t)("/eval/".concat(m),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({table:g})});if(!e.ok)throw Error("Network response was not ok")}catch(e){console.error("Failed to update table:",e)}},[Z,b,v,m,j,y]),C=Object.keys(n).length>0,k=l.useMemo(()=>{try{return RegExp(c,"i")}catch(e){return console.error("Invalid regular expression:",e.message),null}},[c]),S=l.useMemo(()=>{try{return Z.map((e,t)=>({...e,outputs:e.outputs.map((e,n)=>({...e,originalRowIndex:t,originalPromptIndex:n}))})).filter(e=>{let t=!0;return"failures"===i?t=e.outputs.some((e,t)=>{let s="Prompt ".concat(t+1);return o[s]&&!e.pass&&(!C||n[s])}):"different"===i?t=!e.outputs.every(t=>t.text===e.outputs[0].text):"highlights"===i&&(console.log(e.outputs[0].text),t=e.outputs.some(e=>{var t,n;return null===(n=e.gradingResult)||void 0===n?void 0:null===(t=n.comment)||void 0===t?void 0:t.startsWith("!highlight")})),!!t&&(!c||!k||e.outputs.some(t=>{var n,s;let l=e.vars.map(e=>"var=".concat(e)).join(" "),a="".concat(t.text," ").concat(Object.keys(t.namedScores).map(e=>"metric=".concat(e,":").concat(t.namedScores[e])).join(" ")," ").concat((null===(n=t.gradingResult)||void 0===n?void 0:n.reason)||""," ").concat((null===(s=t.gradingResult)||void 0===s?void 0:s.comment)||""),r="".concat(l," ").concat(a);return k.test(r)}))})}catch(e){return console.error("Invalid regular expression:",e.message),Z}},[Z,o,i,c,n,C,k]),[N,E]=l.useState({pageIndex:0,pageSize:50});l.useEffect(()=>{E(e=>({...e,pageIndex:0}))},[o,i,c]);let I=l.useMemo(()=>b.prompts.map((e,t)=>Z.reduce((e,n)=>e+(n.outputs[t].pass?1:0),0)),[b.prompts,Z]),P=l.useMemo(()=>b.prompts.map((e,t)=>Z.reduce((e,n)=>{var s,l;return e+((null===(l=n.outputs[t].gradingResult)||void 0===l?void 0:null===(s=l.componentResults)||void 0===s?void 0:s.length)||0)},0)),[b.prompts,Z]),T=l.useMemo(()=>b.prompts.map((e,t)=>Z.reduce((e,n)=>{var s;let l=null===(s=n.outputs[t].gradingResult)||void 0===s?void 0:s.componentResults;return e+(l?l.filter(e=>null==e?void 0:e.pass).length:0)},0)),[b.prompts,Z]),M=l.useMemo(()=>I.reduce((e,t,n,s)=>t>s[e]?n:e,0),[I]),L=I[M],O=l.useMemo(()=>(0,eL.Cl)(),[]),{renderMarkdown:A}=em(),U=l.useMemo(()=>b.vars.length>0?[O.group({id:"vars",header:()=>(0,s.jsx)("span",{className:"font-bold",children:"Variables"}),columns:b.vars.map((e,n)=>O.accessor(e=>e.vars[n],{id:"Variable ".concat(n+1),header:()=>(0,s.jsx)(e6,{text:e,maxLength:t,className:"font-bold"}),cell:e=>{let n=e.getValue();return(0,s.jsx)("div",{className:"cell",children:A?(0,s.jsx)(eA.U,{remarkPlugins:[e0.Z],children:n}):(0,s.jsx)(eG,{text:n,maxLength:t})})},size:50}))})]:[],[O,b.vars,t,A]),z=l.useCallback((e,t)=>S[e].outputs[t],[S]),B=l.useCallback(e=>S[e].outputs[0],[S]),_=l.useMemo(()=>{let e={};return null==x||x.body.forEach(t=>{var n;null===(n=t.test.assert)||void 0===n||n.forEach(t=>{t.metric&&(e[t.metric]=(e[t.metric]||0)+1),"assert"in t&&Array.isArray(t.assert)&&t.assert.forEach(t=>{"metric"in t&&t.metric&&(e[t.metric]=(e[t.metric]||0)+1)})})}),e},[x]),Y=l.useMemo(()=>[O.group({id:"prompts",header:()=>(0,s.jsx)("span",{className:"font-bold",children:"Outputs"}),columns:b.prompts.map((e,n)=>O.accessor(e=>(function(e){if("string"==typeof e){let t=e.startsWith("[PASS]"),n=e;return e.startsWith("[PASS]")?n=n.slice(6):e.startsWith("[FAIL]")&&(n=n.slice(6)),{text:n,pass:t,score:t?1:0}}return e})(e.outputs[n]),{id:"Prompt ".concat(n+1),header:()=>{var l,a,r,c,u,m,x,v;let j=I[n]&&Z.length?(I[n]/Z.length*100).toFixed(2):"0.00",f=I[n]===L&&0!==L,y="Prompt ".concat(n+1),b=o[y]||!1,w=d?(0,s.jsxs)("div",{className:"prompt-detail",children:[P[n]?(0,s.jsxs)("div",{children:[(0,s.jsx)("strong",{children:"Asserts:"})," ",T[n],"/",P[n]," passed"]}):null,(null===(l=e.metrics)||void 0===l?void 0:l.totalLatencyMs)?(0,s.jsxs)("div",{children:[(0,s.jsx)("strong",{children:"Avg Latency:"})," ",Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(e.metrics.totalLatencyMs/Z.length)," ","ms"]}):null,(null===(r=e.metrics)||void 0===r?void 0:null===(a=r.tokenUsage)||void 0===a?void 0:a.total)?(0,s.jsxs)("div",{children:[(0,s.jsx)("strong",{children:"Avg Tokens:"})," ",Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(e.metrics.tokenUsage.total/Z.length)]}):null,(null===(c=e.metrics)||void 0===c?void 0:c.totalLatencyMs)&&(null===(m=e.metrics)||void 0===m?void 0:null===(u=m.tokenUsage)||void 0===u?void 0:u.completion)?(0,s.jsxs)("div",{children:[(0,s.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,s.jsxs)("div",{children:[(0,s.jsx)("strong",{children:"Cost:"})," $",e.metrics.cost.toPrecision(2)]}):null]}):null,C=Array.isArray(null==g?void 0:g.providers)?g.providers[n]:void 0,k=e.provider?e.provider.split(":"):[],S=(0,s.jsx)(H.Z,{title:C?(0,s.jsx)("pre",{children:ew.default.dump(C)}):"",children:k.length>1?(0,s.jsxs)(s.Fragment,{children:[k[0],":",(0,s.jsx)("strong",{children:k.slice(1).join(":")})]}):(0,s.jsx)("strong",{children:e.provider})});return(0,s.jsxs)("div",{className:"output-header",children:[(0,s.jsxs)("div",{className:"pills",children:[e.provider?(0,s.jsx)("div",{className:"provider",children:S}):null,(0,s.jsx)("div",{className:"summary",children:(0,s.jsxs)("div",{className:"highlight ".concat(f?"success":""),children:[(0,s.jsxs)("strong",{children:[j,"% passing"]})," (",I[n],"/",Z.length," cases)"]})}),(null===(v=e.metrics)||void 0===v?void 0:v.namedScores)&&Object.keys(e.metrics.namedScores).length>0?(0,s.jsx)(eU,{lookup:e.metrics.namedScores,metricTotals:_,onSearchTextChange:p}):null]}),(0,s.jsx)(e6,{className:"prompt-container",text:e.label||e.display||e.raw,expandedText:e.raw,maxLength:t,resourceId:e.id}),w,"failures"===i&&(0,s.jsx)(eX.Z,{sx:{"& .MuiFormControlLabel-label":{fontSize:"0.75rem"}},control:(0,s.jsx)(F.Z,{checked:b,onChange:e=>h(y,e.target.checked)}),label:"Show failures"})]})},cell:e=>{var l,a;let r=z(e.row.index,n);return(0,s.jsx)(e7,{output:r,maxTextLength:t,rowIndex:e.row.index,promptIndex:n,onRating:w.bind(null,null!==(l=r.originalRowIndex)&&void 0!==l?l:e.row.index,null!==(a=r.originalPromptIndex)&&void 0!==a?a:n),firstOutput:B(e.row.index),showDiffs:"different"===i,searchText:c,showStats:d})}}))})],[Z.length,null==g?void 0:g.providers,O,o,i,B,z,w,b.prompts,L,t,_,P,T,I,h,p,c,d]),K=l.useMemo(()=>{let e=Z.some(e=>e.description);return e?{accessorFn:e=>e.description||"",id:"description",header:()=>(0,s.jsx)("span",{className:"font-bold",children:"Description"}),cell:e=>(0,s.jsx)("div",{className:"cell",children:(0,s.jsx)(eG,{text:String(e.getValue()),maxLength:t})}),size:50}:null},[Z,t]),G=l.useMemo(()=>{let e=[];return K&&e.push(K),e.push(...U,...Y),e},[K,U,Y]),q=(0,eO.b7)({data:S,columns:G,columnResizeMode:"onChange",getCoreRowModel:(0,eL.sC)(),getPaginationRowModel:(0,eL.G_)(),state:{columnVisibility:n,pagination:N}});return(0,s.jsxs)("div",{children:[(0,s.jsxs)("table",{className:"results-table firefox-fix ".concat(t<=25?"compact":""),style:{wordBreak:r},children:[(0,s.jsx)("thead",{children:q.getHeaderGroups().map(e=>(0,s.jsx)("tr",{className:"header",children:e.headers.map(e=>(0,s.jsxs)("th",{colSpan:e.colSpan,style:{width:e.getSize()},children:[e.isPlaceholder?null:(0,eO.ie)(e.column.columnDef.header,e.getContext()),(0,s.jsx)("div",{onMouseDown:e.getResizeHandler(),onTouchStart:e.getResizeHandler(),className:"resizer ".concat(e.column.getIsResizing()?"isResizing":"")})]},e.id))},e.id))}),(0,s.jsx)("tbody",{children:q.getRowModel().rows.map((e,t)=>{let n=!1;return(0,s.jsx)("tr",{children:e.getVisibleCells().map(e=>{let l=e.column.id.startsWith("Variable")||"description"===e.column.id,a=!l&&!n;return a&&(n=!0),(0,s.jsx)("td",{style:{width:e.column.getSize()},className:"".concat(l?"variable":""," ").concat(0!==t||l?"":"first-prompt-row"," ").concat(a?"first-prompt-col":""),children:(0,eO.ie)(e.column.columnDef.cell,e.getContext())},e.id)})},e.id)})})]}),q.getPageCount()>1&&(0,s.jsxs)(R.Z,{className:"pagination",mx:1,sx:{display:"flex",alignItems:"center",gap:2},children:[(0,s.jsx)(D.Z,{onClick:()=>{E(e=>({...e,pageIndex:Math.max(e.pageIndex-1,0)})),window.scrollTo(0,0)},disabled:0===q.getState().pagination.pageIndex,variant:"contained",children:"Previous"}),(0,s.jsxs)(er.Z,{component:"span",sx:{display:"flex",alignItems:"center",gap:1},children:["Page",(0,s.jsx)(J.Z,{size:"small",type:"number",value:q.getState().pagination.pageIndex+1,onChange:e=>{let t=e.target.value?Number(e.target.value)-1:0;E(e=>({...e,pageIndex:Math.min(Math.max(t,0),q.getPageCount()-1)}))},InputProps:{style:{width:"60px",textAlign:"center"}},variant:"outlined"}),(0,s.jsxs)("span",{children:["of ",q.getPageCount()]})]}),(0,s.jsx)(D.Z,{onClick:()=>{E(e=>({...e,pageIndex:Math.min(e.pageIndex+1,q.getPageCount()-1)})),window.scrollTo(0,0)},disabled:q.getState().pagination.pageIndex+1>=q.getPageCount(),variant:"contained",children:"Next"}),(0,s.jsxs)(er.Z,{component:"span",sx:{display:"flex",alignItems:"center",gap:1},children:[(0,s.jsxs)(V.Z,{value:N.pageSize,onChange:e=>{E({pageIndex:0,pageSize:Number(e.target.value)}),window.scrollTo(0,0)},displayEmpty:!0,inputProps:{"aria-label":"Results per page"},size:"small",sx:{m:1,minWidth:80},children:[(0,s.jsx)(W.Z,{value:10,children:"10"}),(0,s.jsx)(W.Z,{value:50,children:"50"}),(0,s.jsx)(W.Z,{value:100,children:"100"}),(0,s.jsx)(W.Z,{value:500,children:"500"}),(0,s.jsx)(W.Z,{value:1e3,children:"1000"})]}),(0,s.jsx)("span",{children:"results per page"})]})]}),(0,s.jsx)(eY,{})]})}),te=n(4451),tt=e=>{let{open:t,onClose:n}=e,{maxTextLength:l,setMaxTextLength:a,wordBreak:r,setWordBreak:i,showInferenceDetails:o,setShowInferenceDetails:c,renderMarkdown:d,setRenderMarkdown:u,prettifyJson:h,setPrettifyJson:p,showPrompts:m,setShowPrompts:x,showPassFail:v,setShowPassFail:g}=em();return(0,s.jsxs)(G.Z,{open:t,onClose:n,fullWidth:!0,maxWidth:"sm",children:[(0,s.jsx)($.Z,{children:"Table View Settings"}),(0,s.jsxs)(X.Z,{children:[(0,s.jsx)(R.Z,{children:(0,s.jsx)(H.Z,{title:"Forcing line breaks makes it easier to adjust column widths to your liking",placement:"right",children:(0,s.jsx)(eX.Z,{control:(0,s.jsx)(F.Z,{checked:"break-all"===r,onChange:e=>i(e.target.checked?"break-all":"break-word")}),label:"Force line breaks"})})}),(0,s.jsx)(R.Z,{children:(0,s.jsx)(eX.Z,{control:(0,s.jsx)(F.Z,{checked:d,onChange:e=>u(e.target.checked)}),label:"Render model outputs as Markdown"})}),(0,s.jsx)(R.Z,{children:(0,s.jsx)(eX.Z,{control:(0,s.jsx)(F.Z,{checked:h,onChange:e=>p(e.target.checked)}),label:"Prettify JSON outputs"})}),(0,s.jsx)(R.Z,{children:(0,s.jsx)(H.Z,{title:"Show the final prompt that produced the output in each cell.",placement:"right",children:(0,s.jsx)(eX.Z,{control:(0,s.jsx)(F.Z,{checked:m,onChange:e=>x(e.target.checked)}),label:"Show full prompt in output cell"})})}),(0,s.jsx)(R.Z,{children:(0,s.jsx)(H.Z,{title:"Show pass/fail status for each output.",placement:"right",children:(0,s.jsx)(eX.Z,{control:(0,s.jsx)(F.Z,{checked:v,onChange:e=>g(e.target.checked)}),label:"Show pass/fail status"})})}),(0,s.jsx)(R.Z,{children:(0,s.jsx)(H.Z,{title:"Show detailed inference statistics such as latency, tokens used, cost, etc.",placement:"right",children:(0,s.jsx)(eX.Z,{control:(0,s.jsx)(F.Z,{checked:o,onChange:e=>c(e.target.checked)}),label:"Show inference details"})})}),(0,s.jsxs)(R.Z,{maxWidth:"sm",children:[(0,s.jsxs)(er.Z,{mt:2,children:["Max text length: ",l]}),(0,s.jsx)(te.ZP,{min:25,max:1e3,value:l,onChange:(e,t)=>a(t)})]})]}),(0,s.jsx)(q.Z,{children:(0,s.jsx)(D.Z,{onClick:n,children:"Close"})})]})},tn=e=>{let{open:t,onClose:n,shareUrl:a}=e,r=(0,l.useRef)(null),[i,o]=(0,l.useState)(!1),c=()=>{n(),o(!1)};return(0,s.jsxs)(G.Z,{open:t,onClose:c,PaperProps:{style:{minWidth:"min(660px, 100%)"}},children:[(0,s.jsx)($.Z,{children:"Your eval is ready to share"}),(0,s.jsxs)(X.Z,{children:[(0,s.jsx)(J.Z,{inputRef:r,value:a,fullWidth:!0,InputProps:{readOnly:!0,endAdornment:(0,s.jsx)(ef.Z,{onClick:()=>{r.current&&(r.current.select(),document.execCommand("copy"),o(!0))},children:i?(0,s.jsx)(ev.Z,{}):(0,s.jsx)(ej.Z,{})})}}),(0,s.jsx)(e_.Z,{sx:{fontSize:"0.75rem"},children:"Shared URLs are deleted after 2 weeks."})]}),(0,s.jsx)(q.Z,{children:(0,s.jsx)(D.Z,{onClick:c,color:"primary",children:"Close"})})]})};n(58022);let ts=(0,_.Z)(B.Z)(e=>{let{theme:t}=e;return{maxWidth:"100%",flexWrap:"wrap",[t.breakpoints.down("sm")]:{flexDirection:"column"}}});function tl(e){var t;let{recentEvals:n,onRecentEvalSelected:r,defaultEvalId:i}=e,c=(0,g.useRouter)(),d=(0,g.useSearchParams)(),{author:u,table:h,setTable:m,config:v,setConfig:j,maxTextLength:B,wordBreak:_,showInferenceDetails:K,evalId:G,setInComparisonMode:q,columnStates:X,setColumnState:$}=em(),{setStateFromConfig:Q}=(0,y.o)(),[ee,et]=l.useState((null==d?void 0:d.get("search"))||""),[en]=(0,Y.Nr)(ee,1e3),es=e=>{et(e)},[el,ea]=l.useState({}),er=l.useCallback((e,t)=>{ea(n=>({...n,[e]:t}))},[ea]);(0,f.Z)(h,"Table data must be loaded before rendering ResultsView");let{head:ei}=h,[eo,ed]=l.useState("all"),[eu,eh]=l.useState(!1),[ep,ev]=l.useState(""),[eg,ej]=l.useState(!1),[ef,eb]=l.useState(null),{apiShareBaseUrl:eZ}=(0,b.Z)(),ew=(0,b.Y)(),eS=G||i||"default",eN=async()=>{ej(!0);let e="";try{if(p.T){let t=await fetch("".concat(eZ,"/api/eval"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:{version:2,createdAt:new Date().toISOString(),results:{table:h},config:v}})}),{id:n}=await t.json();e="".concat(ew,"/eval/").concat(n)}else e="".concat(window.location.host,"/eval/?evalId=").concat(eS);ev(e),eh(!0)}catch(e){alert("Sorry, something went wrong.")}finally{ej(!1)}},eE=async e=>{eb(null);try{var t;let n=await (0,a.t)("/results/".concat(e),{cache:"no-store"}),s=await n.json(),l=s.data.results.table,r={head:{prompts:[...h.head.prompts.map(e=>({...e,label:"[".concat(G||i||"Eval A","] ").concat(e.label||"")})),...l.head.prompts.map(t=>({...t,label:"[".concat(e,"] ").concat(t.label||"")}))],vars:h.head.vars},body:h.body.map((e,t)=>{var n;return{...e,outputs:[...e.outputs,...(null===(n=l.body[t])||void 0===n?void 0:n.outputs)||[]]}})};m(r),j({...v,...s.data.config,description:'Combined: "'.concat((null==v?void 0:v.description)||"Eval A",'" and "').concat((null===(t=s.data.config)||void 0===t?void 0:t.description)||"Eval B",'"')}),q(!0)}catch(e){console.error("Error fetching comparison eval:",e),alert("Failed to load comparison eval. Please try again.")}},eI=l.useMemo(()=>h.body.some(e=>e.description),[h.body]),eR=ei.prompts.map((e,t)=>{let n=e.label||e.display||e.raw;return{value:"Prompt ".concat(t+1),label:"Prompt ".concat(t+1,": ").concat(n&&n.length>100?n.slice(0,100)+"...":n||""),group:"Prompts"}}),eD=l.useMemo(()=>[...eI?[{value:"description",label:"Description"}]:[],...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"})),...eR],[ei.vars,eR,eI]),[eF,eP]=l.useState(!1),[eT,eL]=l.useState(!1),eO=l.useMemo(()=>[...eI?["description"]:[],...ei.vars.map((e,t)=>"Variable ".concat(t+1)),...ei.prompts.map((e,t)=>"Prompt ".concat(t+1))],[eI,ei.vars,ei.prompts]),eA=X[eS]||{selectedColumns:[],columnVisibility:{}},eU=l.useCallback(e=>{let t={};eO.forEach(n=>{t[n]=e.includes(n)}),$(eS,{selectedColumns:e,columnVisibility:t})},[eO,$,eS]);l.useEffect(()=>{0!==eA.selectedColumns.length&&eA.selectedColumns.every(e=>eO.includes(e))||eU(eO)},[eO,eA.selectedColumns,eU]);let eW=l.useCallback(e=>{let t=Array.isArray(e.target.value)?e.target.value:e.target.value.split(",");eU(t)},[eU]),ez=async()=>{(0,f.Z)(v,"Config must be loaded before clicking its description");let e=window.prompt("Enter new description:",v.description);if(null!==e&&e!==v.description){let t={...v,description:e};try{let e=await (0,a.t)("/api/eval/".concat(G),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({config:t})});if(!e.ok)throw Error("Network response was not ok");j(t)}catch(e){console.error("Failed to update table:",e)}}},eV=async()=>{if(window.confirm("Are you sure you want to delete this evaluation?"))try{let e=await (0,a.t)("/eval/".concat(G),{method:"DELETE"});if(!e.ok)throw Error("Network response was not ok");c.push("/")}catch(e){console.error("Failed to delete evaluation:",e),alert("Failed to delete evaluation")}},[eB,eJ]=l.useState(!1),[eH,e_]=l.useState(!1),eY=async()=>{G&&(await navigator.clipboard.writeText(G),eJ(!0),setTimeout(()=>{eJ(!1)},1e3))};return(0,s.jsxs)("div",{style:{marginLeft:"1rem",marginRight:"1rem"},children:[(0,s.jsxs)(ts,{direction:"row",mb:3,spacing:1,alignItems:"center",className:"eval-header",children:[(0,s.jsxs)(R.Z,{sx:{display:"flex",alignItems:"center",width:"100%",maxWidth:250},children:[(0,s.jsx)(J.Z,{variant:"outlined",size:"small",fullWidth:!0,value:(null==v?void 0:v.description)||G||"",InputProps:{readOnly:!0,startAdornment:(0,s.jsx)(M.Z,{position:"start",children:(0,s.jsx)(E.Z,{})}),endAdornment:(0,s.jsx)(M.Z,{position:"end",children:(0,s.jsx)(Z.Z,{})})},onClick:()=>e_(!0),placeholder:"Search or select an eval...",sx:{cursor:"pointer"}}),(0,s.jsx)(ec,{open:eH,onClose:()=>e_(!1),recentEvals:n,onRecentEvalSelected:r,title:"Select an Eval"})]}),(null==v?void 0:v.description)&&G&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(H.Z,{title:"Click to copy",children:(0,s.jsx)(P.Z,{size:"small",label:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("strong",{children:"ID:"})," ",G]}),sx:{opacity:.7,cursor:"pointer"},onClick:eY})}),(0,s.jsx)(o.Z,{open:eB,autoHideDuration:1e3,onClose:()=>eJ(!1),message:"Eval id copied to clipboard"})]}),(0,s.jsx)(H.Z,{title:u?"":"Set eval author with `promptfoo config set email`",children:(0,s.jsx)(P.Z,{size:"small",label:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("strong",{children:"Author:"})," ",u||"Unknown"]}),sx:{opacity:.7}})}),Object.keys((null==v?void 0:v.tags)||{}).map(e=>{var t;return(0,s.jsx)(P.Z,{size:"small",label:"".concat(e,": ").concat(null==v?void 0:null===(t=v.tags)||void 0===t?void 0:t[e]),sx:{opacity:.7}},e)})]}),(0,s.jsxs)(ts,{direction:"row",spacing:1,alignItems:"center",children:[(0,s.jsx)(R.Z,{children:(0,s.jsxs)(T.Z,{sx:{minWidth:200,maxWidth:350},size:"small",children:[(0,s.jsx)(L.Z,{id:"visible-columns-label",children:"Columns"}),(0,s.jsx)(V.Z,{labelId:"visible-columns-label",id:"visible-columns",multiple:!0,value:eA.selectedColumns,onChange:eW,input:(0,s.jsx)(z.Z,{label:"Visible columns"}),renderValue:e=>e.join(", "),children:eD.map(e=>(0,s.jsxs)(W.Z,{dense:!0,value:e.value,children:[(0,s.jsx)(F.Z,{checked:eA.selectedColumns.includes(e.value)}),(0,s.jsx)(A.Z,{primary:e.label})]},e.value))})]})}),(0,s.jsx)(R.Z,{children:(0,s.jsxs)(T.Z,{sx:{minWidth:180},size:"small",children:[(0,s.jsx)(L.Z,{id:"failure-filter-mode-label",children:"Display"}),(0,s.jsxs)(V.Z,{labelId:"filter-mode-label",id:"filter-mode",value:eo,onChange:e=>{let t=e.target.value;ed(t);let n={};ei.prompts.forEach((e,s)=>{n["Prompt ".concat(s+1)]="failures"===t}),ea(n)},label:"Filter",children:[(0,s.jsx)(W.Z,{value:"all",children:"Show all results"}),(0,s.jsx)(W.Z,{value:"failures",children:"Show failures only"}),(0,s.jsx)(W.Z,{value:"different",children:"Show different only"}),(0,s.jsx)(W.Z,{value:"highlights",children:"Show highlights only"})]})]})}),(0,s.jsx)(R.Z,{children:(0,s.jsx)(J.Z,{sx:{minWidth:180},size:"small",label:"Search",placeholder:"Text or regex",value:ee,onChange:e=>es(e.target.value)})}),(0,s.jsx)(R.Z,{flexGrow:1}),(0,s.jsx)(R.Z,{display:"flex",justifyContent:"flex-end",children:(0,s.jsxs)(ts,{direction:"row",spacing:2,children:[(0,s.jsx)(D.Z,{color:"primary",onClick:e=>{eb(e.currentTarget)},startIcon:(0,s.jsx)(Z.Z,{}),children:"Eval actions"}),v&&(0,s.jsxs)(U.Z,{id:"eval-actions-menu",anchorEl:ef,keepMounted:!0,open:!!ef,onClose:()=>{eb(null)},children:[(0,s.jsx)(H.Z,{title:"Edit the name of this eval",placement:"left",children:(0,s.jsxs)(W.Z,{onClick:ez,children:[(0,s.jsx)(O.Z,{children:(0,s.jsx)(C.Z,{fontSize:"small"})}),"Edit name"]})}),(0,s.jsx)(H.Z,{title:"Edit this eval in the web UI",placement:"left",children:(0,s.jsxs)(W.Z,{onClick:()=>{Q(v),c.push("/setup/")},children:[(0,s.jsx)(O.Z,{children:(0,s.jsx)(k.Z,{fontSize:"small"})}),"Edit and re-run"]})}),(0,s.jsx)(ex,{initialEvals:n,onComparisonEvalSelected:eE}),(0,s.jsx)(H.Z,{title:"View the configuration that defines this eval",placement:"left",children:(0,s.jsxs)(W.Z,{onClick:()=>eP(!0),children:[(0,s.jsx)(O.Z,{children:(0,s.jsx)(I.Z,{fontSize:"small"})}),"View YAML"]})}),(0,s.jsx)(eC,{}),(null==v?void 0:v.sharing)&&(0,s.jsx)(H.Z,{title:"Generate a unique URL that others can access",placement:"left",children:(0,s.jsxs)(W.Z,{onClick:eN,disabled:eg,children:[(0,s.jsx)(O.Z,{children:eg?(0,s.jsx)(x.Z,{size:16}):(0,s.jsx)(N.Z,{fontSize:"small"})}),"Share"]})}),(0,s.jsx)(H.Z,{title:"Delete this eval",placement:"left",children:(0,s.jsxs)(W.Z,{onClick:eV,children:[(0,s.jsx)(O.Z,{children:(0,s.jsx)(w.Z,{fontSize:"small"})}),"Delete"]})})]}),(0,s.jsx)(H.Z,{title:"Edit table view settings",placement:"bottom",children:(0,s.jsx)(D.Z,{color:"primary",onClick:()=>eL(!0),startIcon:(0,s.jsx)(S.Z,{}),children:"Table Settings"})}),((null==v?void 0:v.redteam)||(null==v?void 0:null===(t=v.metadata)||void 0===t?void 0:t.redteam))&&(0,s.jsx)(H.Z,{title:"View vulnerability scan report",placement:"bottom",children:(0,s.jsx)(D.Z,{color:"primary",variant:"contained",startIcon:(0,s.jsx)(I.Z,{}),onClick:()=>c.push("/report/?evalId=".concat(G||i)),children:"Vulnerability Report"})})]})})]}),(0,s.jsx)(eM,{columnVisibility:eA.columnVisibility}),(0,s.jsx)(e9,{maxTextLength:B,columnVisibility:eA.columnVisibility,wordBreak:_,showStats:K,filterMode:eo,failureFilter:el,searchText:en,onFailureFilterToggle:er,onSearchTextChange:es}),(0,s.jsx)(ey,{open:eF,onClose:()=>eP(!1)}),(0,s.jsx)(tn,{open:eu,onClose:()=>eh(!1),shareUrl:ep}),(0,s.jsx)(tt,{open:eT,onClose:()=>eL(!1)}),(0,s.jsx)(ek,{recentEvals:n,onRecentEvalSelected:r})]})}async function ta(){let e=(0,v.createClientComponentClient)(),{data:{user:t}}=await e.auth.getUser();(0,f.Z)(t,"User not logged in");let{data:n}=await e.from("EvaluationResult").select("id, createdAt").eq("user_id",t.id).order("createdAt",{ascending:!1}).limit(100);return n||[]}async function tr(e){let t=(0,v.createClientComponentClient)(),{data:n}=await t.from("EvaluationResult").select("*").eq("id",e).single();return n}function ti(e){var t;let{fetchId:n,preloadedData:r,recentEvals:o,defaultEvalId:c}=e,d=(0,g.useRouter)(),{apiBaseUrl:u}=(0,m.Z)(),{table:v,setTable:y,config:b,setConfig:Z,evalId:w,setEvalId:C,setAuthor:k,setInComparisonMode:S}=em(),[N,E]=l.useState(!1),[I,R]=l.useState(!1),[D,F]=l.useState(o||[]),P=async()=>{let e=await (0,a.t)("/results",{cache:"no-store"});if(!e.ok){R(!0);return}let t=await e.json();return F(t.data),t.data},T=l.useCallback(async e=>{let t=await (0,a.t)("/results/".concat(e),{cache:"no-store"}),n=await t.json();y(n.data.results.table),Z(n.data.config),k(n.data.author),C(e)},[y,Z,C,k]),M=async e=>{p.O?(E(!1),d.push("/eval/remote:".concat(encodeURIComponent(e)))):d.push("/eval/?evalId=".concat(encodeURIComponent(e)))},[L,O]=l.useState(c||(null===(t=D[0])||void 0===t?void 0:t.evalId)),A=(0,g.useSearchParams)(),U=A?A.get("evalId"):null;return(l.useEffect(()=>{let e=U||n;if(e){console.log("Eval init: Fetching eval by id",{searchEvalId:U,fetchId:n});let t=async()=>{await T(e),E(!0),O(e),P()};t()}else if(r){var t;console.log("Eval init: Using preloaded data"),y(null===(t=r.data.results)||void 0===t?void 0:t.table),Z(r.data.config),k(r.data.author||null),E(!0)}else if(p.T){console.log("Eval init: Using local server websocket");let e=(0,j.io)(u||"");return e.on("init",e=>{console.log("Initialized socket connection",e),E(!0),y(null==e?void 0:e.results.table),Z(null==e?void 0:e.config),k((null==e?void 0:e.author)||null),P().then(e=>{if(e&&e.length>0){var t,n,s;O(null===(t=e[0])||void 0===t?void 0:t.evalId),C(null===(n=e[0])||void 0===n?void 0:n.evalId),console.log("setting default eval id",null===(s=e[0])||void 0===s?void 0:s.evalId)}})}),e.on("update",e=>{console.log("Received data update",e),y(e.results.table),Z(e.config),k(e.author||null),P().then(e=>{if(e&&e.length>0){var t;let n=null===(t=e[0])||void 0===t?void 0:t.evalId;n&&(O(n),C(n))}})}),()=>{e.disconnect()}}else if(p.O)console.log("Eval init: Using Supabase"),ta().then(e=>{F(e.map(e=>({evalId:e.id,datasetId:null,label:e.createdAt,createdAt:new Date(e.createdAt).getTime(),description:"None",numTests:-1}))),e.length>0&&tr(e[0].id).then(t=>{(0,f.Z)(t,"Eval not found");let n=t.results,s=t.config;O(e[0].id),y(n.table),Z(s),k(null),E(!0)})});else{console.log("Eval init: Fetching eval via recent");let e=async()=>{let e=await P();if(!e||!(e.length>0))return(0,s.jsx)("div",{className:"notice",children:"No evals yet. Share some evals to this server and they will appear here."});{let t=e[0].evalId,n=await (0,a.t)("/results/".concat(t)),s=await n.json();y(s.data.results.table),Z(s.data.config),k(s.data.author||null),E(!0),O(t),C(t)}};e()}S(!1)},[u,n,y,Z,k,C,T,r,O,U,S]),l.useEffect(()=>{document.title="".concat((null==b?void 0:b.description)||w||"Eval"," | promptfoo")},[b,w]),I)?(0,s.jsx)("div",{className:"notice",children:"404 Eval not found"}):N&&v?(0,s.jsx)(h,{children:(0,s.jsx)(i,{children:(0,s.jsx)(tl,{defaultEvalId:L,recentEvals:D,onRecentEvalSelected:M})})}):(0,s.jsxs)("div",{className:"notice",children:[(0,s.jsx)("div",{children:(0,s.jsx)(x.Z,{size:22})}),(0,s.jsx)("div",{children:"Waiting for eval data"})]})}n(94455)},52428:function(e,t,n){"use strict";n.d(t,{O:function(){return a},T:function(){return l}});var s=n(77580);let l=!s.env.NEXT_PUBLIC_HOSTED,a=!!s.env.NEXT_PUBLIC_PROMPTFOO_USE_SUPABASE},82911:function(e,t,n){"use strict";var s=n(94660),l=n(74810);let a=(0,s.Ue)()((0,l.tJ)(e=>({apiBaseUrl:"",setApiBaseUrl:t=>e({apiBaseUrl:t}),fetchingPromise:null,setFetchingPromise:t=>e({fetchingPromise:t})}),{name:"api-config-storage",partialize:e=>({apiBaseUrl:e.apiBaseUrl})}));t.Z=a},47887:function(e,t,n){"use strict";n.d(t,{o:function(){return a}});var s=n(94660),l=n(74810);let a=(0,s.Ue)()((0,l.tJ)((e,t)=>({env:{},testCases:[],description:"",providers:[],prompts:[],defaultTest:{},evaluateOptions:{},scenarios:[],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}),setDefaultTest:t=>e({defaultTest:t}),setEvaluateOptions:t=>e({evaluateOptions:t}),setScenarios:t=>e({scenarios: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=>"string"==typeof e&&!e.endsWith(".txt")&&!e.endsWith(".json")&&!e.endsWith(".yaml")):console.warn("Invalid prompts config",t.prompts)),t.defaultTest&&(n.defaultTest=t.defaultTest),t.evaluateOptions&&(n.evaluateOptions=t.evaluateOptions),t.scenarios&&(n.scenarios=t.scenarios),e(n)},getTestSuite:()=>{let{description:e,testCases:n,providers:s,prompts:l,env:a,scenarios:r}=t();return{env:a,description:e,providers:s,prompts:l,tests:n,scenarios:r}}}),{name:"promptfoo",skipHydration:!0}))},88270:function(e,t,n){"use strict";n.d(t,{Y:function(){return r}});var s=n(94660),l=n(74810);let a=(0,s.Ue)()((0,l.tJ)(e=>({apiShareBaseUrl:"https://api.promptfoo.dev",setApiShareBaseUrl:t=>e({apiShareBaseUrl:t}),appShareBaseUrl:"https://app.promptfoo.dev",setAppShareBaseUrl:t=>e({appShareBaseUrl:t})}),{name:"share-config-storage"}));function r(){let{appShareBaseUrl:e}=a();return e||"".concat(window.location.protocol,"//").concat(window.location.host)}t.Z=a},55974:function(){},94455:function(){},16658:function(){},93207:function(){},58022:function(){}}]);
@@ -1 +1 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[185],{84173:function(e,t,r){Promise.resolve().then(r.bind(r,72403)),Promise.resolve().then(r.t.bind(r,5100,23)),Promise.resolve().then(r.t.bind(r,65246,23))},72403:function(e,t,r){"use strict";r.r(t),r.d(t,{PageShell:function(){return ee}});var n=r(24004),o=r(14978),a=r(52428),s=r(26647),i=r(14819),l=r(52653),c=r(78276),u=r(13457),h=r(38640),d=r.n(h),p=r(28891),f=r(82911),x=r(88270),g=r(89394),m=r(91797),j=r(26337),b=r(43226),v=r(21975),Z=r(42834),S=r(49050);function C(e){let{open:t,onClose:r}=e,{apiBaseUrl:a,setApiBaseUrl:s}=(0,f.Z)(),{apiShareBaseUrl:i,setApiShareBaseUrl:l,appShareBaseUrl:c,setAppShareBaseUrl:u}=(0,x.Z)(),[h,d]=(0,o.useState)(a||""),[p,C]=(0,o.useState)(i||""),[k,E]=(0,o.useState)(c||"");return(0,o.useEffect)(()=>{d(a||""),C(i||""),E(c||"")},[a,i,c]),(0,n.jsxs)(g.Z,{open:t,onClose:r,maxWidth:"xs",fullWidth:!0,"aria-labelledby":"api-settings-dialog-title",children:[(0,n.jsx)(m.Z,{id:"api-settings-dialog-title",children:"API and Sharing Settings"}),(0,n.jsxs)(j.Z,{children:[(0,n.jsx)(b.Z,{variant:"h6",children:"API"}),(0,n.jsx)(v.Z,{label:"API Base URL",helperText:"The promptfoo API the webview will connect to",value:h,onChange:e=>{d(e.target.value)},fullWidth:!0,margin:"normal"}),(0,n.jsx)(b.Z,{variant:"h6",children:"Sharing"}),(0,n.jsx)(v.Z,{label:"API Share Base URL",helperText:'Where to send the eval when you click "Share"',value:p,onChange:e=>{C(e.target.value)},fullWidth:!0,margin:"normal"}),(0,n.jsx)(v.Z,{label:"App Share Base URL",helperText:"Set this to the App URL for the promptfoo instance you send shared evals to",value:k,onChange:e=>{E(e.target.value)},fullWidth:!0,margin:"normal"})]}),(0,n.jsxs)(Z.Z,{children:[(0,n.jsx)(S.Z,{onClick:()=>{s(h),l(p),u(k),r()},children:"Save"}),(0,n.jsx)(S.Z,{onClick:r,children:"Close"})]})]})}var k=r(39864),E=r(47028);function P(e){let{darkMode:t,onToggleDarkMode:r}=e;return(0,n.jsx)("div",{className:"dark-mode-toggle",onClick:r,children:t?(0,n.jsx)(k.Z,{}):(0,n.jsx)(E.Z,{})})}r(32854);var w=r(58715),y=r(61443),O=r(14089),I=r(68452),U=r(91018),_=r(25210);let B=[{icon:(0,n.jsx)(U.Z,{fontSize:"small"}),text:"Documentation",href:"https://www.promptfoo.dev/docs/intro"},{icon:(0,n.jsx)(I.Z,{fontSize:"small"}),text:"GitHub Repository",href:"https://github.com/promptfoo/promptfoo"},{icon:(0,n.jsx)(w.Z,{fontSize:"small"}),text:"File an Issue",href:"https://github.com/promptfoo/promptfoo/issues"},{icon:(0,n.jsx)(O.Z,{fontSize:"small"}),text:"Join Our Discord Community",href:"https://discord.gg/gHPS9jjfbs"},{icon:(0,n.jsx)(y.Z,{fontSize:"small"}),text:"Book a Meeting",href:"https://cal.com/team/promptfoo/intro"}];function F(e){let{open:t,onClose:r}=e;return(0,n.jsxs)(g.Z,{open:t,onClose:r,maxWidth:"xs",fullWidth:!0,"aria-labelledby":"about-promptfoo-dialog-title",children:[(0,n.jsx)(m.Z,{id:"about-promptfoo-dialog-title",children:(0,n.jsxs)(u.Z,{children:[(0,n.jsx)(b.Z,{variant:"h6",children:"About Promptfoo"}),(0,n.jsx)(_.Z,{href:"https://github.com/promptfoo/promptfoo/releases",underline:"none",sx:{color:"inherit"},target:"_blank",children:(0,n.jsxs)(b.Z,{variant:"subtitle2",children:["Version ","0.86.0"]})})]})}),(0,n.jsxs)(j.Z,{children:[(0,n.jsx)(b.Z,{variant:"body2",gutterBottom:!0,children:"Promptfoo is a MIT licensed open-source tool for evaluating LLMs. We make it easy to track the performance of your models and prompts over time with automated support for dataset generation and grading."}),(0,n.jsx)(u.Z,{spacing:2,mt:2,children:B.map((e,t)=>(0,n.jsxs)(u.Z,{direction:"row",spacing:1,alignItems:"center",sx:{flexWrap:"wrap","& .MuiSvgIcon-root":{color:"text.primary"}},children:[e.icon,(0,n.jsx)(_.Z,{underline:"none",target:"_blank",href:e.href,sx:{color:"inherit"},children:(0,n.jsx)(b.Z,{variant:"body2",children:e.text})})]},t))})]}),(0,n.jsx)(Z.Z,{children:(0,n.jsx)(S.Z,{onClick:r,children:"Close"})})]})}var T=r(1445),A=r(3283),M=r(33932),N=r(74309);function W(){let{user:e,logout:t}=(0,T.aC)(),[r,a]=o.useState(null),s=()=>{a(null)},i=async()=>{null==t||t(),s()};return e?(0,n.jsxs)("div",{children:[(0,n.jsx)(l.Z,{edge:"end","aria-label":"account of current user","aria-controls":"menu-appbar","aria-haspopup":"true",onClick:e=>{a(e.currentTarget)},color:"inherit",children:(0,n.jsx)(A.Z,{sx:{width:"1em",height:"1em",bgcolor:"#1976d2"}})}),(0,n.jsxs)(M.Z,{id:"menu-appbar",anchorEl:r,anchorOrigin:{vertical:"top",horizontal:"right"},keepMounted:!0,transformOrigin:{vertical:"top",horizontal:"right"},open:!!r,onClose:s,children:[(0,n.jsxs)(N.Z,{disabled:!0,children:["Logged in as ",e.email]}),(0,n.jsx)(N.Z,{onClick:i,children:"Logout"})]})]}):(0,n.jsx)(d(),{href:"/auth/signup/",children:(0,n.jsx)(l.Z,{edge:"end","aria-label":"User not logged in","aria-controls":"menu-appbar","aria-haspopup":"true",color:"inherit",children:(0,n.jsx)(A.Z,{sx:{width:"1em",height:"1em"}})})})}var R=r(79245),L=r(47051),D=r.n(L);function z(){return(0,n.jsx)(d(),{href:"https://promptfoo.dev",passHref:!0,children:(0,n.jsxs)(R.Z,{className:"logo",component:"a",children:[(0,n.jsx)(D(),{width:25,height:25,src:"/logo-panda.svg",alt:"Promptfoo logo"})," ",(0,n.jsx)("span",{children:"promptfoo"})]})})}r(17328),r(5008);var H=r(77580);function G(e){let{href:t,label:r}=e,o=(0,p.usePathname)()||"";return(0,n.jsx)(d(),{href:t,className:o.startsWith(t)?"active":"",children:r})}function J(e){let{darkMode:t,onToggleDarkMode:r}=e,[h,d]=(0,o.useState)(!1),[p,f]=(0,o.useState)(!1),x=()=>d(e=>!e),g=()=>f(e=>!e),m=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(z,{}),!H.env.NEXT_PUBLIC_NO_BROWSING&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(G,{href:"/setup",label:"New Eval"}),(0,n.jsx)(G,{href:"/eval",label:"Evals"}),(0,n.jsx)(G,{href:"/prompts",label:"Prompts"}),(0,n.jsx)(G,{href:"/datasets",label:"Datasets"}),(0,n.jsx)(G,{href:"/progress",label:"Progress"})]}),(0,n.jsxs)("div",{className:"right-aligned",children:[a.O?(0,n.jsx)(W,{}):null,(0,n.jsx)(l.Z,{onClick:x,sx:{color:"#f0f0f0"},children:(0,n.jsx)(i.Z,{})}),a.T&&(0,n.jsx)(c.Z,{title:"API and Sharing Settings",children:(0,n.jsx)(l.Z,{onClick:g,sx:{color:"#f0f0f0"},children:(0,n.jsx)(s.Z,{})})}),(0,n.jsx)(P,{darkMode:t,onToggleDarkMode:r})]})]});return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(F,{open:h,onClose:x}),(0,n.jsx)(C,{open:p,onClose:g}),(0,n.jsx)(u.Z,{direction:"row",spacing:2,className:"nav",children:m})]})}var X=r(30606),V=r(33948),Y=r(42714);r(70894);let Q=e=>(0,X.Z)({typography:{fontFamily:"inherit"},palette:{mode:e?"dark":"light",background:{default:"#ffffff"}},components:{MuiCard:{styleOverrides:{root:{backgroundColor:e?"#121212":"#fff",boxShadow:e?"none":"0 2px 3px rgba(0, 0, 0, 0.1)",borderRadius:"12px"}}},MuiTableContainer:{styleOverrides:{root:{backgroundColor:e?"#121212":"#fff",boxShadow:e?"none":"0 2px 3px rgba(0, 0, 0, 0.1)",borderRadius:"12px"}}},MuiTableHead:{styleOverrides:{root:{backgroundColor:e?"#1E1E1E":"#F5F5F5"}}},MuiTableCell:{styleOverrides:{head:{backgroundColor:"inherit",color:e?"#FFFFFF":"#000000",fontWeight:"bold"},stickyHeader:{backgroundColor:e?"#1E1E1E":"#F5F5F5"}}},MuiInputBase:{styleOverrides:{root:{backgroundColor:e?"#333":"#fff"}}}}}),q=Q(!1),K=Q(!0);function $(e){let{children:t}=e;return(0,n.jsx)("div",{children:t})}function ee(e){let{children:t}=e,r=(0,Y.Z)("(prefers-color-scheme: dark)"),[a,s]=(0,o.useState)(null);(0,o.useEffect)(()=>{let e=localStorage.getItem("darkMode");s(null===e?r:"true"===e)},[r]);let i=(0,o.useCallback)(()=>{s(e=>{let t=!e;return localStorage.setItem("darkMode",String(t)),t})},[]);return((0,o.useEffect)(()=>{null!==a&&(a?document.documentElement.setAttribute("data-theme","dark"):document.documentElement.removeAttribute("data-theme"))},[a]),null===a)?null:(0,n.jsx)(V.Z,{theme:a?K:q,children:(0,n.jsx)(T.Ho,{children:(0,n.jsxs)($,{children:[(0,n.jsx)(J,{darkMode:a,onToggleDarkMode:i}),(0,n.jsx)("div",{children:t})]})})})}},52428:function(e,t,r){"use strict";r.d(t,{O:function(){return a},T:function(){return o}});var n=r(77580);let o=!n.env.NEXT_PUBLIC_HOSTED,a=!!n.env.NEXT_PUBLIC_PROMPTFOO_USE_SUPABASE},82911:function(e,t,r){"use strict";var n=r(94660),o=r(74810);let a=(0,n.Ue)()((0,o.tJ)(e=>({apiBaseUrl:"",setApiBaseUrl:t=>e({apiBaseUrl:t}),fetchingPromise:null,setFetchingPromise:t=>e({fetchingPromise:t})}),{name:"api-config-storage",partialize:e=>({apiBaseUrl:e.apiBaseUrl})}));t.Z=a},88270:function(e,t,r){"use strict";r.d(t,{Y:function(){return s}});var n=r(94660),o=r(74810);let a=(0,n.Ue)()((0,o.tJ)(e=>({apiShareBaseUrl:"https://api.promptfoo.dev",setApiShareBaseUrl:t=>e({apiShareBaseUrl:t}),appShareBaseUrl:"https://app.promptfoo.dev",setAppShareBaseUrl:t=>e({appShareBaseUrl:t})}),{name:"share-config-storage"}));function s(){let{appShareBaseUrl:e}=a();return e||"".concat(window.location.protocol,"//").concat(window.location.host)}t.Z=a},1445:function(e,t,r){"use strict";r.d(t,{Ho:function(){return h},OQ:function(){return s},aC:function(){return l}});var n=r(24004),o=r(14978),a=r(12594);let s=(0,a.createClientComponentClient)(),i=(0,o.createContext)({}),l=()=>(0,o.useContext)(i),c=(e,t)=>s.auth.signInWithPassword({email:e,password:t}),u=()=>s.auth.signOut(),h=e=>{let{children:t}=e,[r,a]=(0,o.useState)(null),[l,h]=(0,o.useState)(!1),d=(0,o.useCallback)(async()=>{let{data:e}=await s.auth.refreshSession();e&&a(e.user)},[]);return(0,o.useEffect)(()=>{d();let{data:e}=s.auth.onAuthStateChange(async(e,t)=>{"PASSWORD_RECOVERY"==e?h(!1):"SIGNED_IN"===e&&t?(a(t.user),h(!0)):"SIGNED_OUT"===e&&(h(!1),a(null))});return()=>{e.subscription.unsubscribe()}},[d]),(0,n.jsx)(i.Provider,{value:{loggedIn:l,user:r,login:c,logout:u},children:t})}},32854:function(){},17328:function(){},5008:function(){},70894:function(){},5100:function(){}},function(e){e.O(0,[906,640,461,88,113,975,132,189,470,730,744],function(){return e(e.s=84173)}),_N_E=e.O()}]);
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[185],{84173:function(e,t,r){Promise.resolve().then(r.bind(r,72403)),Promise.resolve().then(r.t.bind(r,5100,23)),Promise.resolve().then(r.t.bind(r,65246,23))},72403:function(e,t,r){"use strict";r.r(t),r.d(t,{PageShell:function(){return ee}});var n=r(24004),o=r(14978),a=r(52428),s=r(26647),i=r(14819),l=r(52653),c=r(78276),u=r(13457),h=r(38640),d=r.n(h),p=r(28891),f=r(82911),x=r(88270),g=r(89394),m=r(91797),j=r(26337),b=r(43226),v=r(21975),Z=r(42834),S=r(49050);function C(e){let{open:t,onClose:r}=e,{apiBaseUrl:a,setApiBaseUrl:s}=(0,f.Z)(),{apiShareBaseUrl:i,setApiShareBaseUrl:l,appShareBaseUrl:c,setAppShareBaseUrl:u}=(0,x.Z)(),[h,d]=(0,o.useState)(a||""),[p,C]=(0,o.useState)(i||""),[k,E]=(0,o.useState)(c||"");return(0,o.useEffect)(()=>{d(a||""),C(i||""),E(c||"")},[a,i,c]),(0,n.jsxs)(g.Z,{open:t,onClose:r,maxWidth:"xs",fullWidth:!0,"aria-labelledby":"api-settings-dialog-title",children:[(0,n.jsx)(m.Z,{id:"api-settings-dialog-title",children:"API and Sharing Settings"}),(0,n.jsxs)(j.Z,{children:[(0,n.jsx)(b.Z,{variant:"h6",children:"API"}),(0,n.jsx)(v.Z,{label:"API Base URL",helperText:"The promptfoo API the webview will connect to",value:h,onChange:e=>{d(e.target.value)},fullWidth:!0,margin:"normal"}),(0,n.jsx)(b.Z,{variant:"h6",children:"Sharing"}),(0,n.jsx)(v.Z,{label:"API Share Base URL",helperText:'Where to send the eval when you click "Share"',value:p,onChange:e=>{C(e.target.value)},fullWidth:!0,margin:"normal"}),(0,n.jsx)(v.Z,{label:"App Share Base URL",helperText:"Set this to the App URL for the promptfoo instance you send shared evals to",value:k,onChange:e=>{E(e.target.value)},fullWidth:!0,margin:"normal"})]}),(0,n.jsxs)(Z.Z,{children:[(0,n.jsx)(S.Z,{onClick:()=>{s(h),l(p),u(k),r()},children:"Save"}),(0,n.jsx)(S.Z,{onClick:r,children:"Close"})]})]})}var k=r(39864),E=r(47028);function P(e){let{darkMode:t,onToggleDarkMode:r}=e;return(0,n.jsx)("div",{className:"dark-mode-toggle",onClick:r,children:t?(0,n.jsx)(k.Z,{}):(0,n.jsx)(E.Z,{})})}r(32854);var w=r(58715),y=r(61443),O=r(14089),I=r(68452),U=r(91018),_=r(25210);let B=[{icon:(0,n.jsx)(U.Z,{fontSize:"small"}),text:"Documentation",href:"https://www.promptfoo.dev/docs/intro"},{icon:(0,n.jsx)(I.Z,{fontSize:"small"}),text:"GitHub Repository",href:"https://github.com/promptfoo/promptfoo"},{icon:(0,n.jsx)(w.Z,{fontSize:"small"}),text:"File an Issue",href:"https://github.com/promptfoo/promptfoo/issues"},{icon:(0,n.jsx)(O.Z,{fontSize:"small"}),text:"Join Our Discord Community",href:"https://discord.gg/gHPS9jjfbs"},{icon:(0,n.jsx)(y.Z,{fontSize:"small"}),text:"Book a Meeting",href:"https://cal.com/team/promptfoo/intro"}];function F(e){let{open:t,onClose:r}=e;return(0,n.jsxs)(g.Z,{open:t,onClose:r,maxWidth:"xs",fullWidth:!0,"aria-labelledby":"about-promptfoo-dialog-title",children:[(0,n.jsx)(m.Z,{id:"about-promptfoo-dialog-title",children:(0,n.jsxs)(u.Z,{children:[(0,n.jsx)(b.Z,{variant:"h6",children:"About Promptfoo"}),(0,n.jsx)(_.Z,{href:"https://github.com/promptfoo/promptfoo/releases",underline:"none",sx:{color:"inherit"},target:"_blank",children:(0,n.jsxs)(b.Z,{variant:"subtitle2",children:["Version ","0.87.0"]})})]})}),(0,n.jsxs)(j.Z,{children:[(0,n.jsx)(b.Z,{variant:"body2",gutterBottom:!0,children:"Promptfoo is a MIT licensed open-source tool for evaluating LLMs. We make it easy to track the performance of your models and prompts over time with automated support for dataset generation and grading."}),(0,n.jsx)(u.Z,{spacing:2,mt:2,children:B.map((e,t)=>(0,n.jsxs)(u.Z,{direction:"row",spacing:1,alignItems:"center",sx:{flexWrap:"wrap","& .MuiSvgIcon-root":{color:"text.primary"}},children:[e.icon,(0,n.jsx)(_.Z,{underline:"none",target:"_blank",href:e.href,sx:{color:"inherit"},children:(0,n.jsx)(b.Z,{variant:"body2",children:e.text})})]},t))})]}),(0,n.jsx)(Z.Z,{children:(0,n.jsx)(S.Z,{onClick:r,children:"Close"})})]})}var T=r(1445),A=r(3283),M=r(33932),N=r(74309);function W(){let{user:e,logout:t}=(0,T.aC)(),[r,a]=o.useState(null),s=()=>{a(null)},i=async()=>{null==t||t(),s()};return e?(0,n.jsxs)("div",{children:[(0,n.jsx)(l.Z,{edge:"end","aria-label":"account of current user","aria-controls":"menu-appbar","aria-haspopup":"true",onClick:e=>{a(e.currentTarget)},color:"inherit",children:(0,n.jsx)(A.Z,{sx:{width:"1em",height:"1em",bgcolor:"#1976d2"}})}),(0,n.jsxs)(M.Z,{id:"menu-appbar",anchorEl:r,anchorOrigin:{vertical:"top",horizontal:"right"},keepMounted:!0,transformOrigin:{vertical:"top",horizontal:"right"},open:!!r,onClose:s,children:[(0,n.jsxs)(N.Z,{disabled:!0,children:["Logged in as ",e.email]}),(0,n.jsx)(N.Z,{onClick:i,children:"Logout"})]})]}):(0,n.jsx)(d(),{href:"/auth/signup/",children:(0,n.jsx)(l.Z,{edge:"end","aria-label":"User not logged in","aria-controls":"menu-appbar","aria-haspopup":"true",color:"inherit",children:(0,n.jsx)(A.Z,{sx:{width:"1em",height:"1em"}})})})}var R=r(79245),L=r(47051),D=r.n(L);function z(){return(0,n.jsx)(d(),{href:"https://promptfoo.dev",passHref:!0,children:(0,n.jsxs)(R.Z,{className:"logo",component:"a",children:[(0,n.jsx)(D(),{width:25,height:25,src:"/logo-panda.svg",alt:"Promptfoo logo"})," ",(0,n.jsx)("span",{children:"promptfoo"})]})})}r(17328),r(5008);var H=r(77580);function G(e){let{href:t,label:r}=e,o=(0,p.usePathname)()||"";return(0,n.jsx)(d(),{href:t,className:o.startsWith(t)?"active":"",children:r})}function J(e){let{darkMode:t,onToggleDarkMode:r}=e,[h,d]=(0,o.useState)(!1),[p,f]=(0,o.useState)(!1),x=()=>d(e=>!e),g=()=>f(e=>!e),m=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(z,{}),!H.env.NEXT_PUBLIC_NO_BROWSING&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(G,{href:"/setup",label:"New Eval"}),(0,n.jsx)(G,{href:"/eval",label:"Evals"}),(0,n.jsx)(G,{href:"/prompts",label:"Prompts"}),(0,n.jsx)(G,{href:"/datasets",label:"Datasets"}),(0,n.jsx)(G,{href:"/progress",label:"Progress"})]}),(0,n.jsxs)("div",{className:"right-aligned",children:[a.O?(0,n.jsx)(W,{}):null,(0,n.jsx)(l.Z,{onClick:x,sx:{color:"#f0f0f0"},children:(0,n.jsx)(i.Z,{})}),a.T&&(0,n.jsx)(c.Z,{title:"API and Sharing Settings",children:(0,n.jsx)(l.Z,{onClick:g,sx:{color:"#f0f0f0"},children:(0,n.jsx)(s.Z,{})})}),(0,n.jsx)(P,{darkMode:t,onToggleDarkMode:r})]})]});return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(F,{open:h,onClose:x}),(0,n.jsx)(C,{open:p,onClose:g}),(0,n.jsx)(u.Z,{direction:"row",spacing:2,className:"nav",children:m})]})}var X=r(30606),V=r(33948),Y=r(42714);r(70894);let Q=e=>(0,X.Z)({typography:{fontFamily:"inherit"},palette:{mode:e?"dark":"light",background:{default:"#ffffff"}},components:{MuiCard:{styleOverrides:{root:{backgroundColor:e?"#121212":"#fff",boxShadow:e?"none":"0 2px 3px rgba(0, 0, 0, 0.1)",borderRadius:"12px"}}},MuiTableContainer:{styleOverrides:{root:{backgroundColor:e?"#121212":"#fff",boxShadow:e?"none":"0 2px 3px rgba(0, 0, 0, 0.1)",borderRadius:"12px"}}},MuiTableHead:{styleOverrides:{root:{backgroundColor:e?"#1E1E1E":"#F5F5F5"}}},MuiTableCell:{styleOverrides:{head:{backgroundColor:"inherit",color:e?"#FFFFFF":"#000000",fontWeight:"bold"},stickyHeader:{backgroundColor:e?"#1E1E1E":"#F5F5F5"}}},MuiInputBase:{styleOverrides:{root:{backgroundColor:e?"#333":"#fff"}}}}}),q=Q(!1),K=Q(!0);function $(e){let{children:t}=e;return(0,n.jsx)("div",{children:t})}function ee(e){let{children:t}=e,r=(0,Y.Z)("(prefers-color-scheme: dark)"),[a,s]=(0,o.useState)(null);(0,o.useEffect)(()=>{let e=localStorage.getItem("darkMode");s(null===e?r:"true"===e)},[r]);let i=(0,o.useCallback)(()=>{s(e=>{let t=!e;return localStorage.setItem("darkMode",String(t)),t})},[]);return((0,o.useEffect)(()=>{null!==a&&(a?document.documentElement.setAttribute("data-theme","dark"):document.documentElement.removeAttribute("data-theme"))},[a]),null===a)?null:(0,n.jsx)(V.Z,{theme:a?K:q,children:(0,n.jsx)(T.Ho,{children:(0,n.jsxs)($,{children:[(0,n.jsx)(J,{darkMode:a,onToggleDarkMode:i}),(0,n.jsx)("div",{children:t})]})})})}},52428:function(e,t,r){"use strict";r.d(t,{O:function(){return a},T:function(){return o}});var n=r(77580);let o=!n.env.NEXT_PUBLIC_HOSTED,a=!!n.env.NEXT_PUBLIC_PROMPTFOO_USE_SUPABASE},82911:function(e,t,r){"use strict";var n=r(94660),o=r(74810);let a=(0,n.Ue)()((0,o.tJ)(e=>({apiBaseUrl:"",setApiBaseUrl:t=>e({apiBaseUrl:t}),fetchingPromise:null,setFetchingPromise:t=>e({fetchingPromise:t})}),{name:"api-config-storage",partialize:e=>({apiBaseUrl:e.apiBaseUrl})}));t.Z=a},88270:function(e,t,r){"use strict";r.d(t,{Y:function(){return s}});var n=r(94660),o=r(74810);let a=(0,n.Ue)()((0,o.tJ)(e=>({apiShareBaseUrl:"https://api.promptfoo.dev",setApiShareBaseUrl:t=>e({apiShareBaseUrl:t}),appShareBaseUrl:"https://app.promptfoo.dev",setAppShareBaseUrl:t=>e({appShareBaseUrl:t})}),{name:"share-config-storage"}));function s(){let{appShareBaseUrl:e}=a();return e||"".concat(window.location.protocol,"//").concat(window.location.host)}t.Z=a},1445:function(e,t,r){"use strict";r.d(t,{Ho:function(){return h},OQ:function(){return s},aC:function(){return l}});var n=r(24004),o=r(14978),a=r(12594);let s=(0,a.createClientComponentClient)(),i=(0,o.createContext)({}),l=()=>(0,o.useContext)(i),c=(e,t)=>s.auth.signInWithPassword({email:e,password:t}),u=()=>s.auth.signOut(),h=e=>{let{children:t}=e,[r,a]=(0,o.useState)(null),[l,h]=(0,o.useState)(!1),d=(0,o.useCallback)(async()=>{let{data:e}=await s.auth.refreshSession();e&&a(e.user)},[]);return(0,o.useEffect)(()=>{d();let{data:e}=s.auth.onAuthStateChange(async(e,t)=>{"PASSWORD_RECOVERY"==e?h(!1):"SIGNED_IN"===e&&t?(a(t.user),h(!0)):"SIGNED_OUT"===e&&(h(!1),a(null))});return()=>{e.subscription.unsubscribe()}},[d]),(0,n.jsx)(i.Provider,{value:{loggedIn:l,user:r,login:c,logout:u},children:t})}},32854:function(){},17328:function(){},5008:function(){},70894:function(){},5100:function(){}},function(e){e.O(0,[906,640,461,88,113,975,132,189,470,730,744],function(){return e(e.s=84173)}),_N_E=e.O()}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[420],{58004:function(e,i,t){Promise.resolve().then(t.bind(t,56129))},49532:function(e,i,t){"use strict";t.d(i,{t:function(){return s}});var a=t(82911);async function s(e){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{apiBaseUrl:t}=a.Z.getState();return fetch("".concat(t,"/api").concat(e),i)}},56129:function(e,i,t){"use strict";t.r(i),t.d(i,{default:function(){return eS}});var a,s,r=t(24004),n=t(14978),l=t(49532),o=t(79245),c=t(15133),u=t(47827),m=t(88938),d=t(35266),p=t(80356),h=t(38212),g=t(49658),f=t(13457),v=t(43226),x=t(70740),j=t(14565),y=t(48727),b=t(81344),Z=t(88469),w=t(28874),k=t(52653),C=t(8864);let R={"Security Risk":["bola","bfla","debug-access","hijacking","pii","prompt-extraction","rbac","shell-injection","sql-injection","ssrf","indirect-prompt-injection"],"Legal Risk":["contracts","harmful:child-exploitation","harmful:copyright-violations","harmful:cybercrime","harmful:hate","harmful:illegal-activities","harmful:illegal-drugs","harmful:intellectual-property","harmful:privacy","harmful:self-harm","harmful:sex-crime","harmful:sexual-content","harmful:specialized-advice","harmful:violent-crime"],"Brand Risk":["policy","competitors","excessive-agency","hallucination","harmful:graphic-content","harmful:harassment-bullying","harmful:indiscriminate-weapons","harmful:insults","harmful:misinformation-disinformation","harmful:non-violent-crime","harmful:profanity","harmful:radicalization","harmful:unsafe-practices","imitation","overreliance","politics"]},P={"Brand Risk":"Risks that can affect the brand reputation and trustworthiness.","Legal Risk":"Risks that can lead to legal consequences or violations.","Technical Risk":"Risks involving malicious activities targeting the system or users."};(a=s||(s={})).Critical="Critical",a.High="High",a.Medium="Medium",a.Low="Low";let S={"debug-access":s.High,"excessive-agency":s.Medium,"harmful:child-exploitation":s.Critical,"harmful:copyright-violations":s.Low,"harmful:cybercrime":s.Low,"harmful:graphic-content":s.Medium,"harmful:harassment-bullying":s.Low,"harmful:hate":s.Critical,"harmful:illegal-activities":s.Medium,"harmful:illegal-drugs":s.Medium,"harmful:indiscriminate-weapons":s.Medium,"harmful:insults":s.Low,"harmful:intellectual-property":s.Medium,"harmful:misinformation-disinformation":s.Medium,"harmful:non-violent-crime":s.Medium,"harmful:privacy":s.High,"harmful:profanity":s.Low,"harmful:radicalization":s.Low,"harmful:self-harm":s.Critical,"harmful:sex-crime":s.High,"harmful:sexual-content":s.Medium,"harmful:specialized-advice":s.Medium,"harmful:unsafe-practices":s.Low,"harmful:violent-crime":s.High,"prompt-injection":s.Medium,"shell-injection":s.High,"sql-injection":s.High,competitors:s.Low,contracts:s.Medium,hallucination:s.Medium,hijacking:s.High,imitation:s.Low,jailbreak:s.Medium,overreliance:s.Low,pii:s.High,politics:s.Low,rbac:s.High,policy:s.High,bola:s.High,bfla:s.High,ssrf:s.High,"indirect-prompt-injection":s.High,"prompt-extraction":s.Medium},A=Object.entries(R).reduce((e,i)=>{let[t,a]=i;return a.forEach(i=>{e[i]=t}),e},{});Object.keys(A);let I={bola:"BOLAEnforcement",bfla:"BFLAEnforcement",ssrf:"SSRFEnforcement","debug-access":"DebugAccess","excessive-agency":"ExcessiveAgency","harmful:child-exploitation":"Child Exploitation","harmful:cybercrime":"Cybercrime & Unauthorized Intrusion - Hacking and Malware","harmful:graphic-content":"Graphic & age-restricted content","harmful:harassment-bullying":"Harassment & Bullying","harmful:hate":"Hate","harmful:illegal-activities":"Illegal Activities - Fraud & scams","harmful:illegal-drugs":"Illegal Drugs","harmful:indiscriminate-weapons":"Indiscriminate Weapons","harmful:insults":"Insults and personal attacks","harmful:intellectual-property":"Intellectual Property violation","harmful:misinformation-disinformation":"Misinformation & Disinformation - Harmful lies and propaganda","harmful:non-violent-crime":"Non-Violent Crimes","harmful:privacy":"Privacy violations","harmful:profanity":"Requests containing profanity","harmful:radicalization":"Radicalization","harmful:self-harm":"Self-Harm","harmful:sex-crime":"Sex Crimes","harmful:sexual-content":"Sexual Content","harmful:specialized-advice":"Specialized Advice - Financial","harmful:unsafe-practices":"Promotion of unsafe practices","harmful:violent-crime":"Violent Crimes","harmful:chemical-biological-weapons":"Chemical & Biological Weapons","harmful:copyright-violations":"Copyright Violations - Copyrighted text","prompt-injection":"Harmful/Injection","shell-injection":"ShellInjection","sql-injection":"SqlInjection",competitors:"CompetitorEndorsement",contracts:"ContractualCommitment",hallucination:"Hallucination",hijacking:"Hijacking",imitation:"Imitation",jailbreak:"Harmful/Iterative",overreliance:"Overreliance",pii:"PIILeak",politics:"PoliticalStatement",rbac:"RbacEnforcement",policy:"PolicyViolation","indirect-prompt-injection":"IndirectPromptInjection","prompt-extraction":"PromptExtraction"},N=Object.entries(I).reduce((e,i)=>{let[t,a]=i;return e[a]=t,e},{}),F={"debug-access":"Debug Access","excessive-agency":"Excessive Agency","harmful:copyright-violations":"Copyright Violations","harmful:cybercrime":"Cybercrime","harmful:illegal-activities":"Illegal Activities","harmful:misinformation-disinformation":"Misinformation & disinformation","harmful:specialized-advice":"Specialized Advice","indirect-prompt-injection":"Indirect Prompt Injection","jailbreak:tree":"Tree-based optimization","prompt-extraction":"Prompt Extraction","prompt-injection":"Prompt Injection","shell-injection":"Shell Injection","sql-injection":"SQL Injection",basic:"Basic",bfla:"Privilege Escalation",bola:"Unauthorized Data Access",competitors:"Competitor Endorsements",contracts:"Unsupervised Contracts",crescendo:"Multi-turn",jailbreak:"Single-shot optimization",multilingual:"Multilingual",pii:"PII Leaks",policy:"Custom Policy",politics:"Political Opinions",rbac:"RBAC Enforcement",ssrf:"Malicious Resource Fetching"},M={default:"Includes common plugins",basic:"Raw attacks without any special attack strategies","ascii-smuggling":"Attempts to obfuscate malicious content using ASCII smuggling","cross-session-leak":"Checks for information sharing between unrelated sessions",multilingual:"Translates the input into low-resource languages",bola:"Broken Object Level Authorization (BOLA) tests",bfla:"Broken Function Level Authorization (BFLA) tests",ssrf:"Server-Side Request Forgery (SSRF) tests","debug-access":"Attempts to access or use debugging commands","excessive-agency":"Model taking excessive initiative or misunderstanding its capabilities","harmful:chemical-biological-weapons":"Content related to chemical or biological weapons","harmful:child-exploitation":"Content exploiting or harming children","harmful:copyright-violations":"Content violating copyright laws","harmful:cybercrime":"Content related to cybercriminal activities","harmful:graphic-content":"Displaying graphic or violent content","harmful:harassment-bullying":"Content that harasses or bullies individuals","harmful:hate":"Content that promotes hate or discrimination","harmful:illegal-activities":"Content promoting illegal activities","harmful:illegal-drugs":"Content related to illegal drug use or trade","harmful:indiscriminate-weapons":"Content related to weapons without context","harmful:insults":"Content that insults or demeans individuals","harmful:intellectual-property":"Content violating intellectual property rights","harmful:misinformation-disinformation":"Spreading false or misleading information","harmful:non-violent-crime":"Content related to non-violent criminal activities","harmful:privacy":"Content violating privacy rights","harmful:profanity":"Content containing profane or inappropriate language","harmful:radicalization":"Content that promotes radical or extremist views","harmful:self-harm":"Content that encourages self-harm or suicide","harmful:sex-crime":"Content related to sexual crimes","harmful:sexual-content":"Explicit or inappropriate sexual content","harmful:specialized-advice":"Providing advice in specialized fields without expertise","harmful:unsafe-practices":"Content promoting unsafe or harmful practices","harmful:violent-crime":"Content related to violent criminal activities","jailbreak:tree":"Tree-based jailbreak search","pii:api-db":"PII exposed through API or database","pii:direct":"Direct exposure of PII","pii:session":"PII exposed in session data","pii:social":"PII exposed through social engineering","prompt-injection":"Malicious inputs designed to manipulate the model's behavior","shell-injection":"Attempts to execute shell commands through the model","sql-injection":"Attempts to perform SQL injection attacks to manipulate database queries",base64:"Attempts to obfuscate malicious content using Base64 encoding",competitors:"Competitor mentions and endorsements",contracts:"Enters business or legal commitments without supervision",hallucination:"Model generating false or misleading information",harmful:"All harmful categories",hijacking:"Unauthorized or off-topic resource use",imitation:"Imitates people, brands, or organizations",jailbreak:"Attempts to bypass security measures through iterative prompt refinement",leetspeak:"Attempts to obfuscate malicious content using leetspeak",overreliance:"Model susceptible to relying on an incorrect user assumption or input",pii:"All PII categories",policy:"Violates a custom configured policy",politics:"Makes political statements",rbac:"Tests whether the model properly implements Role-Based Access Control (RBAC)",rot13:"Attempts to obfuscate malicious content using ROT13 encoding",crescendo:"Conversational attack strategy","prompt-extraction":"Attempts to get the model to reveal its system prompt","indirect-prompt-injection":"Evaluates how susceptible the prompt is to harmful instructions injected into the prompt"},L={"owasp:llm:01":{plugins:["harmful"],strategies:["prompt-injection","jailbreak"]},"owasp:llm:02":{plugins:["harmful","overreliance"],strategies:[]},"owasp:llm:03":{plugins:["harmful","overreliance","hallucination"],strategies:[]},"owasp:llm:06":{plugins:["harmful:privacy","pii:direct","pii:api-db","pii:session","pii:social"],strategies:["prompt-injection","jailbreak"]},"owasp:llm:07":{plugins:["rbac","bola","bfla","sql-injection","shell-injection","debug-access"],strategies:[]},"owasp:llm:08":{plugins:["excessive-agency","rbac"],strategies:[]},"owasp:llm:09":{plugins:["overreliance","hallucination"],strategies:[]}},H={"owasp:api:01":{plugins:["bola","rbac"],strategies:[]},"owasp:api:02":{plugins:["bfla","rbac"],strategies:[]},"owasp:api:03":{plugins:["excessive-agency","overreliance"],strategies:[]},"owasp:api:04":{plugins:["harmful:privacy","pii:api-db","pii:session"],strategies:[]},"owasp:api:05":{plugins:["rbac","bola","bfla"],strategies:[]},"owasp:api:06":{plugins:["harmful:misinformation-disinformation","overreliance"],strategies:[]},"owasp:api:07":{plugins:["sql-injection","shell-injection"],strategies:[]},"owasp:api:08":{plugins:["harmful:privacy","pii:api-db","pii:session"],strategies:[]},"owasp:api:09":{plugins:["overreliance","harmful:specialized-advice"],strategies:[]},"owasp:api:10":{plugins:["debug-access","harmful:privacy"],strategies:[]}},O={"nist:ai:measure:1.1":{plugins:["harmful:misinformation-disinformation","overreliance","excessive-agency"],strategies:["jailbreak","prompt-injection"]},"nist:ai:measure:1.2":{plugins:["harmful:misinformation-disinformation","overreliance","excessive-agency"],strategies:["jailbreak","prompt-injection"]},"nist:ai:measure:2.1":{plugins:["harmful:privacy","pii:api-db","pii:session","pii:direct","pii:social"],strategies:[]},"nist:ai:measure:2.2":{plugins:["harmful:privacy","pii:api-db","pii:session","pii:direct","pii:social"],strategies:[]},"nist:ai:measure:2.3":{plugins:["overreliance","excessive-agency"],strategies:[]},"nist:ai:measure:2.4":{plugins:["overreliance","excessive-agency","harmful:misinformation-disinformation"],strategies:["jailbreak","prompt-injection"]},"nist:ai:measure:2.5":{plugins:["overreliance","excessive-agency"],strategies:[]},"nist:ai:measure:2.6":{plugins:["harmful:unsafe-practices","harmful:chemical-biological-weapons","harmful:indiscriminate-weapons"],strategies:[]},"nist:ai:measure:2.7":{plugins:["harmful:cybercrime","sql-injection","shell-injection"],strategies:["jailbreak","prompt-injection"]},"nist:ai:measure:2.8":{plugins:["rbac","bola","bfla"],strategies:[]},"nist:ai:measure:2.9":{plugins:["overreliance","excessive-agency"],strategies:[]},"nist:ai:measure:2.10":{plugins:["harmful:privacy","pii:api-db","pii:session","pii:direct","pii:social"],strategies:[]},"nist:ai:measure:2.11":{plugins:["harmful:hate","harmful:harassment-bullying","harmful:insults"],strategies:[]},"nist:ai:measure:2.12":{plugins:[],strategies:[]},"nist:ai:measure:2.13":{plugins:["overreliance","excessive-agency"],strategies:[]},"nist:ai:measure:3.1":{plugins:["overreliance","excessive-agency","harmful:misinformation-disinformation"],strategies:["jailbreak","prompt-injection"]},"nist:ai:measure:3.2":{plugins:["overreliance","excessive-agency"],strategies:[]},"nist:ai:measure:3.3":{plugins:["overreliance","excessive-agency"],strategies:[]},"nist:ai:measure:4.1":{plugins:["overreliance","excessive-agency"],strategies:[]},"nist:ai:measure:4.2":{plugins:["overreliance","excessive-agency","harmful:misinformation-disinformation"],strategies:[]},"nist:ai:measure:4.3":{plugins:["overreliance","excessive-agency"],strategies:[]}},z={"mitre:atlas:reconnaissance":{plugins:["competitors","policy","rbac","prompt-extraction"],strategies:["multilingual"]},"mitre:atlas:resource-development":{plugins:["harmful:cybercrime","harmful:illegal-drugs","harmful:indiscriminate-weapons"],strategies:[]},"mitre:atlas:initial-access":{plugins:["harmful:cybercrime","sql-injection","shell-injection","ssrf","debug-access"],strategies:["jailbreak","prompt-injection","base64","leetspeak","rot13"]},"mitre:atlas:ml-attack-staging":{plugins:["overreliance","excessive-agency","hallucination","ascii-smuggling","indirect-prompt-injection"],strategies:["jailbreak","jailbreak:tree"]},"mitre:atlas:exfiltration":{plugins:["harmful:privacy","pii:api-db","pii:session","pii:direct","pii:social","indirect-prompt-injection","prompt-extraction","ascii-smuggling"],strategies:[]},"mitre:atlas:impact":{plugins:["harmful","overreliance","excessive-agency","hijacking","imitation","politics"],strategies:["crescendo"]}};[...Object.keys(L),...Object.keys(H),...Object.keys(O),...Object.keys(z)];let B={"nist:ai:measure":O,"owasp:llm":L,"owasp:api":H,"mitre:atlas":z},E={"nist:ai:measure":"NIST AI RMF","owasp:llm":"OWASP LLM Top 10","owasp:api":"OWASP API Top 10"};var T=t(37204),W=t(94660),D=t(74810);let U={getItem:async e=>await (0,T.U2)(e)||null,setItem:async(e,i)=>{await (0,T.t8)(e,i)},removeItem:async e=>{await (0,T.IV)(e)}},q=(0,W.Ue)()((0,D.tJ)(e=>({showPercentagesOnRiskCards:!1,setShowPercentagesOnRiskCards:i=>e(()=>({showPercentagesOnRiskCards:i})),pluginPassRateThreshold:1,setPluginPassRateThreshold:i=>e(()=>({pluginPassRateThreshold:i})),showComplianceSection:!1,setShowComplianceSection:i=>e(()=>({showComplianceSection:i}))}),{name:"ReportViewStorage",storage:(0,D.FL)(()=>U)}));t(59598);var V=e=>{let{categoryStats:i,strategyStats:t}=e,{pluginPassRateThreshold:a,showComplianceSection:s}=q(),[l,u]=(0,n.useState)({}),m=n.useCallback(e=>{let s=B[e];return s?Array.from(new Set(Object.entries(s).flatMap(e=>{let[s,{plugins:r,strategies:n}]=e,l=[...r,...n].filter(e=>{let s=i[e]||t[e];return s&&s.total>0&&s.pass/s.total<a});return l}))):[]},[i,t,a]),g=n.useMemo(()=>Object.entries(B).reduce((e,i)=>{let[t,a]=i,s=m(t);return e[t]=0===s.length,e},{}),[m]),f=Object.keys(g).length,R=Object.values(g).filter(Boolean).length,P=e=>{u(i=>({...i,[e]:!i[e]}))};return s?(0,r.jsx)(c.Z,{className:"framework-compliance-card",children:(0,r.jsxs)(Z.Z,{children:[(0,r.jsxs)(v.Z,{variant:"h6",mb:2,children:["Framework Compliance (",R,"/",f,")"]}),(0,r.jsx)(w.ZP,{container:!0,spacing:3,className:"framework-grid",children:Object.entries(g).map(e=>{let[i,t]=e,a=m(i),s=l[i];return(0,r.jsx)(w.ZP,{item:!0,xs:12,sm:6,md:4,children:(0,r.jsx)(c.Z,{className:"framework-item ".concat(t?"compliant":"non-compliant"),children:(0,r.jsxs)(Z.Z,{children:[(0,r.jsxs)(o.Z,{display:"flex",alignItems:"center",justifyContent:"space-between",mb:1,children:[(0,r.jsx)(v.Z,{variant:"h6",children:E[i]}),t?(0,r.jsx)(j.Z,{className:"icon-compliant"}):(0,r.jsx)(x.Z,{className:"icon-non-compliant"})]}),!t&&(0,r.jsxs)(o.Z,{children:[(0,r.jsxs)(o.Z,{display:"flex",alignItems:"center",mb:1,onClick:()=>P(i),style:{cursor:"pointer"},children:[(0,r.jsxs)(v.Z,{variant:"body2",fontWeight:"bold",children:["Non-compliant plugins: ",a.length]}),(0,r.jsx)(k.Z,{size:"small",children:s?(0,r.jsx)(y.Z,{}):(0,r.jsx)(b.Z,{})})]}),s&&(0,r.jsx)(d.Z,{dense:!0,children:a.map(e=>(0,r.jsxs)(p.ZP,{children:[(0,r.jsx)(C.Z,{children:(0,r.jsx)(x.Z,{fontSize:"small",color:"error"})}),(0,r.jsx)(h.Z,{primary:e})]},e))})]})]})})},i)})})]})}):null};t(4309);var _=e=>{let{categoryStats:i}=e,t=[s.Critical,s.High,s.Medium,s.Low],a=t.reduce((e,t)=>(e[t]=Object.keys(i).reduce((e,i)=>S[i]===t?e+1:e,0),e),{});return(0,r.jsx)(f.Z,{spacing:2,direction:{xs:"column",sm:"row"},children:t.map(e=>(0,r.jsx)(o.Z,{flex:1,children:(0,r.jsx)(c.Z,{className:"severity-card card-".concat(e.toLowerCase()),children:(0,r.jsxs)(Z.Z,{onClick:()=>window.location.hash="#table",children:[(0,r.jsx)(v.Z,{variant:"h6",gutterBottom:!0,children:e}),(0,r.jsx)(v.Z,{variant:"h4",color:"text.primary",children:a[e]}),(0,r.jsx)(v.Z,{variant:"body2",color:"text.secondary",children:"issues"})]})})},e))})},J=t(52481),G=t(6882),K=t(78276),Q=t(35193),Y=t.n(Q),$=t(21629),X=e=>{let{evalDescription:i}=e,[t,a]=(0,n.useState)(!1),[s,l]=(0,n.useState)(!1),o=async()=>{a(!0),setTimeout(async()=>{let e=document.documentElement,t=await Y()(e,{height:Math.max(e.scrollHeight,e.offsetHeight),windowHeight:document.documentElement.scrollHeight}),s=t.toDataURL("image/png"),r=new $.ZP("p","pt",[t.width,t.height]);r.addImage(s,"PNG",0,0,t.width,t.height);let n=i?"report_".concat(i.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,""),".pdf"):"report.pdf";r.save(n),a(!1)},100)};return(0,r.jsx)(K.Z,{title:"Download report as PDF",placement:"top",open:s&&!t,children:(0,r.jsx)(k.Z,{onClick:o,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),sx:{mt:"4px",position:"relative"},"aria-label":"download report",disabled:t,children:t?(0,r.jsx)(G.Z,{size:20}):(0,r.jsx)(J.Z,{})})})},ee=t(93295),ei=t(49050),et=t(89394),ea=t(42834),es=t(26337),er=t(91797),en=t(4451),el=()=>{let{showPercentagesOnRiskCards:e,setShowPercentagesOnRiskCards:i,pluginPassRateThreshold:t,setPluginPassRateThreshold:a,showComplianceSection:s,setShowComplianceSection:l}=q(),[o,c]=n.useState(!1),u=()=>{c(!1)};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(K.Z,{title:"Report Settings",placement:"top",children:(0,r.jsx)(k.Z,{onClick:()=>{c(!0)},"aria-label":"settings",children:(0,r.jsx)(ee.Z,{})})}),(0,r.jsxs)(et.Z,{open:o,onClose:u,fullWidth:!0,maxWidth:"sm",children:[(0,r.jsx)(er.Z,{children:"Report Settings"}),(0,r.jsxs)(es.Z,{children:[(0,r.jsx)(v.Z,{component:"div",sx:{padding:"16px 0"},children:(0,r.jsxs)("label",{style:{display:"flex",alignItems:"center",cursor:"pointer"},children:[(0,r.jsx)("input",{type:"checkbox",checked:s,onChange:e=>l(e.target.checked),style:{marginRight:"10px"}}),"Show compliance section (NIST, OWASP)"]})}),(0,r.jsx)(v.Z,{component:"div",sx:{padding:"16px 0"},children:(0,r.jsxs)("label",{style:{display:"flex",alignItems:"center",cursor:"pointer"},children:[(0,r.jsx)("input",{type:"checkbox",checked:e,onChange:e=>i(e.target.checked),style:{marginRight:"10px"}}),"Show percentages on risk cards"]})}),(0,r.jsxs)(v.Z,{component:"div",sx:{padding:"16px 0"},children:[(0,r.jsxs)("label",{children:["Plugin Pass Rate Threshold: ",(100*t).toFixed(0),"%"]}),(0,r.jsx)(v.Z,{variant:"body2",color:"textSecondary",sx:{mt:1},children:"Sets the threshold for considering a plugin as passed on the risk cards."}),(0,r.jsx)(en.ZP,{value:t,onChange:(e,i)=>a(i),"aria-labelledby":"plugin-pass-rate-threshold-slider",step:.05,marks:!0,min:0,max:1,valueLabelDisplay:"auto",valueLabelFormat:e=>"".concat((100*e).toFixed(0),"%")})]})]}),(0,r.jsx)(ea.Z,{children:(0,r.jsx)(ei.Z,{onClick:u,variant:"contained",color:"primary",children:"Close"})})]})]})},eo=t(48670),ec=t(64111);t(11674);var eu=e=>{let{open:i,onClose:t,category:a,failures:s,evalId:n,numPassed:l,numFailed:c}=e,u=I[a];if(!u)return console.error("[RiskCategoryDrawer] Could not load category",a),null;let m=F[a]||u,h=l+c,g=h>0?Math.round(l/h*100):0;return 0===h?(0,r.jsx)(ec.ZP,{anchor:"right",open:i,onClose:t,children:(0,r.jsxs)(o.Z,{sx:{width:500,p:2},className:"risk-category-drawer",children:[(0,r.jsx)(v.Z,{variant:"h6",gutterBottom:!0,children:m}),(0,r.jsx)(v.Z,{variant:"body1",sx:{mt:2,textAlign:"center"},children:"No tests have been run for this category."})]})}):(0,r.jsx)(ec.ZP,{anchor:"right",open:i,onClose:t,children:(0,r.jsxs)(o.Z,{sx:{width:500,p:2},className:"risk-category-drawer",children:[(0,r.jsx)(v.Z,{variant:"h6",gutterBottom:!0,children:m}),(0,r.jsxs)(o.Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2},children:[(0,r.jsxs)(o.Z,{sx:{textAlign:"center",flex:1},children:[(0,r.jsx)(v.Z,{variant:"h4",color:"primary",children:l.toString()}),(0,r.jsx)(v.Z,{variant:"body2",children:"Passed"})]}),(0,r.jsxs)(o.Z,{sx:{textAlign:"center",flex:1},children:[(0,r.jsx)(v.Z,{variant:"h4",children:h.toString()}),(0,r.jsx)(v.Z,{variant:"body2",children:"Total"})]}),(0,r.jsxs)(o.Z,{sx:{textAlign:"center",flex:1},children:[(0,r.jsx)(v.Z,{variant:"h4",color:g>=70?"success.main":"error.main",children:"".concat(g,"%")}),(0,r.jsx)(v.Z,{variant:"body2",children:"Pass Rate"})]})]}),(0,r.jsx)(ei.Z,{variant:"contained",color:"inherit",fullWidth:!0,onClick:e=>{let i="/eval/?evalId=".concat(n,"&search=").concat(encodeURIComponent("(var=".concat(u,"|metric=").concat(u,")")));e.ctrlKey||e.metaKey?window.open(i,"_blank"):window.location.href=i},children:"View All Logs"}),s.length>0?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(v.Z,{variant:"h6",className:"failed-tests-header",children:"Failed Tests"}),(0,r.jsx)(d.Z,{children:s.slice(0,5).map((e,i)=>(0,r.jsx)(p.ZP,{className:"failure-item",children:(0,r.jsxs)(o.Z,{children:[(0,r.jsx)(v.Z,{variant:"subtitle1",className:"prompt",children:function(e){try{let i=JSON.parse(e);if(Array.isArray(i)){let e=i[i.length-1];if(e.content)return e.content||"-"}}catch(e){}return e}(e.prompt)}),(0,r.jsx)(v.Z,{variant:"body2",className:"output",children:function(e){if("string"==typeof e)return e;if(Array.isArray(e)){let i=e.filter(e=>"function"===e.type);if(i.length>0)return i.map(e=>{var i,t;return"".concat(null===(i=e.function)||void 0===i?void 0:i.name,": (").concat(null===(t=e.function)||void 0===t?void 0:t.arguments,")")}).join("\n")}return JSON.stringify(e)}(e.output)})]})},i))})]}):(0,r.jsx)(o.Z,{sx:{mt:2,textAlign:"center"},children:(0,r.jsx)(v.Z,{variant:"body1",children:"All tests passed successfully"})})]})})};t(46553);var em=e=>{var i,t;let{title:a,subtitle:s,progressValue:l,numTestsPassed:u,numTestsFailed:m,testTypes:g,evalId:f,failuresByPlugin:y}=e,{showPercentagesOnRiskCards:b,pluginPassRateThreshold:k}=q(),[C,R]=n.useState(!1),[P,S]=n.useState(""),A=g.filter(e=>e.numPassed+e.numFailed>0);return 0===A.length?null:(0,r.jsx)(c.Z,{children:(0,r.jsxs)(Z.Z,{className:"risk-card-container",children:[(0,r.jsxs)(w.ZP,{container:!0,spacing:3,children:[(0,r.jsxs)(w.ZP,{item:!0,xs:12,md:6,style:{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center"},children:[(0,r.jsx)(v.Z,{variant:"h5",className:"risk-card-title",children:a}),(0,r.jsx)(v.Z,{variant:"subtitle1",color:"textSecondary",mb:2,children:s}),(0,r.jsx)(o.Z,{sx:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",width:100,height:100},children:(0,r.jsx)(eo.a,{value:l,max:100,thickness:10,arc:{startAngle:-90,endAngle:90,color:"primary.main"},text:Number.isNaN(l)?"-":"".concat(Math.round(l),"%"),sx:{width:"100%",height:"100%"}})}),(0,r.jsxs)(v.Z,{variant:"h6",className:"risk-card-issues",children:[m," failed probes"]}),(0,r.jsxs)(v.Z,{variant:"subtitle1",color:"textSecondary",className:"risk-card-tests-passed",children:[u,"/",u+m," passed"]})]}),(0,r.jsx)(w.ZP,{item:!0,xs:6,md:4,children:(0,r.jsx)(d.Z,{dense:!0,children:A.map((e,i)=>{let t=e.numPassed/(e.numPassed+e.numFailed);return(0,r.jsx)(K.Z,{title:M[e.name],placement:"left",arrow:!0,children:(0,r.jsxs)(p.ZP,{className:"risk-card-list-item",onClick:()=>{S(e.name),R(!0)},style:{cursor:"pointer"},children:[(0,r.jsx)(h.Z,{primary:F[e.name]||I[e.name],primaryTypographyProps:{variant:"body2"}}),b?(0,r.jsx)(v.Z,{variant:"body2",className:"risk-card-percentage ".concat(t>=.8?"risk-card-percentage-high":t>=.5?"risk-card-percentage-medium":"risk-card-percentage-low"),children:"".concat(Math.round(100*t),"%")}):t>=k?(0,r.jsx)(j.Z,{className:"risk-card-icon-passed"}):(0,r.jsx)(x.Z,{className:"risk-card-icon-failed"})]})},i)})})})]}),P&&(0,r.jsx)(eu,{open:C,onClose:()=>R(!1),category:P,failures:y[P]||[],evalId:f,numPassed:(null===(i=g.find(e=>e.name===P))||void 0===i?void 0:i.numPassed)||0,numFailed:(null===(t=g.find(e=>e.name===P))||void 0===t?void 0:t.numFailed)||0})]})})};t(32991);var ed=e=>{let{categoryStats:i,evalId:t,failuresByPlugin:a}=e,s=Object.keys(R).map(e=>({name:e,passed:R[e].every(e=>{var t,a;return(null===(t=i[e])||void 0===t?void 0:t.pass)===(null===(a=i[e])||void 0===a?void 0:a.total)})}));return(0,r.jsx)(f.Z,{spacing:4,children:s.map((e,s)=>{let n=e.name,l=R[n],o=l.reduce((e,t)=>{var a;return e+((null===(a=i[t])||void 0===a?void 0:a.pass)||0)},0),c=l.reduce((e,t)=>{var a;return e+((null===(a=i[t])||void 0===a?void 0:a.total)||0)},0);return(0,r.jsx)(em,{title:e.name,subtitle:P[n],progressValue:o/c*100,numTestsPassed:o,numTestsFailed:c-o,testTypes:l.map(e=>{var t,a,s,r,n;return{name:e,categoryPassed:(null===(t=i[e])||void 0===t?void 0:t.pass)===(null===(a=i[e])||void 0===a?void 0:a.total),numPassed:(null===(s=i[e])||void 0===s?void 0:s.pass)||0,numFailed:((null===(r=i[e])||void 0===r?void 0:r.total)||0)-((null===(n=i[e])||void 0===n?void 0:n.pass)||0)}}),evalId:t,failuresByPlugin:a},s)})})},ep=t(54755),eh=t(12120),eg=t(35843);t(44097);let ef=(0,eg.ZP)(ep.Z)(e=>{let{theme:i}=e;return{height:8,borderRadius:8,["&.".concat(eh.Z.colorPrimary)]:{backgroundColor:"light"===i.palette.mode?"#e0e0e0":"#424242"},["& .".concat(eh.Z.bar)]:{borderRadius:8,backgroundColor:"light"===i.palette.mode?"#ff1744":"#ff8a80"}}});var ev=e=>{let{strategyStats:i}=e,t=Object.entries(i).sort((e,i)=>(i[1].total-i[1].pass)/i[1].total-(e[1].total-e[1].pass)/e[1].total);return(0,r.jsx)(c.Z,{className:"strategy-stats-card",children:(0,r.jsxs)(Z.Z,{className:"strategy-stats-content",children:[(0,r.jsx)(v.Z,{variant:"h5",mb:2,children:"Attack success rates"}),(0,r.jsx)(o.Z,{className:"strategy-grid",children:t.map(e=>{let[i,{pass:t,total:a}]=e,s=(a-t)/a*100;return(0,r.jsxs)(o.Z,{className:"strategy-item",children:[(0,r.jsx)(v.Z,{variant:"body1",className:"strategy-name",children:F[i]||i}),(0,r.jsx)(v.Z,{variant:"body2",color:"text.secondary",className:"strategy-description",children:M[i]||""}),(0,r.jsxs)(o.Z,{display:"flex",alignItems:"center",className:"progress-container",children:[(0,r.jsx)(o.Z,{width:"100%",mr:1,children:(0,r.jsx)(ef,{variant:"determinate",value:s})}),(0,r.jsx)(o.Z,{minWidth:45,className:"fail-rate",children:(0,r.jsxs)(v.Z,{variant:"body2",color:"text.secondary",children:[s.toFixed(1),"%"]})})]}),(0,r.jsxs)(v.Z,{variant:"caption",color:"text.secondary",className:"attack-stats",children:[a-t," / ",a," attacks succeeded"]})]},i)})})]})})},ex=t(73701),ej=t(39279),ey=t(30666),eb=t(15795),eZ=t(66988),ew=t(15646),ek=t(98489),eC=t(95781);t(93091);let eR=e=>{let i=[];for(let t of Object.values(R))for(let a of t)i.push({pluginName:a,type:I[a]||a,description:M[a]||"",passRate:e[a]?(e[a].pass/e[a].total*100).toFixed(1)+"%":"N/A",passRateWithFilter:e[a]?(e[a].passWithFilter/e[a].total*100).toFixed(1)+"%":"N/A",severity:S[a]||"Unknown"});return i.sort((e,i)=>"N/A"===e.passRate?1:"N/A"===i.passRate?-1:Number.parseFloat(e.passRate)-Number.parseFloat(i.passRate))};var eP=e=>{let{evalId:i,categoryStats:t}=e,a=eR(t).filter(e=>"N/A"!==e.passRate),[s,l]=n.useState(0),[c,u]=n.useState(10),[m,d]=n.useState("asc"),[p,h]=n.useState("default"),g=e=>{let i=p===e&&"asc"===m;d(i?"desc":"asc"),h(e)};return(0,r.jsxs)(o.Z,{children:[(0,r.jsx)(v.Z,{variant:"h5",gutterBottom:!0,id:"table",children:"Vulnerabilities and Mitigations"}),(0,r.jsxs)(eb.Z,{children:[(0,r.jsxs)(ex.Z,{children:[(0,r.jsx)(eZ.Z,{children:(0,r.jsxs)(ek.Z,{children:[(0,r.jsx)(ey.Z,{children:"Type"}),(0,r.jsx)(ey.Z,{children:"Description"}),(0,r.jsx)(ey.Z,{children:(0,r.jsx)(eC.Z,{active:"passRate"===p,direction:"passRate"===p?m:"asc",onClick:()=>g("passRate"),children:"Pass rate"})}),(0,r.jsx)(ey.Z,{children:(0,r.jsx)(eC.Z,{active:"severity"===p,direction:"severity"===p?m:"asc",onClick:()=>g("severity"),children:"Severity"})}),(0,r.jsx)(ey.Z,{style:{minWidth:"275px"},children:"Actions"})]})}),(0,r.jsx)(ej.Z,{children:a.sort((e,i)=>{if("passRate"===p)return"N/A"===e.passRate?1:"N/A"===i.passRate?-1:"asc"===m?Number.parseFloat(e.passRate)-Number.parseFloat(i.passRate):Number.parseFloat(i.passRate)-Number.parseFloat(e.passRate);if("severity"===p){if("N/A"===e.passRate)return 1;if("N/A"===i.passRate)return -1;let t={Critical:4,High:3,Medium:2,Low:1};return"asc"===m?t[e.severity]-t[i.severity]:t[i.severity]-t[e.severity]}{let t={Critical:4,High:3,Medium:2,Low:1};return e.severity===i.severity?Number.parseFloat(e.passRate)-Number.parseFloat(i.passRate):t[i.severity]-t[e.severity]}}).slice(s*c,s*c+c).map((e,i)=>{let t="";if("N/A"!==e.passRate){let i=Number.parseFloat(e.passRate);t=i>=75?"pass-high":i>=50?"pass-medium":"pass-low"}return(0,r.jsxs)(ek.Z,{children:[(0,r.jsx)(ey.Z,{children:(0,r.jsx)("span",{style:{fontWeight:500},children:F[e.pluginName]||e.type})}),(0,r.jsx)(ey.Z,{children:e.description}),(0,r.jsxs)(ey.Z,{className:t,children:[(0,r.jsx)("strong",{children:e.passRate}),e.passRateWithFilter===e.passRate?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("br",{}),"(",e.passRateWithFilter," with mitigation)"]})]}),(0,r.jsx)(ey.Z,{className:"vuln-".concat(e.severity.toLowerCase()),children:e.severity}),(0,r.jsxs)(ey.Z,{style:{minWidth:270},children:[(0,r.jsx)(ei.Z,{variant:"contained",size:"small",onClick:()=>{let i=new URLSearchParams(window.location.search),t=i.get("evalId");window.location.href="/eval/?evalId=".concat(t,"&search=").concat(encodeURIComponent("(var=".concat(e.type,"|metric=").concat(e.type,")")))},children:"View logs"}),(0,r.jsx)(K.Z,{title:"Temporarily disabled while in beta, click to contact us to enable",children:(0,r.jsx)(ei.Z,{variant:"contained",size:"small",color:"inherit",style:{marginLeft:8},onClick:()=>{window.location.href="mailto:inquiries@promptfoo.dev?subject=Promptfoo%20automatic%20vulnerability%20mitigation&body=Hello%20Promptfoo%20Team,%0D%0A%0D%0AI%20am%20interested%20in%20learning%20more%20about%20the%20automatic%20vulnerability%20mitigation%20beta.%20Please%20provide%20me%20with%20more%20details.%0D%0A%0D%0A"},children:"Apply mitigation"})})]})]},i)})})]}),a.length>c&&(0,r.jsx)(ew.Z,{rowsPerPageOptions:[10,25,50],component:"div",count:a.length,rowsPerPage:c,page:s,onPageChange:(e,i)=>{l(i)},onRowsPerPageChange:e=>{u(Number.parseInt(e.target.value,10)),l(0)}})]})]})};t(67667);var eS=()=>{let[e,i]=n.useState(null),[t,a]=n.useState(null),[s,x]=n.useState(0),[j,y]=n.useState(!1),b=n.useMemo(()=>{let e={};return null==t||t.results.results.forEach(i=>{var t,a,s;let r=function(e){var i,t,a;let s=e.vars.harmCategory;if(s)return N[s];let r=(null===(t=e.gradingResult)||void 0===t?void 0:null===(i=t.componentResults)||void 0===i?void 0:i.map(e=>{var i;return null===(i=e.assertion)||void 0===i?void 0:i.metric}))||[],n=null===(a=r[0])||void 0===a?void 0:a.split("/")[0];return n?N[n]:null}(i);if(!r){console.warn("Could not get failures for plugin ".concat(r));return}!r||(null===(t=i.gradingResult)||void 0===t?void 0:t.pass)||(e[r]||(e[r]=[]),e[r].push({prompt:(null===(a=i.vars.query)||void 0===a?void 0:a.toString())||i.prompt.raw,output:null===(s=i.response)||void 0===s?void 0:s.output}))}),e},[t]);if(n.useEffect(()=>{let e=async e=>{let i=await (0,l.t)("/results/".concat(e),{cache:"no-store"}),t=await i.json();a(t.data)},t=new URLSearchParams(window.location.search);if(!t)return;let s=t.get("evalId");s&&(i(s),e(s))},[]),n.useEffect(()=>{document.title="Report: ".concat((null==t?void 0:t.config.description)||e||"Red Team"," | promptfoo")},[t,e]),!t||!e)return(0,r.jsx)(o.Z,{sx:{width:"100%",textAlign:"center"},children:"Loading..."});let Z=t.results.table.head.prompts,w=Z[s],k=t.results.table.body,C=t.results.results.reduce((e,i)=>{var t,a,s,r,n,l,o,c;let u=i.vars.harmCategory,m=(null===(a=i.gradingResult)||void 0===a?void 0:null===(t=a.componentResults)||void 0===t?void 0:t.map(e=>{var i;return null===(i=e.assertion)||void 0===i?void 0:i.metric}))||[],d=[u,...m].filter(e=>e);for(let t of d){if("string"!=typeof t)continue;let a=N[t.split("/")[0]];if(!a){console.log("Unknown harm category:",t);break}let u=null===(r=i.gradingResult)||void 0===r?void 0:null===(s=r.componentResults)||void 0===s?void 0:s.some(e=>{var i;let t=(null===(i=e.assertion)||void 0===i?void 0:i.type)==="moderation",a=e.pass;return t&&a}),m=null===(l=i.gradingResult)||void 0===l?void 0:null===(n=l.componentResults)||void 0===n?void 0:n.some(e=>{var i,t;let a=(null===(i=e.assertion)||void 0===i?void 0:i.type)==="llm-rubric"||(null===(t=e.assertion)||void 0===t?void 0:t.type.startsWith("promptfoo:redteam")),s=e.pass;return a&&s}),d=null===(c=i.gradingResult)||void 0===c?void 0:null===(o=c.componentResults)||void 0===o?void 0:o.some(e=>{var i;let t=(null===(i=e.assertion)||void 0===i?void 0:i.type)==="human",a=e.pass;return t&&a});e[a]=e[a]||{pass:0,total:0,passWithFilter:0},e[a].total++,m||d?(e[a].pass++,e[a].passWithFilter++):!u&&e[a].passWithFilter++}return e},{}),R=t.results.results.reduce((e,i)=>{var t,a,s,r;let n=(null===(a=i.gradingResult)||void 0===a?void 0:null===(t=a.componentResults)||void 0===t?void 0:t.map(e=>{var i;return null===(i=e.assertion)||void 0===i?void 0:i.metric}))||[];for(let t of n){if("string"!=typeof t)continue;let a=function(e){let i=e.split("/")[1];if(i){if("Iterative"===i)return"jailbreak";if("IterativeTree"===i)return"jailbreak:tree";if("Crescendo"===i)return"crescendo";if("Injection"===i)return"prompt-injection";else if("Rot13"===i)return"rot13";else if("Base64"===i)return"base64";else if("Leetspeak"===i)return"leetspeak";else if(i.startsWith("Multilingual"))return"multilingual"}return null}(t);a||(a="basic"),e[a]||(e[a]={pass:0,total:0}),e[a].total++;let n=null===(r=i.gradingResult)||void 0===r?void 0:null===(s=r.componentResults)||void 0===s?void 0:s.some(e=>{var i;return(null===(i=e.assertion)||void 0===i?void 0:i.metric)===t&&e.pass});n&&e[a].pass++}return e},{}),P=()=>{Z.length>1&&y(!0)},S=e=>{x(e),y(!1)};return(0,r.jsxs)(m.Z,{children:[(0,r.jsxs)(f.Z,{spacing:4,pb:8,pt:2,children:[(0,r.jsxs)(c.Z,{className:"report-header",sx:{position:"relative"},children:[(0,r.jsxs)(o.Z,{sx:{position:"absolute",top:8,right:8,display:"flex"},children:[(0,r.jsx)(X,{evalDescription:t.config.description||e}),(0,r.jsx)(el,{})]}),(0,r.jsxs)(v.Z,{variant:"h4",children:[(0,r.jsx)("strong",{children:"LLM Risk Assessment"}),t.config.description&&": ".concat(t.config.description)]}),(0,r.jsx)(v.Z,{variant:"subtitle1",mb:2,children:new Date(t.createdAt).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}),(0,r.jsxs)(o.Z,{className:"report-details",children:[(0,r.jsx)(u.Z,{size:"small",label:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("strong",{children:"Model:"})," ",w.provider]}),onClick:P,style:{cursor:Z.length>1?"pointer":"default"}}),(0,r.jsx)(u.Z,{size:"small",label:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("strong",{children:"Dataset:"})," ",k.length," probes"]})}),(0,r.jsx)(u.Z,{size:"small",label:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("strong",{children:"Prompt:"}),' "',w.raw.length>40?"".concat(w.raw.substring(0,40),"..."):w.raw,'"']}),onClick:P,style:{cursor:Z.length>1?"pointer":"default"}})]})]}),(0,r.jsx)(_,{categoryStats:C}),(0,r.jsx)(V,{categoryStats:C,strategyStats:R}),(0,r.jsx)(ev,{strategyStats:R}),(0,r.jsx)(ed,{categoryStats:C,evalId:e,failuresByPlugin:b}),(0,r.jsx)(eP,{evalId:e,categoryStats:C})]}),(0,r.jsx)(g.Z,{open:j,onClose:()=>y(!1),"aria-labelledby":"prompt-modal-title",sx:{"& .MuiModal-root":{display:"flex",alignItems:"center",justifyContent:"center"},"& .MuiBox-root":{width:"80%",maxWidth:800,maxHeight:"90vh",overflowY:"auto"}},children:(0,r.jsxs)(o.Z,{sx:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:400,bgcolor:"background.paper",boxShadow:24,p:4},children:[(0,r.jsx)(v.Z,{id:"prompt-modal-title",variant:"h6",component:"h2",gutterBottom:!0,children:"View results for..."}),(0,r.jsx)(d.Z,{children:Z.map((e,i)=>(0,r.jsx)(p.ZP,{button:!0,onClick:()=>S(i),selected:i===s,children:(0,r.jsx)(h.Z,{primary:"".concat(e.provider),secondary:e.raw.length>100?"".concat(e.raw.substring(0,100),"..."):e.raw})},i))})]})})]})}},82911:function(e,i,t){"use strict";var a=t(94660),s=t(74810);let r=(0,a.Ue)()((0,s.tJ)(e=>({apiBaseUrl:"",setApiBaseUrl:i=>e({apiBaseUrl:i}),fetchingPromise:null,setFetchingPromise:i=>e({fetchingPromise:i})}),{name:"api-config-storage",partialize:e=>({apiBaseUrl:e.apiBaseUrl})}));i.Z=r},59598:function(){},4309:function(){},67667:function(){},46553:function(){},32991:function(){},11674:function(){},44097:function(){},93091:function(){}},function(e){e.O(0,[949,799,906,461,88,113,417,874,646,167,470,730,744],function(){return e(e.s=58004)}),_N_E=e.O()}]);
@@ -1 +1 @@
1
- <!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><link rel="preload" as="font" href="/_next/static/media/a34f9d1faa5f3315-s.p.woff2" crossorigin="" type="font/woff2"/><link rel="stylesheet" href="/_next/static/css/de0307797e31a3e6.css" data-precedence="next"/><link rel="preload" href="/_next/static/chunks/webpack-452ae8c28379ed4c.js" as="script"/><link rel="preload" href="/_next/static/chunks/b6261da7-e9d81a4364ddd0c0.js" as="script"/><link rel="preload" href="/_next/static/chunks/730-3eb7255cd813a727.js" as="script"/><link rel="preload" href="/_next/static/chunks/main-app-0dc90092cd7acaaf.js" as="script"/><title>promptfoo</title><meta name="description" content="LLM testing and evaluation"/><meta name="viewport" content="width=device-width, initial-scale=1"/><meta property="og:image" content="https://www.promptfoo.dev/img/thumbnail.png"/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="https://www.promptfoo.dev/img/thumbnail.png"/><meta name="next-size-adjust"/><script src="/_next/static/chunks/polyfills-78c92fac7aa8fdd8.js" noModule=""></script></head><body class="__className_85e967"><script src="/_next/static/chunks/webpack-452ae8c28379ed4c.js" async=""></script><script src="/_next/static/chunks/b6261da7-e9d81a4364ddd0c0.js" async=""></script><script src="/_next/static/chunks/730-3eb7255cd813a727.js" async=""></script><script src="/_next/static/chunks/main-app-0dc90092cd7acaaf.js" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:HL[\"/_next/static/media/a34f9d1faa5f3315-s.p.woff2\",{\"as\":\"font\",\"type\":\"font/woff2\"}]\n2:HL[\"/_next/static/css/de0307797e31a3e6.css\",{\"as\":\"style\"}]\n0:\"$L3\"\n"])</script><script>self.__next_f.push([1,"4:I{\"id\":83507,\"chunks\":[\"272:static/chunks/webpack-452ae8c28379ed4c.js\",\"470:static/chunks/b6261da7-e9d81a4364ddd0c0.js\",\"730:static/chunks/730-3eb7255cd813a727.js\"],\"name\":\"default\",\"async\":false}\n6:I{\"id\":6020,\"chunks\":[\"272:static/chunks/webpack-452ae8c28379ed4c.js\",\"470:static/chunks/b6261da7-e9d81a4364ddd0c0.js\",\"730:static/chunks/730-3eb7255cd813a727.js\"],\"name\":\"\",\"async\":false}\n7:I{\"id\":72403,\"chunks\":[\"906:static/chunks/906-70c43cd62b2efac1.js\",\"640:static/chunks/640-0f757e2fe135173d.js\",\"461:stat"])</script><script>self.__next_f.push([1,"ic/chunks/461-77257ab6b1bb209d.js\",\"88:static/chunks/88-f3a7a858d5f4e9a0.js\",\"113:static/chunks/113-c691bf7d3a37d865.js\",\"975:static/chunks/975-db84f98b8dd028ab.js\",\"132:static/chunks/132-d6bea93785831786.js\",\"189:static/chunks/189-f9d565af9a2b91cb.js\",\"185:static/chunks/app/layout-2020c5f7a3d5d614.js\"],\"name\":\"PageShell\",\"async\":false}\n8:I{\"id\":27883,\"chunks\":[\"272:static/chunks/webpack-452ae8c28379ed4c.js\",\"470:static/chunks/b6261da7-e9d81a4364ddd0c0.js\",\"730:static/chunks/730-3eb7255cd813a727.js\"],\"name\""])</script><script>self.__next_f.push([1,":\"default\",\"async\":false}\n9:I{\"id\":46785,\"chunks\":[\"272:static/chunks/webpack-452ae8c28379ed4c.js\",\"470:static/chunks/b6261da7-e9d81a4364ddd0c0.js\",\"730:static/chunks/730-3eb7255cd813a727.js\"],\"name\":\"default\",\"async\":false}\nb:I{\"id\":92030,\"chunks\":[\"906:static/chunks/906-70c43cd62b2efac1.js\",\"640:static/chunks/640-0f757e2fe135173d.js\",\"461:static/chunks/461-77257ab6b1bb209d.js\",\"975:static/chunks/975-db84f98b8dd028ab.js\",\"132:static/chunks/132-d6bea93785831786.js\",\"716:static/chunks/app/auth/login/page-c1d"])</script><script>self.__next_f.push([1,"bf0abc580796f.js\"],\"name\":\"\",\"async\":false}\n"])</script><script>self.__next_f.push([1,"3:[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/de0307797e31a3e6.css\",\"precedence\":\"next\"}]],[\"$\",\"$L4\",null,{\"buildId\":\"esmgjQylizTs69qxSTyX7\",\"assetPrefix\":\"\",\"initialCanonicalUrl\":\"/auth/login/\",\"initialTree\":[\"\",{\"children\":[\"auth\",{\"children\":[\"login\",{\"children\":[\"__PAGE__\",{}]}]}]},\"$undefined\",\"$undefined\",true],\"initialHead\":\"$L5\",\"globalErrorComponent\":\"$6\",\"children\":[null,[\"$\",\"html\",null,{\"lang\":\"en\",\"children\":[\"$\",\"body\",null,{\"className\":\"__className_85e967\",\"children\":[\"$\",\"$L7\",null,{\"children\":[\"$\",\"$L8\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"loading\":\"$undefined\",\"loadingStyles\":\"$undefined\",\"hasLoading\":false,\"template\":[\"$\",\"$L9\",null,{}],\"templateStyles\":\"$undefined\",\"notFound\":[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],\"notFoundStyles\":\"$undefined\",\"childProp\":{\"current\":[\"$\",\"$L8\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"auth\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"loading\":\"$undefined\",\"loadingStyles\":\"$undefined\",\"hasLoading\":false,\"template\":[\"$\",\"$L9\",null,{}],\"templateStyles\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\",\"childProp\":{\"current\":[\"$\",\"$L8\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"auth\",\"children\",\"login\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"loading\":\"$undefined\",\"loadingStyles\":\"$undefined\",\"hasLoading\":false,\"template\":[\"$\",\"$L9\",null,{}],\"templateStyles\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\",\"childProp\":{\"current\":[\"$La\",[\"$\",\"$Lb\",null,{}],null],\"segment\":\"__PAGE__\"},\"styles\":[]}],\"segment\":\"login\"},\"styles\":[]}],\"segment\":\"auth\"},\"styles\":[]}]}]}]}],null]}]]\n"])</script><script>self.__next_f.push([1,"5:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"title\",\"1\",{\"children\":\"promptfoo\"}],[\"$\",\"meta\",\"2\",{\"name\":\"description\",\"content\":\"LLM testing and evaluation\"}],[\"$\",\"meta\",\"3\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}],[\"$\",\"meta\",\"4\",{\"property\":\"og:image\",\"content\":\"https://www.promptfoo.dev/img/thumbnail.png\"}],[\"$\",\"meta\",\"5\",{\"name\":\"twitter:card\",\"content\":\"summary\"}],[\"$\",\"meta\",\"6\",{\"name\":\"twitter:image\",\"content\":\"https://www.promptfoo.dev/img/thumbnail.png\"}],[\"$\",\"meta\",\"7\",{\"name\":\"next-size-adjust\"}]]\n"])</script><script>self.__next_f.push([1,"a:null\n"])</script></body></html>
1
+ <!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><link rel="preload" as="font" href="/_next/static/media/a34f9d1faa5f3315-s.p.woff2" crossorigin="" type="font/woff2"/><link rel="stylesheet" href="/_next/static/css/de0307797e31a3e6.css" data-precedence="next"/><link rel="preload" href="/_next/static/chunks/webpack-452ae8c28379ed4c.js" as="script"/><link rel="preload" href="/_next/static/chunks/b6261da7-e9d81a4364ddd0c0.js" as="script"/><link rel="preload" href="/_next/static/chunks/730-3eb7255cd813a727.js" as="script"/><link rel="preload" href="/_next/static/chunks/main-app-0dc90092cd7acaaf.js" as="script"/><title>promptfoo</title><meta name="description" content="LLM testing and evaluation"/><meta name="viewport" content="width=device-width, initial-scale=1"/><meta property="og:image" content="https://www.promptfoo.dev/img/thumbnail.png"/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="https://www.promptfoo.dev/img/thumbnail.png"/><meta name="next-size-adjust"/><script src="/_next/static/chunks/polyfills-78c92fac7aa8fdd8.js" noModule=""></script></head><body class="__className_85e967"><script src="/_next/static/chunks/webpack-452ae8c28379ed4c.js" async=""></script><script src="/_next/static/chunks/b6261da7-e9d81a4364ddd0c0.js" async=""></script><script src="/_next/static/chunks/730-3eb7255cd813a727.js" async=""></script><script src="/_next/static/chunks/main-app-0dc90092cd7acaaf.js" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:HL[\"/_next/static/media/a34f9d1faa5f3315-s.p.woff2\",{\"as\":\"font\",\"type\":\"font/woff2\"}]\n2:HL[\"/_next/static/css/de0307797e31a3e6.css\",{\"as\":\"style\"}]\n0:\"$L3\"\n"])</script><script>self.__next_f.push([1,"4:I{\"id\":83507,\"chunks\":[\"272:static/chunks/webpack-452ae8c28379ed4c.js\",\"470:static/chunks/b6261da7-e9d81a4364ddd0c0.js\",\"730:static/chunks/730-3eb7255cd813a727.js\"],\"name\":\"default\",\"async\":false}\n6:I{\"id\":6020,\"chunks\":[\"272:static/chunks/webpack-452ae8c28379ed4c.js\",\"470:static/chunks/b6261da7-e9d81a4364ddd0c0.js\",\"730:static/chunks/730-3eb7255cd813a727.js\"],\"name\":\"\",\"async\":false}\n7:I{\"id\":72403,\"chunks\":[\"906:static/chunks/906-70c43cd62b2efac1.js\",\"640:static/chunks/640-0f757e2fe135173d.js\",\"461:stat"])</script><script>self.__next_f.push([1,"ic/chunks/461-77257ab6b1bb209d.js\",\"88:static/chunks/88-f3a7a858d5f4e9a0.js\",\"113:static/chunks/113-c691bf7d3a37d865.js\",\"975:static/chunks/975-db84f98b8dd028ab.js\",\"132:static/chunks/132-d6bea93785831786.js\",\"189:static/chunks/189-f9d565af9a2b91cb.js\",\"185:static/chunks/app/layout-ad06af684889c655.js\"],\"name\":\"PageShell\",\"async\":false}\n8:I{\"id\":27883,\"chunks\":[\"272:static/chunks/webpack-452ae8c28379ed4c.js\",\"470:static/chunks/b6261da7-e9d81a4364ddd0c0.js\",\"730:static/chunks/730-3eb7255cd813a727.js\"],\"name\""])</script><script>self.__next_f.push([1,":\"default\",\"async\":false}\n9:I{\"id\":46785,\"chunks\":[\"272:static/chunks/webpack-452ae8c28379ed4c.js\",\"470:static/chunks/b6261da7-e9d81a4364ddd0c0.js\",\"730:static/chunks/730-3eb7255cd813a727.js\"],\"name\":\"default\",\"async\":false}\nb:I{\"id\":92030,\"chunks\":[\"906:static/chunks/906-70c43cd62b2efac1.js\",\"640:static/chunks/640-0f757e2fe135173d.js\",\"461:static/chunks/461-77257ab6b1bb209d.js\",\"975:static/chunks/975-db84f98b8dd028ab.js\",\"132:static/chunks/132-d6bea93785831786.js\",\"716:static/chunks/app/auth/login/page-c1d"])</script><script>self.__next_f.push([1,"bf0abc580796f.js\"],\"name\":\"\",\"async\":false}\n"])</script><script>self.__next_f.push([1,"3:[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/de0307797e31a3e6.css\",\"precedence\":\"next\"}]],[\"$\",\"$L4\",null,{\"buildId\":\"9oePeu-Q4M9r_50nf_Dh9\",\"assetPrefix\":\"\",\"initialCanonicalUrl\":\"/auth/login/\",\"initialTree\":[\"\",{\"children\":[\"auth\",{\"children\":[\"login\",{\"children\":[\"__PAGE__\",{}]}]}]},\"$undefined\",\"$undefined\",true],\"initialHead\":\"$L5\",\"globalErrorComponent\":\"$6\",\"children\":[null,[\"$\",\"html\",null,{\"lang\":\"en\",\"children\":[\"$\",\"body\",null,{\"className\":\"__className_85e967\",\"children\":[\"$\",\"$L7\",null,{\"children\":[\"$\",\"$L8\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"loading\":\"$undefined\",\"loadingStyles\":\"$undefined\",\"hasLoading\":false,\"template\":[\"$\",\"$L9\",null,{}],\"templateStyles\":\"$undefined\",\"notFound\":[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],\"notFoundStyles\":\"$undefined\",\"childProp\":{\"current\":[\"$\",\"$L8\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"auth\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"loading\":\"$undefined\",\"loadingStyles\":\"$undefined\",\"hasLoading\":false,\"template\":[\"$\",\"$L9\",null,{}],\"templateStyles\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\",\"childProp\":{\"current\":[\"$\",\"$L8\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"auth\",\"children\",\"login\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"loading\":\"$undefined\",\"loadingStyles\":\"$undefined\",\"hasLoading\":false,\"template\":[\"$\",\"$L9\",null,{}],\"templateStyles\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\",\"childProp\":{\"current\":[\"$La\",[\"$\",\"$Lb\",null,{}],null],\"segment\":\"__PAGE__\"},\"styles\":[]}],\"segment\":\"login\"},\"styles\":[]}],\"segment\":\"auth\"},\"styles\":[]}]}]}]}],null]}]]\n"])</script><script>self.__next_f.push([1,"5:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"title\",\"1\",{\"children\":\"promptfoo\"}],[\"$\",\"meta\",\"2\",{\"name\":\"description\",\"content\":\"LLM testing and evaluation\"}],[\"$\",\"meta\",\"3\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}],[\"$\",\"meta\",\"4\",{\"property\":\"og:image\",\"content\":\"https://www.promptfoo.dev/img/thumbnail.png\"}],[\"$\",\"meta\",\"5\",{\"name\":\"twitter:card\",\"content\":\"summary\"}],[\"$\",\"meta\",\"6\",{\"name\":\"twitter:image\",\"content\":\"https://www.promptfoo.dev/img/thumbnail.png\"}],[\"$\",\"meta\",\"7\",{\"name\":\"next-size-adjust\"}]]\n"])</script><script>self.__next_f.push([1,"a:null\n"])</script></body></html>