promptfoo 0.73.2 → 0.73.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package.json +5 -5
- package/dist/src/checkNodeVersion.d.ts.map +1 -1
- package/dist/src/checkNodeVersion.js +2 -3
- package/dist/src/checkNodeVersion.js.map +1 -1
- package/dist/src/commands/generate/redteam.d.ts.map +1 -1
- package/dist/src/commands/generate/redteam.js +8 -0
- package/dist/src/commands/generate/redteam.js.map +1 -1
- package/dist/src/commands/redteam.d.ts.map +1 -1
- package/dist/src/commands/redteam.js +8 -12
- package/dist/src/commands/redteam.js.map +1 -1
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +4 -5
- package/dist/src/config.js.map +1 -1
- package/dist/src/database/operations.d.ts +24 -316
- package/dist/src/database/operations.d.ts.map +1 -1
- package/dist/src/providers.d.ts.map +1 -1
- package/dist/src/providers.js +4 -0
- package/dist/src/providers.js.map +1 -1
- package/dist/src/redteam/constants.d.ts +2 -2
- package/dist/src/redteam/constants.d.ts.map +1 -1
- package/dist/src/redteam/constants.js +2 -2
- package/dist/src/redteam/constants.js.map +1 -1
- package/dist/src/redteam/index.d.ts.map +1 -1
- package/dist/src/redteam/index.js +14 -3
- package/dist/src/redteam/index.js.map +1 -1
- package/dist/src/redteam/plugins/harmful.d.ts.map +1 -1
- package/dist/src/redteam/plugins/harmful.js +29 -0
- package/dist/src/redteam/plugins/harmful.js.map +1 -1
- package/dist/src/redteam/plugins/pii.js +1 -1
- package/dist/src/redteam/plugins/pii.js.map +1 -1
- package/dist/src/redteam/providers/iterative.d.ts.map +1 -1
- package/dist/src/redteam/providers/iterative.js +11 -28
- package/dist/src/redteam/providers/iterative.js.map +1 -1
- package/dist/src/redteam/providers/iterativeTree.d.ts +24 -0
- package/dist/src/redteam/providers/iterativeTree.d.ts.map +1 -0
- package/dist/src/redteam/providers/iterativeTree.js +358 -0
- package/dist/src/redteam/providers/iterativeTree.js.map +1 -0
- package/dist/src/redteam/strategies/injections.d.ts.map +1 -1
- package/dist/src/redteam/strategies/injections.js +0 -29
- package/dist/src/redteam/strategies/injections.js.map +1 -1
- package/dist/src/redteam/strategies/iterative.d.ts +1 -1
- package/dist/src/redteam/strategies/iterative.d.ts.map +1 -1
- package/dist/src/redteam/strategies/iterative.js +7 -27
- package/dist/src/redteam/strategies/iterative.js.map +1 -1
- package/dist/src/redteam/types.d.ts +17 -0
- package/dist/src/redteam/types.d.ts.map +1 -1
- package/dist/src/redteam/types.js +4 -0
- package/dist/src/redteam/types.js.map +1 -1
- package/dist/src/types/index.d.ts +343 -10669
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/src/types/index.js +8 -12
- package/dist/src/types/index.js.map +1 -1
- package/dist/src/util/index.d.ts +16 -184
- package/dist/src/util/index.d.ts.map +1 -1
- package/dist/src/web/nextui/404/index.html +1 -1
- package/dist/src/web/nextui/404.html +1 -1
- package/dist/src/web/nextui/_next/static/chunks/325-0d36870ade5e5263.js +1 -1
- package/dist/src/web/nextui/_next/static/chunks/{497-e280a5610a3d7d42.js → 620-90f699b936fa00a2.js} +1 -1
- package/dist/src/web/nextui/_next/static/chunks/757-3a6ee77e3437bad8.js +1 -0
- package/dist/src/web/nextui/_next/static/chunks/app/auth/login/{page-6214330a95aad25c.js → page-92f9144478c53546.js} +1 -1
- package/dist/src/web/nextui/_next/static/chunks/app/auth/signup/{page-9568bbad5c19d0c0.js → page-a52bd72f4be1d8a3.js} +1 -1
- package/dist/src/web/nextui/_next/static/chunks/app/datasets/page-aa38cfddd283849f.js +1 -0
- package/dist/src/web/nextui/_next/static/chunks/app/eval/[id]/not-found-dc8b4f57fd363c1b.js +1 -0
- package/dist/src/web/nextui/_next/static/chunks/app/eval/[id]/page-3dd4578809a69719.js +1 -0
- package/dist/src/web/nextui/_next/static/chunks/app/eval/page-1cc8acdb37413a75.js +1 -0
- package/dist/src/web/nextui/_next/static/chunks/app/{layout-8c4345194197c406.js → layout-76d90600c429dc6f.js} +1 -1
- package/dist/src/web/nextui/_next/static/chunks/app/page-81e3b8fee37eaf67.js +1 -0
- package/dist/src/web/nextui/_next/static/chunks/app/progress/{page-2d90754723eb1b96.js → page-cd0150ae52aaf5ec.js} +1 -1
- package/dist/src/web/nextui/_next/static/chunks/app/prompts/page-691e0c341568a4db.js +1 -0
- package/dist/src/web/nextui/_next/static/chunks/app/report/page-0d49de07f4492d23.js +1 -0
- package/dist/src/web/nextui/_next/static/chunks/app/setup/page-bea6e3f13f5bd21d.js +1 -0
- package/dist/src/web/nextui/_next/static/chunks/main-app-ecd0bfa892b8d60b.js +1 -0
- package/dist/src/web/nextui/android-chrome-192x192.png +0 -0
- package/dist/src/web/nextui/android-chrome-512x512.png +0 -0
- package/dist/src/web/nextui/apple-touch-icon.png +0 -0
- package/dist/src/web/nextui/auth/login/index.html +1 -1
- package/dist/src/web/nextui/auth/login/index.txt +3 -3
- package/dist/src/web/nextui/auth/signup/index.html +1 -1
- package/dist/src/web/nextui/auth/signup/index.txt +3 -3
- package/dist/src/web/nextui/browserconfig.xml +9 -0
- package/dist/src/web/nextui/datasets/index.html +1 -1
- package/dist/src/web/nextui/datasets/index.txt +3 -3
- package/dist/src/web/nextui/eval/index.html +1 -1
- package/dist/src/web/nextui/eval/index.txt +3 -3
- package/dist/src/web/nextui/favicon-16x16.png +0 -0
- package/dist/src/web/nextui/favicon-32x32.png +0 -0
- package/dist/src/web/nextui/favicon.ico +0 -0
- package/dist/src/web/nextui/index.html +1 -1
- package/dist/src/web/nextui/index.txt +2 -2
- package/dist/src/web/nextui/mstile-144x144.png +0 -0
- package/dist/src/web/nextui/mstile-150x150.png +0 -0
- package/dist/src/web/nextui/mstile-310x150.png +0 -0
- package/dist/src/web/nextui/mstile-310x310.png +0 -0
- package/dist/src/web/nextui/mstile-70x70.png +0 -0
- package/dist/src/web/nextui/progress/index.html +1 -1
- package/dist/src/web/nextui/progress/index.txt +3 -3
- package/dist/src/web/nextui/prompts/index.html +1 -1
- package/dist/src/web/nextui/prompts/index.txt +3 -3
- package/dist/src/web/nextui/report/index.html +1 -1
- package/dist/src/web/nextui/report/index.txt +3 -3
- package/dist/src/web/nextui/safari-pinned-tab.svg +68 -0
- package/dist/src/web/nextui/setup/index.html +1 -1
- package/dist/src/web/nextui/setup/index.txt +3 -3
- package/dist/src/web/nextui/site.webmanifest +19 -0
- package/dist/test/providers.test.js.map +1 -1
- package/dist/test/telemetry.test.js +2 -0
- package/dist/test/telemetry.test.js.map +1 -1
- package/package.json +5 -5
- package/dist/src/web/nextui/_next/static/chunks/737-da96e7475cd51628.js +0 -1
- package/dist/src/web/nextui/_next/static/chunks/app/datasets/page-b1cc3b59d0bc97eb.js +0 -1
- package/dist/src/web/nextui/_next/static/chunks/app/eval/[id]/not-found-ce320e6d1e6d1d23.js +0 -1
- package/dist/src/web/nextui/_next/static/chunks/app/eval/[id]/page-c7d540f6b584c1ad.js +0 -1
- package/dist/src/web/nextui/_next/static/chunks/app/eval/page-86b8e9b498011d89.js +0 -1
- package/dist/src/web/nextui/_next/static/chunks/app/page-0613739abb0e8dc3.js +0 -1
- package/dist/src/web/nextui/_next/static/chunks/app/prompts/page-302f44de5b590062.js +0 -1
- package/dist/src/web/nextui/_next/static/chunks/app/report/page-53738967c111db11.js +0 -1
- package/dist/src/web/nextui/_next/static/chunks/app/setup/page-412396ae32fb0ce9.js +0 -1
- package/dist/src/web/nextui/_next/static/chunks/main-app-2984edea17efbc9d.js +0 -1
- /package/dist/src/web/nextui/_next/static/{85-O57Tjz2umr6t4Za4gW → gBi_t9qsWFfmCXpqjFt4-}/_buildManifest.js +0 -0
- /package/dist/src/web/nextui/_next/static/{85-O57Tjz2umr6t4Za4gW → gBi_t9qsWFfmCXpqjFt4-}/_ssgManifest.js +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[737],{49532:function(e,t,n){"use strict";let s,l;async function a(){if(s||(l||(l=fetch("/api/config").then(e=>e.json()).then(e=>s=e.apiBaseUrl)),await l),void 0===s)throw Error("API base URL is undefined");return s}n.d(t,{b:function(){return a}})},15737:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return tl}});var s=n(24004),l=n(14978),a=n(77580);let r=a.env.NEXT_PUBLIC_PROMPTFOO_REMOTE_API_BASE_URL||a.env.NEXT_PUBLIC_PROMPTFOO_BASE_URL||a.env.PROMPTFOO_REMOTE_API_BASE_URL||"https://api.promptfoo.dev",i=a.env.NEXT_PUBLIC_PROMPTFOO_BASE_URL||a.env.PROMPTFOO_REMOTE_APP_BASE_URL||"https://app.promptfoo.dev";a?.stdout?.columns&&a?.stdout?.columns>10&&a?.stdout?.columns;var o=n(49532);let c=(0,l.createContext)(void 0),d=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)(c.Provider,{value:n,children:t})};var u=n(22262),h=n(6363);let p=(0,l.createContext)(void 0),m=()=>{let e=(0,l.useContext)(p);if(!e)throw Error("useToast must be used within a ToastProvider");return e},x=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)(p.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)(u.Z,{open:n.open,autoHideDuration:6e3,onClose:r,children:(0,s.jsx)(h.Z,{onClose:r,severity:n.severity,children:n.message})})]})};var g=n(52428),v=n(11615),j=n(12594),f=n(28891),b=n(74997),y=n(93179),Z=n(47887),w=n(43205),C=n(5592),k=n(14931),S=n(75307),E=n(17178),I=n(42610),R=n(49567),N=n(40982),P=n(24362),F=n(885),T=n(39813),D=n(1852),M=n(57027),O=n(94941),L=n(36273),A=n(96976),U=n(8508),W=n(34304),z=n(32414),_=n(67339),V=n(65969),B=n(63147),J=n(14059),H=n(23223),K=n(94068),G=n(29794),X=n(22701),q=n(51956),Y=n(82669),$=n(37803),Q=n(65068),ee=n(70417),et=n(21303),en=n(61451),es=n(26485),el=n(30021),ea=n(32162),er=n.n(ea),ei=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)},g=a.filter(e=>er()(c.toLowerCase(),e.label.toLowerCase())||"string"==typeof e.description&&er()(c.toLowerCase(),e.description.toLowerCase())),v=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)(Y.Z,{children:i}):null,(0,s.jsxs)(q.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)(_.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,g.length-1));break;case"ArrowUp":e.preventDefault(),h(e=>Math.max(e-1,0));break;case"Enter":e.preventDefault(),u>=0&&u<g.length?v(g[u].evalId):g.length>0&&v(g[0].evalId);break;case"Escape":e.preventDefault(),x()}},sx:{mb:2},inputRef:p,id:"eval-selector-search-".concat(f)}),(0,s.jsx)(en.Z,{component:$.Z,sx:{height:"600px",overflow:"auto"},ref:m,children:(0,s.jsxs)(Q.Z,{stickyHeader:!0,children:[(0,s.jsx)(es.Z,{children:(0,s.jsxs)(el.Z,{children:[(0,s.jsx)(et.Z,{children:"Created"}),(0,s.jsx)(et.Z,{children:"Description"}),(0,s.jsx)(et.Z,{children:"# Tests"})]})}),(0,s.jsx)(ee.Z,{children:g.length>0?g.map((e,t)=>(0,s.jsxs)(el.Z,{hover:!0,onClick:()=>v(e.evalId),sx:{cursor:"pointer",backgroundColor:t===u?"rgba(255, 255, 0, 0.1)":"inherit"},children:[(0,s.jsx)(et.Z,{children:new Date(e.createdAt).toLocaleString()}),(0,s.jsx)(et.Z,{children:e.description||e.label}),(0,s.jsx)(et.Z,{children:e.numTests})]},e.evalId)):(0,s.jsx)(el.Z,{children:(0,s.jsx)(et.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)(B.Z,{variant:"h6",gutterBottom:!0,children:"No evaluations found"}),(0,s.jsx)(B.Z,{variant:"body2",children:"Try adjusting your search or create a new evaluation"})]})})})})]})})]})]}),(0,s.jsx)(X.Z,{children:(0,s.jsx)(N.Z,{onClick:x,children:"Cancel"})})]})},eo=n(37204),ec=n(79685),ed=n(74595);let eu={getItem:async e=>await (0,eo.U2)(e)||null,setItem:async(e,t)=>{await (0,eo.t8)(e,t)},removeItem:async e=>{await (0,eo.IV)(e)}},eh=(0,ec.Ue)()((0,ed.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}))}),{name:"ResultsViewStorage",storage:(0,ed.FL)(()=>eu)}));var ep=function(e){let{initialEvals:t,onComparisonEvalSelected:n}=e,{evalId:a}=eh(),[r,i]=(0,l.useState)(!1),[c,d]=(0,l.useState)(t),u=async()=>{try{let e=await (0,o.b)(),n=a||t[0].evalId,s=await fetch("".concat(e,"/api/results/").concat(n),{cache:"no-store"}),l=await s.json(),r=l.data.datasetId;if(!r){console.error("No datasetId found for current eval "+n);return}let i=await fetch("".concat(e,"/api/results?datasetId=").concat(r),{cache:"no-store"}),c=await i.json();d(c.data.filter(e=>e.evalId!==n))}catch(e){console.error("Error fetching recent evals:",e)}},h=()=>{i(!1)};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(V.Z,{title:"Combine this eval with another eval run",placement:"left",children:(0,s.jsxs)(A.Z,{onClick:()=>{u(),i(!0)},children:[(0,s.jsx)(M.Z,{children:(0,s.jsx)(K.Z,{fontSize:"small"})}),(0,s.jsx)(O.Z,{children:"Compare with another eval"})]})}),(0,s.jsx)(ei,{open:r,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."})]})},em=n(26110),ex=n(48931),eg=n(99645),ev=n(77656);function ej(e){let{open:t,onClose:a}=e,{config:r}=eh(),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)(Y.Z,{id:"config-dialog-title",children:(0,s.jsxs)(R.Z,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[(0,s.jsx)(B.Z,{variant:"h6",style:{flexGrow:1},children:"Config"}),(0,s.jsxs)(R.Z,{children:[(0,s.jsx)(V.Z,{title:"Copy to clipboard",children:(0,s.jsx)(ev.Z,{onClick:()=>{i.current&&(i.current.select(),document.execCommand("copy"),c(!0))},children:o?(0,s.jsx)(em.Z,{}):(0,s.jsx)(eg.Z,{})})}),(0,s.jsx)(V.Z,{title:"Download .yaml",children:(0,s.jsx)(ev.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)(ex.Z,{})})})]})]})}),(0,s.jsx)(q.Z,{children:(0,s.jsx)(B.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)(X.Z,{children:(0,s.jsx)(N.Z,{onClick:h,color:"primary",children:"Close"})})]})}var ef=n(79715),eb=n(34235),ey=function(){let{table:e,config:t,evalId:n}=eh(),[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)};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(A.Z,{onClick:()=>{r(!0)},children:[(0,s.jsx)(M.Z,{children:(0,s.jsx)(ex.Z,{fontSize:"small"})}),(0,s.jsx)(O.Z,{children:"Download"})]}),(0,s.jsx)(G.Z,{onClose:o,open:a,children:(0,s.jsx)(q.Z,{children:(0,s.jsxs)(z.Z,{direction:"column",spacing:2,sx:{width:"100%"},children:[(0,s.jsx)(N.Z,{onClick:()=>{let e=eb.default.dump(t),n=new Blob([e],{type:"text/yaml;charset=utf-8"});i(n,"promptfooconfig.yaml"),o()},startIcon:(0,s.jsx)(ex.Z,{}),fullWidth:!0,sx:{justifyContent:"flex-start"},children:"Download YAML Config"}),(0,s.jsx)(N.Z,{onClick:()=>{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,ef.P)(t),a=new Blob([l],{type:"text/csv;charset=utf-8;"});i(a,"".concat(n,"-table.csv")),o()},startIcon:(0,s.jsx)(ex.Z,{}),fullWidth:!0,sx:{justifyContent:"flex-start"},children:"Download Table CSV"}),(0,s.jsx)(N.Z,{onClick:()=>{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()},startIcon:(0,s.jsx)(ex.Z,{}),fullWidth:!0,sx:{justifyContent:"flex-start"},children:"Download Table JSON"}),(0,s.jsx)(N.Z,{onClick:()=>{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()},startIcon:(0,s.jsx)(ex.Z,{}),fullWidth:!0,sx:{justifyContent:"flex-start"},children:"Download DPO JSON"})]})})})]})},eZ=n(49653),ew=e=>{let{recentEvals:t,onRecentEvalSelected:n,currentEval:a}=e,[r,i]=(0,l.useState)(!1),o="undefined"!=typeof navigator&&-1!==navigator.platform.toUpperCase().indexOf("MAC"),c=()=>{i(!0)};return l.useEffect(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&"k"===e.key&&(e.preventDefault(),c())};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}},[]),(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(V.Z,{title:o?"Search for Evals (⌘ + K)":"Search for Evals (Ctrl + K)",arrow:!0,children:(0,s.jsx)(ev.Z,{onClick:c,color:"primary",size:"small",children:(0,s.jsx)(eZ.Z,{})})}),(0,s.jsx)(ei,{title:"Open an Eval",open:r,onClose:()=>{i(!1)},recentEvals:t,onRecentEvalSelected:n})]})},eC=n(69179),ek=n(92715),eS=n(92863),eE=n(36001);let eI=["#fd7f6f","#7eb0d5","#b2e061","#bd7ebe","#ffb55a","#ffee65","#beb9db","#fdcce5","#8bd3c7"];function eR(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)=>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:eI[n%eI.length]}});a.current=new eE.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:function(e){let t=e[0].datasetIndex;return"Column ".concat(t+1)},label:function(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 eN(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:eI[n%eI.length]}});a.current=new eE.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 eE.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:function(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:function(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:function(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)(Y.Z,{children:"Compare prompt outputs"}),(0,s.jsxs)(q.Z,{children:[(0,s.jsx)(T.Z,{sx:{m:1,minWidth:120},children:(0,s.jsx)(W.Z,{value:r,onChange:e=>i(Number(e.target.value)),children:t.head.prompts.map((e,t)=>(0,s.jsxs)(A.Z,{value:t,children:["Prompt ",t+1]},t))})}),(0,s.jsx)(T.Z,{sx:{m:1,minWidth:120},children:(0,s.jsx)(W.Z,{value:o,onChange:e=>c(Number(e.target.value)),children:t.head.prompts.map((e,t)=>(0,s.jsxs)(A.Z,{value:t,children:["Prompt ",t+1]},t))})})]})]}),(0,s.jsx)("canvas",{ref:n,style:{maxHeight:"300px",cursor:"pointer"},onClick:()=>u(!0)})]})}function eF(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:eI[n%eI.length]}});a.current=new eE.kL(n.current,{type:"bar",data:{labels:s,datasets:l},options:{scales:{x:{grid:{display:!1}},y:{ticks:{callback:function(e,t,n){let s=String(Math.round(100*Number(e)));return t===n.length-1&&(s+="%"),s}}}},plugins:{tooltip:{callbacks:{title:function(e){return e[0].dataset.label},label:function(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"}})}eE.kL.register(eE.vn,eE.ST,eE.ho,eE.uw,eE.f$,eE.ZL,eE.jn,eE.od,eE.u,eE.wL);var eT=l.memo(function(e){var t;let{columnVisibility:n}=e,a=(0,eS.Z)();eE.kL.defaults.color="dark"===a.palette.mode?"#aaa":"#666";let[r,i]=(0,l.useState)(!0),{table:o}=eh();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)(eC.SV,{fallback:null,children:(0,s.jsxs)($.Z,{style:{position:"relative",padding:a.spacing(3)},children:[(0,s.jsx)(ev.Z,{style:{position:"absolute",right:0,top:0},onClick:()=>i(!1),children:(0,s.jsx)(ek.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)(eN,{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)(eF,{table:o}):(0,s.jsx)(eR,{table:o})}),(0,s.jsx)("div",{style:{width:"33%"},children:(0,s.jsx)(eP,{table:o})})]})]})})}),eD=n(36128),eM=n(9317),eO=n(20286);n(55974);var eL=e=>{let{lookup:t,metricTotals:n,onSearchTextChange:l}=e;return t&&Object.keys(t).length?(0,s.jsx)("div",{className:"custom-metric-container",children:Object.entries(t).map(e=>{let[t,a]=e;return t&&void 0!==a?(0,s.jsxs)("span",{onClick:()=>l&&l("metric=".concat(t,":")),className:l?"clickable":"",children:[t,":"," ",n&&n[t]?(0,s.jsxs)(s.Fragment,{children:[(a/n[t]*100).toFixed(2),"% (",a,"/",n[t],")"]}):a]},t):null})}):null},eA=n(35185),eU=n(22689);function eW(e){let{gradingResults:t}=e;return t?(0,s.jsxs)(R.Z,{mt:2,children:[(0,s.jsx)(B.Z,{variant:"subtitle1",children:"Assertions"}),(0,s.jsx)(en.Z,{children:(0,s.jsxs)(Q.Z,{children:[(0,s.jsx)(es.Z,{children:(0,s.jsxs)(el.Z,{children:[(0,s.jsx)(et.Z,{style:{fontWeight:"bold"},children:"Pass"}),(0,s.jsx)(et.Z,{style:{fontWeight:"bold"},children:"Score"}),(0,s.jsx)(et.Z,{style:{fontWeight:"bold"},children:"Type"}),(0,s.jsx)(et.Z,{style:{fontWeight:"bold"},children:"Value"}),(0,s.jsx)(et.Z,{style:{fontWeight:"bold"},children:"Reason"})]})}),(0,s.jsx)(ee.Z,{children:t.map((e,t)=>{var n,l,a;return e?(0,s.jsxs)(el.Z,{children:[(0,s.jsx)(et.Z,{children:e.pass?"✅":"❌"}),(0,s.jsx)(et.Z,{children:null===(n=e.score)||void 0===n?void 0:n.toFixed(2)}),(0,s.jsx)(et.Z,{children:(null===(l=e.assertion)||void 0===l?void 0:l.type)||""}),(0,s.jsx)(et.Z,{style:{whiteSpace:"pre-wrap"},children:(null===(a=e.assertion)||void 0===a?void 0:a.value)?"object"==typeof e.assertion.value?JSON.stringify(e.assertion.value,null,2):String(e.assertion.value):"-"}),(0,s.jsx)(et.Z,{style:{whiteSpace:"pre-wrap"},children:e.reason})]},t):null})})]})})]}):null}function ez(e){let{open:t,onClose:n,prompt:a,provider:r,output:i,gradingResults:o,metadata:c}=e,[d,u]=(0,l.useState)(!1);(0,l.useEffect)(()=>{u(!1)},[a]);let h=async e=>{await navigator.clipboard.writeText(e),u(!0)};return(0,s.jsxs)(G.Z,{open:t,onClose:n,fullWidth:!0,maxWidth:"lg",children:[(0,s.jsxs)(Y.Z,{children:["Details",r&&": ".concat(r)]}),(0,s.jsxs)(q.Z,{children:[(0,s.jsxs)(R.Z,{mb:2,children:[(0,s.jsx)(B.Z,{variant:"subtitle1",style:{marginBottom:"1rem"},children:"Prompt"}),(0,s.jsx)(eU.Z,{readOnly:!0,value:a,style:{width:"100%",padding:"0.75rem"},maxRows:20}),(0,s.jsx)(ev.Z,{onClick:()=>h(a),style:{position:"absolute",right:"10px",top:"10px"},children:d?(0,s.jsx)(em.Z,{}):(0,s.jsx)(eA.Z,{})})]}),(null==c?void 0:c.redteamFinalPrompt)&&(0,s.jsxs)(R.Z,{my:2,children:[(0,s.jsx)(B.Z,{variant:"subtitle1",style:{marginBottom:"1rem",marginTop:"1rem"},children:"Modified User Input (Red Team)"}),(0,s.jsx)(eU.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)(B.Z,{variant:"subtitle1",style:{marginBottom:"1rem",marginTop:"1rem"},children:"Output"}),(0,s.jsx)(eU.Z,{readOnly:!0,maxRows:20,value:i,style:{width:"100%",padding:"0.75rem"}})]}),(0,s.jsx)(eW,{gradingResults:o})]}),(0,s.jsx)(X.Z,{children:(0,s.jsx)(N.Z,{onClick:n,children:"Close"})})]})}var e_=n(12431),eV=n(8541),eB=function(){let e=(0,eS.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)(N.Z,{variant:"text",color:"primary",startIcon:(0,s.jsx)(e_.Z,{}),onClick:()=>{n(!0)},children:"Generate test cases"})}),(0,s.jsxs)(G.Z,{open:t,onClose:a,children:[(0,s.jsx)(Y.Z,{children:"Run on Command Line"}),(0,s.jsx)(q.Z,{children:(0,s.jsxs)(eV.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)(X.Z,{children:(0,s.jsx)(N.Z,{onClick:a,color:"primary",children:"Close"})})]})]})};function eJ(e){return"string"==typeof e||"number"==typeof e?e.toString().length:Array.isArray(e)?e.reduce((e,t)=>e+eJ(t),0):l.isValidElement(e)&&e.props.children?l.Children.toArray(e.props.children).reduce((e,t)=>e+eJ(t),0):0}let eH=l.memo(function(e){let t,{text:n,maxLength:a}=e,[r,i]=l.useState(!0),o=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if("string"==typeof e||"number"==typeof e){let n=e.toString();return n.slice(0,a-t)}if(Array.isArray(e)){let n=[],s=t;for(let t of e){let e=eJ(t);if(s+e>a){n.push(o(t,s));break}n.push(t),s+=e}return n}if(l.isValidElement(e)&&e.props.children){let n=eJ(e.props.children);if(n>a-t)return l.cloneElement(e,{...e.props,children:o(e.props.children,t)})}return e};t=l.isValidElement(n)||"string"==typeof n?n:JSON.stringify(n);let c=r?o(t):t,d=eJ(t)>a;return(0,s.jsxs)("div",{style:{cursor:d?"pointer":"normal"},onClick:()=>{i(!r)},children:[c,r&&eJ(t)>a&&(0,s.jsx)("span",{children:"..."})]})});var eK=n(59682),eG=n(62268),eX=n(38640),eq=n.n(eX),eY=n(33352),e$=n(73490),eQ=n(24495);n(16658);var e0=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)(ev.Z,{onClick:()=>{a(e=>e>0?e-1:t.length-1)},children:(0,s.jsx)(e$.Z,{sx:{fontSize:12}})}),(0,s.jsxs)("span",{children:[n+1,"/",t.length]}),(0,s.jsx)(ev.Z,{onClick:()=>{a(e=>e<t.length-1?e+1:0)},children:(0,s.jsx)(eQ.Z,{sx:{fontSize:12}})})]}),t[n].trim().split("\n").map((e,t)=>(0,s.jsxs)(l.Fragment,{children:[e,(0,s.jsx)("br",{})]},t))]})},e1=e=>{let{open:t,contextText:n,commentText:l,onClose:a,onSave:r,onChange:i}=e;return(0,s.jsxs)(G.Z,{open:t,onClose:a,fullWidth:!0,maxWidth:"sm",children:[(0,s.jsx)(Y.Z,{children:"Edit Comment"}),(0,s.jsxs)(q.Z,{children:[(0,s.jsx)(R.Z,{sx:{backgroundColor:"#f0f0f0",padding:2,marginBottom:2},children:n}),(0,s.jsx)(_.Z,{autoFocus:!0,margin:"dense",type:"text",fullWidth:!0,multiline:!0,rows:4,value:l,onChange:e=>i(e.target.value)})]}),(0,s.jsxs)(X.Z,{children:[(0,s.jsx)(N.Z,{onClick:r,color:"primary",variant:"contained",children:"Save"}),(0,s.jsx)(N.Z,{onClick:a,color:"primary",children:"Cancel"})]})]})};let e2=()=>{let e=(0,l.useContext)(c);if(void 0===e)throw Error("useShiftKey must be used within a ShiftKeyProvider");return e};var e3=n(19116);let e5=l.memo(function(e){var t,n,a,r,i,o,c,d,u,h,p,m,x;let g,v,j,f,b,y,{output:Z,maxTextLength:w,rowIndex:C,promptIndex:k,onRating:S,firstOutput:E,showDiffs:I,searchText:R,showStats:N}=e,{renderMarkdown:P,prettifyJson:F,showPrompts:T,showPassFail:D,inComparisonMode:M}=eh(),[O,L]=l.useState(!1),[A,U]=l.useState(!1),[W,z]=l.useState(null),_=e=>{z(e||null),U(!A)},[B,J]=l.useState(!1),[H,K]=l.useState((null===(t=Z.gradingResult)||void 0===t?void 0:t.comment)||""),G=()=>{J(!0)},X="string"==typeof Z.text?Z.text:JSON.stringify(Z.text),q=[];if(!Z.pass&&X.includes("---")&&(q=((null===(h=Z.gradingResult)||void 0===h?void 0:h.componentResults)||[]).filter(e=>!!e&&!e.pass).map(e=>e.reason),X=X.split("---").slice(1).join("---")),I&&E){let e,t="string"==typeof E.text?E.text:JSON.stringify(E.text);t.includes("---")&&(t=t.split("---").slice(1).join("---"));try{JSON.parse(t),JSON.parse(X),e=(0,e3.CT)(t,X)}catch(n){e=t.includes(". ")&&X.includes(". ")?(0,e3.SY)(t,X):(0,e3.NV)(t,X)}g=(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(R)try{let e;let t=RegExp(R,"gi"),n=[];for(;null!==(e=t.exec(X));)n.push({start:e.index,end:t.lastIndex});g=(0,s.jsx)(s.Fragment,{children:n.length>0?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{children:X.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:X.substring(e.start,e.end)},"match-"+t),(0,s.jsx)("span",{children:X.substring(e.end,n[t+1]?n[t+1].start:X.length)},"text-after-"+t)]}))]}):(0,s.jsx)("span",{children:X},"no-match")})}catch(e){console.error("Invalid regular expression:",e.message)}else if(P&&!I)g=(0,s.jsx)(eO.U,{remarkPlugins:[eY.Z],components:{img:e=>{let{src:t,alt:n}=e;return(0,s.jsx)("img",{loading:"lazy",src:t,alt:n,onClick:()=>_(t),style:{cursor:"pointer"}})}},children:X});else if(F)try{g=(0,s.jsx)("pre",{children:JSON.stringify(JSON.parse(X),null,2)})}catch(e){}let Y=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]),$=l.useCallback(()=>{let e=prompt("Set test score (0.0 - 1.0):",String(Z.score));if(null!==e){let n=parseFloat(e);if(!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,ee]=l.useState(!1),et=l.useCallback(()=>{navigator.clipboard.writeText(Z.text),ee(!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&&(b=(0,s.jsxs)("span",{children:["$",Z.cost.toPrecision(2)]})),null===(i=Z.tokenUsage)||void 0===i?void 0:i.cached)v=(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);v=(0,s.jsx)(V.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 en=(null===(c=Z.gradingResult)||void 0===c?void 0:c.comment)&&"!highlight"!==Z.gradingResult.comment?(0,s.jsx)("div",{className:"comment",onClick:G,children:Z.gradingResult.comment}):null,es=N?(0,s.jsxs)("div",{className:"cell-detail",children:[v&&(0,s.jsxs)("div",{className:"stat-item",children:[(0,s.jsx)("strong",{children:"Tokens:"})," ",v]}),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]}),b&&(0,s.jsxs)("div",{className:"stat-item",children:[(0,s.jsx)("strong",{children:"Cost:"})," ",b]})]}):null,el=e2(),ea=(0,s.jsxs)("div",{className:"cell-actions",children:[el&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"action",onClick:et,onMouseDown:e=>e.preventDefault(),children:(0,s.jsx)(V.Z,{title:"Copy output to clipboard",children:(0,s.jsx)("span",{children:Q?"✅":"\uD83D\uDCCB"})})}),(0,s.jsx)("span",{className:"action",onClick:()=>{let e;H.startsWith("!highlight")?S(void 0,void 0,e=H.slice(10).trim()):S(void 0,void 0,e=("!highlight "+H).trim()),K(e)},onMouseDown:e=>e.preventDefault(),children:(0,s.jsx)(V.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)(V.Z,{title:"View output and test details",children:(0,s.jsx)("span",{children:"\uD83D\uDD0E"})})}),(0,s.jsx)(ez,{open:O,onClose:()=>{L(!1)},prompt:Z.prompt,provider:Z.provider,gradingResults:null===(d=Z.gradingResult)||void 0===d?void 0:d.componentResults,output:X,metadata:Z.metadata})]}),(0,s.jsx)("span",{className:"action",onClick:()=>Y(!0),children:(0,s.jsx)(V.Z,{title:"Mark test passed (score 1.0)",children:(0,s.jsx)("span",{children:"\uD83D\uDC4D"})})}),(0,s.jsx)("span",{className:"action",onClick:()=>Y(!1),children:(0,s.jsx)(V.Z,{title:"Mark test failed (score 0.0)",children:(0,s.jsx)("span",{children:"\uD83D\uDC4E"})})}),(0,s.jsx)("span",{className:"action",onClick:$,children:(0,s.jsx)(V.Z,{title:"Set test score",children:(0,s.jsx)("span",{children:"\uD83D\uDD22"})})}),(0,s.jsx)("span",{className:"action",onClick:G,children:(0,s.jsx)(V.Z,{title:"Edit comment",children:(0,s.jsx)("span",{children:"✏️"})})})]}),er={};(null===(u=Z.gradingResult)||void 0===u?void 0:u.comment)==="!highlight"&&(er.backgroundColor="#ffffeb");let ei=0,eo=0,ec=Z.gradingResult;if(ec?ec.componentResults?ec.componentResults.forEach(e=>{(null==e?void 0:e.pass)?ei++:eo++}):(ei=ec.pass?1:0,eo=ec.pass?0:1):Z.pass?ei=1:Z.pass||(eo=1),1===eo&&1===ei)y=(0,s.jsxs)(s.Fragment,{children:["".concat(eo," FAIL")," ","".concat(ei," PASS")]});else{let e="";eo>1||ei>1&&eo>0?e="".concat(eo," FAIL"):1===eo&&(e="FAIL");let t="";ei>1||eo>1&&ei>0?t="".concat(ei," PASS"):1===ei&&0===eo&&(t="PASS");let n=e&&t?" ":"";y=(0,s.jsxs)(s.Fragment,{children:[e,n,t]})}let ed=null===(x=Z.score)||0===x||1===x?"":"(".concat(x.toFixed(2),")");return(0,s.jsxs)("div",{className:"cell",style:er,children:[D&&(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:[y,ed&&(0,s.jsxs)("span",{className:"score",children:[" ",ed]})]}),(0,s.jsx)(eL,{lookup:Z.namedScores})]})}):(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)("div",{className:"status fail",children:[(0,s.jsxs)("div",{className:"pill",children:[y,ed&&(0,s.jsxs)("span",{className:"score",children:[" ",ed]})]}),(0,s.jsx)(eL,{lookup:Z.namedScores}),(0,s.jsx)("span",{className:"fail-reason",children:(0,s.jsx)(e0,{failReasons:q})})]})})}),T&&E.prompt&&(0,s.jsxs)("div",{className:"prompt",children:[(0,s.jsx)("span",{className:"pill",children:"Prompt"}),Z.prompt]}),(0,s.jsx)(eH,{text:g||X,maxLength:w}),en,es,ea,A&&W&&(0,s.jsx)("div",{className:"lightbox",onClick:()=>_(),children:(0,s.jsx)("img",{src:W,alt:"Lightbox"})}),(0,s.jsx)(e1,{open:B,contextText:Z.text,commentText:H,onClose:()=>{J(!1)},onSave:()=>{S(void 0,void 0,H),J(!1)},onChange:K})]})});function e4(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)(eH,{text:t,maxLength:n}),a&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(V.Z,{title:"View prompt",children:(0,s.jsx)("span",{className:"action",onClick:()=>{c(!0)},children:"\uD83D\uDD0E"})}),(0,s.jsx)(ez,{open:o,onClose:()=>{c(!1)},prompt:a}),r&&(0,s.jsx)(V.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)(eK.Z,{fontSize:"small"})})})})]})]})}n(93207);var e7=l.memo(function(e){let{maxTextLength:t,columnVisibility:n,wordBreak:a,filterMode:r,failureFilter:i,searchText:c,showStats:d,onFailureFilterToggle:u,onSearchTextChange:h}=e,{evalId:p,table:x,setTable:g,inComparisonMode:v}=eh(),{showToast:j}=m();(0,y.Z)(x,"Table should be defined");let{head:f,body:b}=x,Z=l.useCallback(async(e,t,n,s,l)=>{var a,r;let i=[...b],c={...i[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 m=(null===(a=d[t].gradingResult)||void 0===a?void 0:a.componentResults)||[];if(void 0!==n){let e=m.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?m[e]=t:m.push(t)}let x={...d[t].gradingResult||{},pass:u,score:h,reason:"Manual result (overrides all other grading results)",comment:l,assertion:(null===(r=d[t].gradingResult)||void 0===r?void 0:r.assertion)||null,componentResults:m};d[t].gradingResult=x,c.outputs=d,i[e]=c;let y={head:f,body:i};if(g(y),v)j("Ratings are not saved in comparison mode","warning");else try{let e=await fetch("".concat(await (0,o.b)(),"/api/eval/").concat(p),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({table:y})});if(!e.ok)throw Error("Network response was not ok")}catch(e){console.error("Failed to update table:",e)}},[b,f,g,p,v,j]),w=Object.keys(n).length>0,C=l.useMemo(()=>{try{return RegExp(c,"i")}catch(e){return console.error("Invalid regular expression:",e.message),null}},[c]),k=l.useMemo(()=>{try{return b.map((e,t)=>({...e,outputs:e.outputs.map((e,n)=>({...e,originalRowIndex:t,originalPromptIndex:n}))})).filter(e=>{let t=!0;return"failures"===r?t=e.outputs.some((e,t)=>{let s="Prompt ".concat(t+1);return i[s]&&!e.pass&&(!w||n[s])}):"different"===r?t=!e.outputs.every(t=>t.text===e.outputs[0].text):"highlights"===r&&(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||!C||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 C.test(r)}))})}catch(e){return console.error("Invalid regular expression:",e.message),b}},[b,i,r,c,n,w,C]),[S,E]=l.useState({pageIndex:0,pageSize:50});l.useEffect(()=>{E(e=>({...e,pageIndex:0}))},[i,r,c]);let I=l.useMemo(()=>f.prompts.map((e,t)=>b.reduce((e,n)=>e+(n.outputs[t].pass?1:0),0)),[f.prompts,b]),F=l.useMemo(()=>f.prompts.map((e,t)=>b.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)),[f.prompts,b]),T=l.useMemo(()=>f.prompts.map((e,t)=>b.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)),[f.prompts,b]),D=l.useMemo(()=>I.reduce((e,t,n,s)=>t>s[e]?n:e,0),[I]),M=I[D],O=l.useMemo(()=>(0,eD.Cl)(),[]),{renderMarkdown:L}=eh(),U=l.useMemo(()=>f.vars.length>0?[O.group({id:"vars",header:()=>(0,s.jsx)("span",{className:"font-bold",children:"Variables"}),columns:f.vars.map((e,n)=>O.accessor(e=>e.vars[n],{id:"Variable ".concat(n+1),header:()=>(0,s.jsx)(e4,{text:e,maxLength:t,className:"font-bold"}),cell:e=>{let n=e.getValue();return(0,s.jsx)("div",{className:"cell",children:L?(0,s.jsx)(eO.U,{remarkPlugins:[eY.Z],children:n}):(0,s.jsx)(eH,{text:n,maxLength:t})})},size:50}))})]:[],[O,f.vars,t,L]),z=l.useCallback((e,t)=>k[e].outputs[t],[k]),V=l.useCallback(e=>k[e].outputs[0],[k]),J=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]),H=l.useMemo(()=>[O.group({id:"prompts",header:()=>(0,s.jsx)("span",{className:"font-bold",children:"Outputs"}),columns:f.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,o,c,p,m,x,g;let v=I[n]&&b.length?(I[n]/b.length*100).toFixed(2):"0.00",j=I[n]===M&&0!==M,f="Prompt ".concat(n+1),y=i[f]||!1,Z=d?(0,s.jsxs)("div",{className:"prompt-detail",children:[F[n]?(0,s.jsxs)("div",{children:[(0,s.jsx)("strong",{children:"Asserts:"})," ",T[n],"/",F[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/b.length)," ","ms"]}):null,(null===(o=e.metrics)||void 0===o?void 0:null===(a=o.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/b.length)]}):null,(null===(c=e.metrics)||void 0===c?void 0:c.totalLatencyMs)&&(null===(m=e.metrics)||void 0===m?void 0:null===(p=m.tokenUsage)||void 0===p?void 0:p.completion)?(0,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,w=e.provider?e.provider.split(":"):[],C=w.length>1?(0,s.jsxs)(s.Fragment,{children:[w[0],":",(0,s.jsx)("strong",{children:w.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:C}):null,(0,s.jsx)("div",{className:"summary",children:(0,s.jsxs)("div",{className:"highlight ".concat(j?"success":""),children:[(0,s.jsxs)("strong",{children:[v,"% passing"]})," (",I[n],"/",b.length," cases)"]})}),(null===(g=e.metrics)||void 0===g?void 0:g.namedScores)&&Object.keys(e.metrics.namedScores).length>0?(0,s.jsx)(eL,{lookup:e.metrics.namedScores,metricTotals:J,onSearchTextChange:h}):null]}),(0,s.jsx)(e4,{className:"prompt-container",text:e.label||e.display||e.raw,expandedText:e.raw,maxLength:t,resourceId:e.id}),Z,"failures"===r&&(0,s.jsx)(eG.Z,{sx:{"& .MuiFormControlLabel-label":{fontSize:"0.75rem"}},control:(0,s.jsx)(P.Z,{checked:y,onChange:e=>u(f,e.target.checked)}),label:"Show failures"})]})},cell:e=>{var l,a;let i=z(e.row.index,n);return(0,s.jsx)(e5,{output:i,maxTextLength:t,rowIndex:e.row.index,promptIndex:n,onRating:Z.bind(null,null!==(l=i.originalRowIndex)&&void 0!==l?l:e.row.index,null!==(a=i.originalPromptIndex)&&void 0!==a?a:n),firstOutput:V(e.row.index),showDiffs:"different"===r,searchText:c,showStats:d})}}))})],[b.length,O,i,r,V,z,Z,f.prompts,M,t,J,F,T,I,u,h,c,d]),K=l.useMemo(()=>{let e=b.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)(eH,{text:String(e.getValue()),maxLength:t})}),size:50}:null},[b,t]),G=l.useMemo(()=>{let e=[];return K&&e.push(K),e.push(...U,...H),e},[K,U,H]),X=(0,eM.b7)({data:k,columns:G,columnResizeMode:"onChange",getCoreRowModel:(0,eD.sC)(),getPaginationRowModel:(0,eD.G_)(),state:{columnVisibility:n,pagination:S}});return(0,s.jsxs)("div",{children:[(0,s.jsxs)("table",{className:"results-table firefox-fix ".concat(t<=25?"compact":""),style:{wordBreak:a},children:[(0,s.jsx)("thead",{children:X.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,eM.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:X.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,eM.ie)(e.column.columnDef.cell,e.getContext())},e.id)})},e.id)})})]}),X.getPageCount()>1&&(0,s.jsxs)(R.Z,{className:"pagination",mx:1,sx:{display:"flex",alignItems:"center",gap:2},children:[(0,s.jsx)(N.Z,{onClick:()=>{E(e=>({...e,pageIndex:Math.max(e.pageIndex-1,0)})),window.scrollTo(0,0)},disabled:0===X.getState().pagination.pageIndex,variant:"contained",children:"Previous"}),(0,s.jsxs)(B.Z,{component:"span",sx:{display:"flex",alignItems:"center",gap:1},children:["Page",(0,s.jsx)(_.Z,{size:"small",type:"number",value:X.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),X.getPageCount()-1)}))},InputProps:{style:{width:"60px",textAlign:"center"}},variant:"outlined"}),(0,s.jsxs)("span",{children:["of ",X.getPageCount()]})]}),(0,s.jsx)(N.Z,{onClick:()=>{E(e=>({...e,pageIndex:Math.min(e.pageIndex+1,X.getPageCount()-1)})),window.scrollTo(0,0)},disabled:X.getState().pagination.pageIndex+1>=X.getPageCount(),variant:"contained",children:"Next"}),(0,s.jsxs)(B.Z,{component:"span",sx:{display:"flex",alignItems:"center",gap:1},children:[(0,s.jsxs)(W.Z,{value:S.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)(A.Z,{value:10,children:"10"}),(0,s.jsx)(A.Z,{value:50,children:"50"}),(0,s.jsx)(A.Z,{value:100,children:"100"}),(0,s.jsx)(A.Z,{value:500,children:"500"}),(0,s.jsx)(A.Z,{value:1e3,children:"1000"})]}),(0,s.jsx)("span",{children:"results per page"})]})]}),(0,s.jsx)(eB,{})]})}),e6=n(97540),e8=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:g,setShowPassFail:v}=eh();return(0,s.jsxs)(G.Z,{open:t,onClose:n,fullWidth:!0,maxWidth:"sm",children:[(0,s.jsx)(Y.Z,{children:"Table View Settings"}),(0,s.jsxs)(q.Z,{children:[(0,s.jsx)(R.Z,{children:(0,s.jsx)(V.Z,{title:"Forcing line breaks makes it easier to adjust column widths to your liking",placement:"right",children:(0,s.jsx)(eG.Z,{control:(0,s.jsx)(P.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)(eG.Z,{control:(0,s.jsx)(P.Z,{checked:d,onChange:e=>u(e.target.checked)}),label:"Render model outputs as Markdown"})}),(0,s.jsx)(R.Z,{children:(0,s.jsx)(eG.Z,{control:(0,s.jsx)(P.Z,{checked:h,onChange:e=>p(e.target.checked)}),label:"Prettify JSON outputs"})}),(0,s.jsx)(R.Z,{children:(0,s.jsx)(V.Z,{title:"Show the final prompt that produced the output in each cell.",placement:"right",children:(0,s.jsx)(eG.Z,{control:(0,s.jsx)(P.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)(V.Z,{title:"Show pass/fail status for each output.",placement:"right",children:(0,s.jsx)(eG.Z,{control:(0,s.jsx)(P.Z,{checked:g,onChange:e=>v(e.target.checked)}),label:"Show pass/fail status"})})}),(0,s.jsx)(R.Z,{children:(0,s.jsx)(V.Z,{title:"Show detailed inference statistics such as latency, tokens used, cost, etc.",placement:"right",children:(0,s.jsx)(eG.Z,{control:(0,s.jsx)(P.Z,{checked:o,onChange:e=>c(e.target.checked)}),label:"Show inference details"})})}),(0,s.jsxs)(R.Z,{maxWidth:"sm",children:[(0,s.jsxs)(B.Z,{mt:2,children:["Max text length: ",l]}),(0,s.jsx)(e6.ZP,{min:25,max:1e3,value:l,onChange:(e,t)=>a(t)})]})]}),(0,s.jsx)(X.Z,{children:(0,s.jsx)(N.Z,{onClick:n,children:"Close"})})]})},e9=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)(Y.Z,{children:"Your eval is ready to share"}),(0,s.jsxs)(q.Z,{children:[(0,s.jsx)(_.Z,{inputRef:r,value:a,fullWidth:!0,InputProps:{readOnly:!0,endAdornment:(0,s.jsx)(ev.Z,{onClick:()=>{r.current&&(r.current.select(),document.execCommand("copy"),o(!0))},children:i?(0,s.jsx)(em.Z,{}):(0,s.jsx)(eg.Z,{})})}}),(0,s.jsx)(eV.Z,{sx:{fontSize:"0.75rem"},children:"Shared URLs are deleted after 2 weeks."})]}),(0,s.jsx)(X.Z,{children:(0,s.jsx)(N.Z,{onClick:c,color:"primary",children:"Close"})})]})};n(58022);let te=(0,J.Z)(z.Z)(e=>{let{theme:t}=e;return{maxWidth:"100%",flexWrap:"wrap",[t.breakpoints.down("sm")]:{flexDirection:"column"}}});function tt(e){var t;let{recentEvals:n,onRecentEvalSelected:a,defaultEvalId:c}=e,d=(0,f.useRouter)(),h=(0,f.useSearchParams)(),{author:p,table:m,setTable:x,config:g,setConfig:j,maxTextLength:b,wordBreak:z,showInferenceDetails:J,evalId:K,inComparisonMode:G,setInComparisonMode:X}=eh(),{setStateFromConfig:q}=(0,Z.o)(),[Y,$]=l.useState((null==h?void 0:h.get("search"))||""),[Q]=(0,H.Nr)(Y,1e3),ee=e=>{$(e)},[et,en]=l.useState({}),es=l.useCallback((e,t)=>{en(n=>({...n,[e]:t}))},[en]);(0,y.Z)(m,"Table data must be loaded before rendering ResultsView");let{head:el}=m,[ea,er]=l.useState("all"),[ei,eo]=l.useState(!1),[ec,ed]=l.useState(""),[eu,em]=l.useState(!1),[ex,eg]=l.useState(null),ev=async()=>{em(!0);try{let e=await fetch("".concat(r,"/api/eval"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:{version:2,createdAt:new Date().toISOString(),results:{table:m},config:g}})}),{id:t}=await e.json(),n="".concat(i,"/eval/").concat(t);ed(n),eo(!0)}catch(e){alert("Sorry, something went wrong.")}finally{em(!1)}},ef=async e=>{eg(null);try{var t;let n=await fetch("".concat(await (0,o.b)(),"/api/results/").concat(e),{cache:"no-store"}),s=await n.json(),l=s.data.results.table,a={head:{prompts:[...m.head.prompts.map(e=>({...e,label:"[".concat(K||c||"Eval A","] ").concat(e.label||"")})),...l.head.prompts.map(t=>({...t,label:"[".concat(e,"] ").concat(t.label||"")}))],vars:m.head.vars},body:m.body.map((e,t)=>{var n;return{...e,outputs:[...e.outputs,...(null===(n=l.body[t])||void 0===n?void 0:n.outputs)||[]]}})};x(a),j({...g,...s.data.config,description:'Combined: "'.concat((null==g?void 0:g.description)||"Eval A",'" and "').concat((null===(t=s.data.config)||void 0===t?void 0:t.description)||"Eval B",'"')}),X(!0)}catch(e){console.error("Error fetching comparison eval:",e),alert("Failed to load comparison eval. Please try again.")}},eb=l.useMemo(()=>m.body.some(e=>e.description),[m.body]),eZ=l.useMemo(()=>[...eb?[{value:"description",label:"Description"}]:[],...el.vars.map((e,t)=>({value:"Variable ".concat(t+1),label:"Var ".concat(t+1,": ").concat(el.vars[t].length>100?el.vars[t].slice(0,97)+"...":el.vars[t]),group:"Variables"})),...el.prompts.map((e,t)=>{let n=el.prompts[t],s=n.label||n.display||n.raw;return{value:"Prompt ".concat(t+1),label:"Prompt ".concat(t+1,": ").concat(s.length>100?s.slice(0,97)+"...":s),group:"Prompts"}})],[el.vars,el.prompts,eb]),[eC,ek]=l.useState(!1),[eS,eE]=l.useState(!1),[eI,eR]=l.useState({}),[eN,eP]=l.useState(eZ.map(e=>e.value)),eF=async()=>{(0,y.Z)(g,"Config must be loaded before clicking its description");let e=window.prompt("Enter new description:",g.description);if(null!==e&&e!==g.description){let t={...g,description:e};try{let e=await fetch("".concat(await (0,o.b)(),"/api/eval/").concat(K),{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)}}},eD=async()=>{if(window.confirm("Are you sure you want to delete this evaluation?"))try{let e=await fetch("".concat(await (0,o.b)(),"/api/eval/").concat(K),{method:"DELETE"});if(!e.ok)throw Error("Network response was not ok");d.push("/")}catch(e){console.error("Failed to delete evaluation:",e),alert("Failed to delete evaluation")}},[eM,eO]=l.useState(!1),eL=async()=>{K&&(await navigator.clipboard.writeText(K),eO(!0),setTimeout(()=>{eO(!1)},1e3))};return(0,s.jsxs)("div",{style:{marginLeft:"1rem",marginRight:"1rem"},children:[(0,s.jsxs)(te,{direction:"row",mb:2,spacing:1,alignItems:"center",className:"eval-header",children:[n&&n.length>0&&(0,s.jsx)(ew,{recentEvals:n,onRecentEvalSelected:a,currentEval:n.find(e=>e.evalId===K)||null}),!G&&(0,s.jsx)(B.Z,{variant:"h5",sx:{display:"flex",alignItems:"center"},children:(0,s.jsx)(V.Z,{title:"Click to edit description",children:(0,s.jsx)("span",{className:"description",onClick:eF,children:(null==g?void 0:g.description)||K})})}),(null==g?void 0:g.description)&&K&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(V.Z,{title:"Click to copy",children:(0,s.jsx)(F.Z,{size:"small",label:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("strong",{children:"ID:"})," ",K]}),sx:{opacity:.7,cursor:"pointer"},onClick:eL})}),(0,s.jsx)(u.Z,{open:eM,autoHideDuration:1e3,onClose:()=>eO(!1),message:"Eval id copied to clipboard"})]}),(0,s.jsx)(V.Z,{title:p?"":"Set eval author with `promptfoo config set email`",children:(0,s.jsx)(F.Z,{size:"small",label:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("strong",{children:"Author:"})," ",p||"Unknown"]}),sx:{opacity:.7}})})]}),(0,s.jsxs)(te,{direction:"row",spacing:4,alignItems:"center",children:[(0,s.jsx)(R.Z,{children:(0,s.jsxs)(T.Z,{sx:{m:1,minWidth:200,maxWidth:350},size:"small",children:[(0,s.jsx)(D.Z,{id:"visible-columns-label",children:"Columns"}),(0,s.jsx)(W.Z,{labelId:"visible-columns-label",id:"visible-columns",multiple:!0,value:eN,onChange:e=>{let{target:{value:t}}=e;eP("string"==typeof t?t.split(","):t);let n=[...eb?["description"]:[],...el.vars.map((e,t)=>"Variable ".concat(t+1)),...el.prompts.map((e,t)=>"Prompt ".concat(t+1))],s={};n.forEach(e=>{s[e]=("string"==typeof t?t.split(","):t).includes(e)}),eR(s)},input:(0,s.jsx)(U.Z,{label:"Visible columns"}),renderValue:e=>e.join(", "),children:eZ.map(e=>(0,s.jsxs)(A.Z,{dense:!0,value:e.value,children:[(0,s.jsx)(P.Z,{checked:eN.indexOf(e.value)>-1}),(0,s.jsx)(O.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)(D.Z,{id:"failure-filter-mode-label",children:"Display"}),(0,s.jsxs)(W.Z,{labelId:"filter-mode-label",id:"filter-mode",value:ea,onChange:e=>{let t=e.target.value;er(t);let n={};el.prompts.forEach((e,s)=>{n["Prompt ".concat(s+1)]="failures"===t}),en(n)},label:"Filter",children:[(0,s.jsx)(A.Z,{value:"all",children:"Show all results"}),(0,s.jsx)(A.Z,{value:"failures",children:"Show failures only"}),(0,s.jsx)(A.Z,{value:"different",children:"Show different only"}),(0,s.jsx)(A.Z,{value:"highlights",children:"Show highlights only"})]})]})}),(0,s.jsx)(R.Z,{children:(0,s.jsx)(_.Z,{sx:{minWidth:180},size:"small",label:"Search",placeholder:"Text or regex",value:Y,onChange:e=>ee(e.target.value)})}),(0,s.jsx)(R.Z,{flexGrow:1}),(0,s.jsx)(R.Z,{display:"flex",justifyContent:"flex-end",children:(0,s.jsxs)(te,{direction:"row",spacing:2,children:[(0,s.jsx)(N.Z,{color:"primary",onClick:e=>{eg(e.currentTarget)},startIcon:(0,s.jsx)(w.Z,{}),children:"Eval actions"}),g&&(0,s.jsxs)(L.Z,{id:"eval-actions-menu",anchorEl:ex,keepMounted:!0,open:!!ex,onClose:()=>{eg(null)},children:[(0,s.jsx)(ep,{initialEvals:n,onComparisonEvalSelected:ef}),(0,s.jsx)(V.Z,{title:"View the configuration that defines this eval",placement:"left",children:(0,s.jsxs)(A.Z,{onClick:()=>ek(!0),children:[(0,s.jsx)(M.Z,{children:(0,s.jsx)(I.Z,{fontSize:"small"})}),"View YAML"]})}),(0,s.jsx)(V.Z,{title:"Edit this eval in the web UI",placement:"left",children:(0,s.jsxs)(A.Z,{onClick:()=>{q(g),d.push("/setup/")},children:[(0,s.jsx)(M.Z,{children:(0,s.jsx)(k.Z,{fontSize:"small"})}),"Edit Eval"]})}),(0,s.jsx)(ey,{}),(null==g?void 0:g.sharing)&&(0,s.jsx)(V.Z,{title:"Generate a unique URL that others can access",placement:"left",children:(0,s.jsxs)(A.Z,{onClick:ev,disabled:eu,children:[(0,s.jsx)(M.Z,{children:eu?(0,s.jsx)(v.Z,{size:16}):(0,s.jsx)(E.Z,{fontSize:"small"})}),"Share"]})}),(0,s.jsx)(V.Z,{title:"Delete this eval",placement:"left",children:(0,s.jsxs)(A.Z,{onClick:eD,children:[(0,s.jsx)(M.Z,{children:(0,s.jsx)(C.Z,{fontSize:"small"})}),"Delete"]})})]}),(0,s.jsx)(V.Z,{title:"Edit table view settings",placement:"bottom",children:(0,s.jsx)(N.Z,{color:"primary",onClick:()=>eE(!0),startIcon:(0,s.jsx)(S.Z,{}),children:"Table Settings"})}),(null==g?void 0:null===(t=g.metadata)||void 0===t?void 0:t.redteam)&&(0,s.jsx)(V.Z,{title:"View vulnerability scan report",placement:"bottom",children:(0,s.jsx)(N.Z,{color:"primary",startIcon:(0,s.jsx)(I.Z,{}),onClick:()=>d.push("/report/?evalId=".concat(K||c)),children:"Vulnerability Report"})})]})})]}),(0,s.jsx)(eT,{columnVisibility:eI}),(0,s.jsx)(e7,{maxTextLength:b,columnVisibility:eI,wordBreak:z,showStats:J,filterMode:ea,failureFilter:et,searchText:Q,onFailureFilterToggle:es,onSearchTextChange:ee}),(0,s.jsx)(ej,{open:eC,onClose:()=>ek(!1)}),(0,s.jsx)(e9,{open:ei,onClose:()=>eo(!1),shareUrl:ec}),(0,s.jsx)(e8,{open:eS,onClose:()=>eE(!1)})]})}async function tn(){let e=(0,j.createClientComponentClient)(),{data:{user:t}}=await e.auth.getUser();(0,y.Z)(t,"User not logged in");let{data:n,error:s}=await e.from("EvaluationResult").select("id, createdAt").eq("user_id",t.id).order("createdAt",{ascending:!1}).limit(100);return n||[]}async function ts(e){let t=(0,j.createClientComponentClient)(),{data:n,error:s}=await t.from("EvaluationResult").select("*").eq("id",e).single();return n}function tl(e){var t;let{fetchId:n,preloadedData:a,recentEvals:i,defaultEvalId:c}=e,u=(0,f.useRouter)(),{table:h,setTable:p,setConfig:m,setEvalId:j,setAuthor:Z,setInComparisonMode:w}=eh(),[C,k]=l.useState(!1),[S,E]=l.useState(!1),[I,R]=l.useState(i||[]),N=async()=>{let e=await fetch("".concat(await (0,o.b)(),"/api/results"),{cache:"no-store"}),t=await e.json();return R(t.data),t.data},P=l.useCallback(async e=>{let t=await fetch("".concat(await (0,o.b)(),"/api/results/").concat(e),{cache:"no-store"}),n=await t.json();p(n.data.results.table),m(n.data.config),Z(n.data.author),j(e)},[p,m,j,Z]),F=async e=>{g.Ox?(k(!1),u.push("/eval/remote:".concat(encodeURIComponent(e)))):u.push("/eval/?evalId=".concat(encodeURIComponent(e)))},[T,D]=l.useState(c||(null===(t=I[0])||void 0===t?void 0:t.evalId)),M=(0,f.useSearchParams)(),O=M?M.get("evalId"):null;return(l.useEffect(()=>{if(O){console.log("Eval init: Fetching eval by id",O);let e=async()=>{await P(O),k(!0),D(O),N()};e()}else if(a){var e;console.log("Eval init: Using preloaded data"),p(null===(e=a.data.results)||void 0===e?void 0:e.table),m(a.data.config),Z(a.data.author||null),k(!0)}else if(n){console.log("Eval init: Fetching eval from remote server",n);let e=async()=>{var e;let t="".concat(r,"/api/eval/").concat(n);console.log("Fetching eval from remote server",t);let s=await fetch(t);if(!s.ok){E(!0);return}let l=await s.json();p(null===(e=l.data.results)||void 0===e?void 0:e.table),m(l.data.config),Z(l.data.author||null),k(!0)};e()}else if(g.T8)console.log("Eval init: Using local server websocket"),(0,o.b)().then(e=>{let t=(0,b.io)(e);return t.on("init",e=>{console.log("Initialized socket connection",e),k(!0),p(null==e?void 0:e.results.table),m(null==e?void 0:e.config),Z((null==e?void 0:e.author)||null),N().then(e=>{var t,n,s;D(null===(t=e[0])||void 0===t?void 0:t.evalId),console.log("setting default eval id",null===(n=e[0])||void 0===n?void 0:n.evalId),j(null===(s=e[0])||void 0===s?void 0:s.evalId)})}),t.on("update",e=>{console.log("Received data update",e),p(e.results.table),m(e.config),Z(e.author||null),N().then(e=>{var t;let n=null===(t=e[0])||void 0===t?void 0:t.evalId;n&&(D(n),j(n))})}),()=>{t.disconnect()}});else if(g.Ox)console.log("Eval init: Using Supabase"),tn().then(e=>{R(e.map(e=>({evalId:e.id,datasetId:null,label:e.createdAt,createdAt:new Date(e.createdAt).getTime(),description:"None",numTests:-1}))),e.length>0&&ts(e[0].id).then(t=>{(0,y.Z)(t,"Eval not found");let n=t.results,s=t.config;D(e[0].id),p(n.table),m(s),Z(null),k(!0)})});else{console.log("Eval init: Fetching eval via recent");let e=async()=>{let e=await N();if(!(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=await (0,o.b)(),n=e[0].evalId,s=await fetch("".concat(t,"/api/results/").concat(n)),l=await s.json();p(l.data.results.table),m(l.data.config),Z(l.data.author||null),k(!0),D(n),j(n)}};e()}w(!1)},[n,p,m,Z,j,P,a,D,O,w]),S)?(0,s.jsx)("div",{className:"notice",children:"404 Eval not found"}):C&&h?(0,s.jsx)(x,{children:(0,s.jsx)(d,{children:(0,s.jsx)(tt,{defaultEvalId:T,recentEvals:I,onRecentEvalSelected:F})})}):(0,s.jsxs)("div",{className:"notice",children:[(0,s.jsx)("div",{children:(0,s.jsx)(v.Z,{size:22})}),(0,s.jsx)("div",{children:"Waiting for eval data"})]})}n(94455)},52428:function(e,t,n){"use strict";n.d(t,{Ox:function(){return a},T8:function(){return l},eA:function(){return r}});var s=n(77580);let l=!s.env.NEXT_PUBLIC_PROMPTFOO_BUILD_STANDALONE_SERVER,a=!!s.env.NEXT_PUBLIC_PROMPTFOO_USE_SUPABASE,r=""},47887:function(e,t,n){"use strict";n.d(t,{o:function(){return a}});var s=n(79685),l=n(74595);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}))},55974:function(){},94455:function(){},16658:function(){},93207:function(){},58022:function(){}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[958],{56:function(e,t,s){Promise.resolve().then(s.bind(s,41400))},49532:function(e,t,s){"use strict";let n,i;async function r(){if(n||(i||(i=fetch("/api/config").then(e=>e.json()).then(e=>n=e.apiBaseUrl)),await i),void 0===n)throw Error("API base URL is undefined");return n}s.d(t,{b:function(){return r}})},41400:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return b}});var n=s(24004),i=s(14978),r=s(49532),l=s(49567),c=s(30469),a=s(65068),d=s(70417),o=s(21303),h=s(61451),u=s(26485),p=s(30021),x=s(19708),j=s(65969),v=s(38640),Z=s.n(v),m=s(28891),f=s(40982),w=s(29794),C=s(22701),y=s(51956),g=s(82669),I=s(22689),k=s(63147),P=s(34235);function S(e){var t,s,r,l;let{openDialog:h,handleClose:x,testCase:j}=e,[v,m]=(0,i.useState)(1);return(0,n.jsxs)(w.Z,{open:h,onClose:x,fullWidth:!0,maxWidth:"lg",children:[(0,n.jsxs)(g.Z,{children:["Dataset ",j.id.slice(0,6)]}),(0,n.jsxs)(y.Z,{children:[(0,n.jsx)(k.Z,{variant:"h6",style:{marginTop:"1rem"},children:"Test cases"}),(0,n.jsx)(I.Z,{readOnly:!0,value:j&&P.default.dump(j.testCases),style:{width:"100%",padding:"0.75rem"},maxRows:15}),(0,n.jsx)(k.Z,{variant:"h6",style:{marginTop:"1rem"},children:"Used in..."}),(0,n.jsxs)(a.Z,{children:[(0,n.jsx)(u.Z,{children:(0,n.jsxs)(p.Z,{children:[(0,n.jsx)(o.Z,{children:"Eval ID"}),(0,n.jsx)(o.Z,{children:"Prompt ID"}),(0,n.jsx)(o.Z,{children:"Raw score"}),(0,n.jsx)(o.Z,{children:"Pass rate"}),(0,n.jsx)(o.Z,{children:"Pass count"}),(0,n.jsx)(o.Z,{children:"Fail count"}),(0,n.jsx)(o.Z,{children:"Prompt"})]})}),(0,n.jsx)(d.Z,{children:null==j?void 0:null===(t=j.prompts)||void 0===t?void 0:t.slice((v-1)*10,10*v).sort((e,t)=>t.evalId.localeCompare(e.evalId)).map((e,t)=>{var s,i,c,a,d;return(0,n.jsxs)(p.Z,{hover:!0,children:[(0,n.jsx)(o.Z,{children:(0,n.jsx)(Z(),{href:"/eval/?evalId=".concat(e.evalId),children:e.evalId})}),(0,n.jsx)(o.Z,{style:{minWidth:"8em"},children:(0,n.jsx)(Z(),{href:"/prompts/?id=".concat(e.id),children:e.id.slice(0,6)})}),(0,n.jsx)(o.Z,{children:"number"==typeof(null===(s=e.prompt.metrics)||void 0===s?void 0:s.score)?e.prompt.metrics.score.toFixed(2):"-"}),(0,n.jsx)(o.Z,{children:"number"==typeof(null===(i=e.prompt.metrics)||void 0===i?void 0:i.testPassCount)&&"number"==typeof(null===(c=e.prompt.metrics)||void 0===c?void 0:c.testFailCount)&&e.prompt.metrics.testPassCount+e.prompt.metrics.testFailCount>0?(e.prompt.metrics.testPassCount/(e.prompt.metrics.testPassCount+e.prompt.metrics.testFailCount)*100).toFixed(2)+"%":"-"}),(0,n.jsx)(o.Z,{children:null!==(r=null===(a=e.prompt.metrics)||void 0===a?void 0:a.testPassCount)&&void 0!==r?r:"-"}),(0,n.jsx)(o.Z,{children:null!==(l=null===(d=e.prompt.metrics)||void 0===d?void 0:d.testFailCount)&&void 0!==l?l:"-"}),(0,n.jsx)(o.Z,{children:e.prompt.raw.length>250?e.prompt.raw.slice(0,250)+"...":e.prompt.raw})]},t)})})]}),Math.ceil(((null==j?void 0:null===(s=j.prompts)||void 0===s?void 0:s.length)||0)/10)>1&&(0,n.jsx)(c.Z,{count:Math.ceil(j.prompts.length/10),page:v,onChange:(e,t)=>{m(t)}})]}),(0,n.jsx)(C.Z,{children:(0,n.jsx)(f.Z,{onClick:x,children:"Close"})})]})}function b(){let e=(0,m.useSearchParams)(),[t,s]=(0,i.useState)([]),[v,f]=(0,i.useState)("date"),[w,C]=(0,i.useState)("desc"),[y,g]=(0,i.useState)(1),[I,k]=(0,i.useState)(10),[P,b]=(0,i.useState)(!1),[E,D]=(0,i.useState)(0),F=e=>{let t=v===e&&"asc"===w?"desc":"asc";f(e),C(t)};(0,i.useEffect)(()=>{(async()=>{fetch("".concat(await (0,r.b)(),"/api/datasets")).then(e=>e.json()).then(e=>{let t=[...e.data].sort((e,t)=>null===v?0:"asc"===w?e[v]>t[v]?1:-1:e[v]<t[v]?1:-1);s(t)})})()},[v,w,y,I]);let M=e=>{D(e),b(!0)};return(0,i.useEffect)(()=>{let s=null==e?void 0:e.get("id");if(s){let e=t.findIndex(e=>e.id.startsWith(s));-1!==e&&M(e)}},[t,e]),(0,n.jsx)(l.Z,{paddingX:2,children:(0,n.jsxs)(h.Z,{children:[(0,n.jsxs)(a.Z,{children:[(0,n.jsx)(u.Z,{children:(0,n.jsxs)(p.Z,{children:[(0,n.jsx)(o.Z,{style:{width:"10%"},children:"ID"}),(0,n.jsx)(o.Z,{style:{width:"20%"},children:(0,n.jsx)(x.Z,{active:"raw"===v,direction:"raw"===v?w:"asc",onClick:()=>F("raw"),children:"Info"})}),(0,n.jsx)(o.Z,{style:{width:"20%"},children:"Variables"}),(0,n.jsx)(o.Z,{style:{width:"10%"},children:(0,n.jsx)(x.Z,{active:"count"===v,direction:"count"===v?w:"asc",onClick:()=>F("count"),children:"Total # evals"})}),(0,n.jsx)(o.Z,{style:{width:"20%"},children:(0,n.jsx)(j.Z,{title:"The date of the most recent eval for this set of test cases",children:(0,n.jsx)(x.Z,{active:"date"===v,direction:"date"===v?w:"asc",onClick:()=>F("date"),children:"Most recent eval date"})})}),(0,n.jsx)(o.Z,{style:{width:"20%"},children:(0,n.jsx)(j.Z,{title:"The ID of the most recent eval for this set of test cases",children:(0,n.jsx)(x.Z,{active:"evalId"===v,direction:"evalId"===v?w:"asc",onClick:()=>F("evalId"),children:"Most recent eval ID"})})})]})}),(0,n.jsx)(d.Z,{children:t.slice((y-1)*I,y*I).map((e,t)=>(0,n.jsxs)(p.Z,{hover:!0,onClick:()=>M(t),style:{cursor:"pointer"},children:[(0,n.jsx)(o.Z,{children:e.id.slice(0,6)}),(0,n.jsxs)(o.Z,{style:{width:"20%",whiteSpace:"pre-wrap"},children:[e.testCases.length," test cases"]}),(0,n.jsx)(o.Z,{style:{width:"20%",whiteSpace:"pre-wrap"},children:(()=>{if(!Array.isArray(e.testCases)||"string"==typeof e.testCases[0])return"";let t=(e.testCases||[]).flatMap(e=>Object.keys(e.vars||{})),s=Array.from(new Set(t));return s.length>0?s.join(", "):"None"})()}),(0,n.jsx)(o.Z,{style:{width:"10%"},children:e.count}),(0,n.jsx)(o.Z,{style:{width:"20%"},children:e.recentEvalDate||"Unknown"}),(0,n.jsx)(o.Z,{style:{width:"20%"},children:e.recentEvalId?(0,n.jsx)(Z(),{href:"/eval?evalId=".concat(e.recentEvalId),children:e.recentEvalId}):"Unknown"})]},t))})]}),Math.ceil(t.length/I)>1&&(0,n.jsx)(c.Z,{count:Math.ceil(t.length/I),page:y,onChange:(e,t)=>g(t)}),t[E]&&(0,n.jsx)(S,{openDialog:P,handleClose:()=>{b(!1)},testCase:t[E]})]})})}}},function(e){e.O(0,[903,640,493,281,969,235,322,470,730,744],function(){return e(e.s=56)}),_N_E=e.O()}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[466],{9550:function(n,e,u){Promise.resolve().then(u.t.bind(u,29820,23))},29820:function(){}},function(n){n.O(0,[470,730,744],function(){return n(n.s=9550)}),_N_E=n.O()}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[421],{2323:function(e,n,t){Promise.resolve().then(t.t.bind(t,16662,23)),Promise.resolve().then(t.t.bind(t,27924,23)),Promise.resolve().then(t.t.bind(t,81885,23)),Promise.resolve().then(t.t.bind(t,30910,23)),Promise.resolve().then(t.bind(t,15737)),Promise.resolve().then(t.t.bind(t,29820,23))},81885:function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),function(e,n){for(var t in n)Object.defineProperty(e,t,{enumerable:!0,get:n[t]})}(n,{suspense:function(){return o},NoSSR:function(){return i}}),t(69278),t(14978);let r=t(66995);function o(){let e=Error(r.NEXT_DYNAMIC_NO_SSR_CODE);throw e.digest=r.NEXT_DYNAMIC_NO_SSR_CODE,e}function i(e){let{children:n}=e;return n}},29820:function(){}},function(e){e.O(0,[583,903,640,916,493,304,281,339,969,163,378,235,476,515,631,905,497,737,470,730,744],function(){return e(e.s=2323)}),_N_E=e.O()}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[11],{15669:function(e,n,s){Promise.resolve().then(s.t.bind(s,63512,23)),Promise.resolve().then(s.bind(s,15737))}},function(e){e.O(0,[583,903,640,916,493,304,281,339,969,163,378,235,476,515,631,905,497,737,470,730,744],function(){return e(e.s=15669)}),_N_E=e.O()}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{86287:function(e,n,t){Promise.resolve().then(t.t.bind(t,16662,23)),Promise.resolve().then(t.t.bind(t,27924,23)),Promise.resolve().then(t.t.bind(t,81885,23)),Promise.resolve().then(t.t.bind(t,30910,23)),Promise.resolve().then(t.t.bind(t,48607,23))},81885:function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),function(e,n){for(var t in n)Object.defineProperty(e,t,{enumerable:!0,get:n[t]})}(n,{suspense:function(){return o},NoSSR:function(){return i}}),t(69278),t(14978);let r=t(66995);function o(){let e=Error(r.NEXT_DYNAMIC_NO_SSR_CODE);throw e.digest=r.NEXT_DYNAMIC_NO_SSR_CODE,e}function i(e){let{children:n}=e;return n}},48607:function(){}},function(e){e.O(0,[470,730,744],function(){return e(e.s=86287)}),_N_E=e.O()}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[794],{34070:function(e,t,i){Promise.resolve().then(i.bind(i,73730))},49532:function(e,t,i){"use strict";let n,s;async function l(){if(n||(s||(s=fetch("/api/config").then(e=>e.json()).then(e=>n=e.apiBaseUrl)),await s),void 0===n)throw Error("API base URL is undefined");return n}i.d(t,{b:function(){return l}})},73730:function(e,t,i){"use strict";i.r(t),i.d(t,{default:function(){return P}});var n=i(24004),s=i(14978),l=i(49532),r=i(49567),c=i(30469),d=i(65068),a=i(70417),o=i(21303),h=i(61451),u=i(26485),x=i(30021),j=i(19708),Z=i(65969),v=i(38640),p=i.n(v),f=i(28891),m=i(40982),w=i(29794),y=i(22701),C=i(51956),g=i(82669),E=i(22689),k=i(63147),I=e=>{var t;let{openDialog:i,handleClose:s,selectedPrompt:l}=e;return(0,n.jsxs)(w.Z,{open:i,onClose:s,fullWidth:!0,maxWidth:"lg",children:[(0,n.jsxs)(g.Z,{children:["Prompt ",l.id.slice(0,6)]}),(0,n.jsxs)(C.Z,{children:[(0,n.jsx)(k.Z,{variant:"h6",style:{marginTop:"1rem"},children:"Prompt"}),(0,n.jsx)(E.Z,{readOnly:!0,value:null==l?void 0:null===(t=l.prompt)||void 0===t?void 0:t.raw,style:{width:"100%",padding:"0.75rem"},maxRows:50}),(0,n.jsx)(k.Z,{variant:"h6",style:{marginTop:"1rem"},children:"Used in..."}),(0,n.jsxs)(d.Z,{children:[(0,n.jsx)(u.Z,{children:(0,n.jsxs)(x.Z,{children:[(0,n.jsx)(o.Z,{children:"Eval ID"}),(0,n.jsx)(o.Z,{children:"Dataset ID"}),(0,n.jsx)(o.Z,{children:"Raw score"}),(0,n.jsx)(o.Z,{children:"Pass rate"}),(0,n.jsx)(o.Z,{children:"Pass count"}),(0,n.jsx)(o.Z,{children:"Fail count"})]})}),(0,n.jsx)(a.Z,{children:null==l?void 0:l.evals.sort((e,t)=>t.id.localeCompare(e.id)).map(e=>{var t,i,s,l,r,c,d;let a=null!==(r=null===(t=e.metrics)||void 0===t?void 0:t.testPassCount)&&void 0!==r?r:0,h=null!==(c=null===(i=e.metrics)||void 0===i?void 0:i.testFailCount)&&void 0!==c?c:0,u=a+h>0?(a/(a+h)*100).toFixed(2)+"%":"-";return(0,n.jsxs)(x.Z,{children:[(0,n.jsx)(o.Z,{children:(0,n.jsx)(p(),{href:"/eval/?evalId=".concat(e.id),children:e.id})}),(0,n.jsx)(o.Z,{children:(0,n.jsx)(p(),{href:"/datasets/?id=".concat(e.datasetId),children:e.datasetId.slice(0,6)})}),(0,n.jsx)(o.Z,{children:null!==(d=null===(l=e.metrics)||void 0===l?void 0:null===(s=l.score)||void 0===s?void 0:s.toFixed(2))&&void 0!==d?d:"-"}),(0,n.jsx)(o.Z,{children:u}),(0,n.jsx)(o.Z,{children:a}),(0,n.jsx)(o.Z,{children:h})]},"eval-".concat(e.id))})})]})]}),(0,n.jsx)(y.Z,{children:(0,n.jsx)(m.Z,{onClick:s,children:"Close"})})]})};function P(){let e=(0,f.useSearchParams)(),[t,i]=(0,s.useState)([]),[v,m]=(0,s.useState)("date"),[w,y]=(0,s.useState)("desc"),[C,g]=(0,s.useState)(1),[E,k]=(0,s.useState)(10),[P,S]=(0,s.useState)(!1),[D,b]=(0,s.useState)(0),_=e=>{let t=v===e&&"asc"===w?"desc":"asc";m(e),y(t)};(0,s.useEffect)(()=>{(async()=>{fetch("".concat(await (0,l.b)(),"/api/prompts")).then(e=>e.json()).then(e=>{let t=[...e.data].sort((e,t)=>null===v?0:"asc"===w?e[v]>t[v]?1:-1:e[v]<t[v]?1:-1);i(t)})})()},[v,w]);let F=e=>{S(!0),b(e)};return(0,s.useEffect)(()=>{let i=null==e?void 0:e.get("id");if(i){let e=t.findIndex(e=>e.id.startsWith(i));-1!==e&&F(e)}},[t,e]),(0,n.jsx)(r.Z,{paddingX:2,children:(0,n.jsxs)(h.Z,{children:[(0,n.jsxs)(d.Z,{children:[(0,n.jsx)(u.Z,{children:(0,n.jsxs)(x.Z,{children:[(0,n.jsx)(o.Z,{style:{width:"10%"},children:"ID"}),(0,n.jsx)(o.Z,{style:{width:"60%"},children:(0,n.jsx)(j.Z,{active:"raw"===v,direction:"raw"===v?w:"asc",onClick:()=>_("raw"),children:"Prompt"})}),(0,n.jsx)(o.Z,{style:{width:"20%"},children:(0,n.jsx)(Z.Z,{title:"The date of the most recent eval for this prompt",children:(0,n.jsx)(j.Z,{active:"date"===v,direction:"date"===v?w:"asc",onClick:()=>_("date"),children:"Most recent eval"})})}),(0,n.jsx)(o.Z,{style:{width:"10%"},children:(0,n.jsx)(j.Z,{active:"count"===v,direction:"count"===v?w:"asc",onClick:()=>_("count"),children:"# Evals"})})]})}),(0,n.jsx)(a.Z,{children:t.slice((C-1)*E,C*E).map((e,t)=>(0,n.jsxs)(x.Z,{hover:!0,children:[(0,n.jsx)(o.Z,{style:{width:"10%"},children:e.id.slice(0,6)}),(0,n.jsx)(o.Z,{style:{width:"60%",whiteSpace:"pre-wrap",cursor:"pointer"},onClick:()=>F(t),children:e.prompt.raw.length>500?e.prompt.raw.slice(0,500)+"...":e.prompt.raw}),(0,n.jsx)(o.Z,{style:{width:"20%"},children:e.recentEvalDate?(0,n.jsx)(p(),{href:"/eval?evalId=".concat(e.recentEvalId),children:e.recentEvalDate}):"Unknown"}),(0,n.jsx)(o.Z,{style:{width:"10%"},children:e.count})]},t))})]}),Math.ceil(t.length/E)>1&&(0,n.jsx)(c.Z,{count:Math.ceil(t.length/E),page:C,onChange:(e,t)=>g(t)}),t[D]&&(0,n.jsx)(I,{openDialog:P,handleClose:()=>{S(!1)},selectedPrompt:t[D]})]})})}}},function(e){e.O(0,[903,640,493,281,969,322,470,730,744],function(){return e(e.s=34070)}),_N_E=e.O()}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[420],{92892:function(e,i,t){Promise.resolve().then(t.bind(t,77087))},49532:function(e,i,t){"use strict";let a,s;async function r(){if(a||(s||(s=fetch("/api/config").then(e=>e.json()).then(e=>a=e.apiBaseUrl)),await s),void 0===a)throw Error("API base URL is undefined");return a}t.d(i,{b:function(){return r}})},77087:function(e,i,t){"use strict";t.r(i),t.d(i,{default:function(){return er}});var a,s,r=t(24004),n=t(14978),l=t(49532),o=t(49567),c=t(80661),d=t(885),m=t(11520),u=t(32414),h=t(63147),p=t(49578);let g={"Brand Risk":["competitors","politics","excessive-agency","hallucination","overreliance","harmful:graphic-content","harmful:indiscriminate-weapons","harmful:misinformation-disinformation","harmful:non-violent-crime","harmful:radicalization","harmful:unsafe-practices"],"Legal Risk":["harmful:child-exploitation","harmful:copyright-violations","harmful:cybercrime","harmful:illegal-activities","harmful:illegal-drugs","harmful:intellectual-property","harmful:privacy","harmful:sex-crime","harmful:sexual-content","harmful:specialized-advice","harmful:violent-crime","harmful:self-harm","rbac","contracts"],"Malicious Attacks":["harmful:harassment-bullying","harmful:hate","harmful:insults","harmful:profanity","hijacking","jailbreak","pii","prompt-injection","shell-injection","sql-injection","debug-access"]},f={"Brand Risk":"Risks that can affect the brand reputation and trustworthiness.","Legal Risk":"Risks that can lead to legal consequences or violations.","Malicious Attacks":"Risks involving malicious activities targeting the system or users."};(a=s||(s={})).Critical="Critical",a.High="High",a.Medium="Medium",a.Low="Low";let v={"debug-access":s.High,"excessive-agency":s.Medium,"harmful:child-exploitation":s.Critical,"harmful:copyright-violations":s.Medium,"harmful:cybercrime":s.High,"harmful:graphic-content":s.Medium,"harmful:harassment-bullying":s.High,"harmful:hate":s.Critical,"harmful:illegal-activities":s.High,"harmful:illegal-drugs":s.High,"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.High,"harmful:self-harm":s.Critical,"harmful:sex-crime":s.Critical,"harmful:sexual-content":s.High,"harmful:specialized-advice":s.High,"harmful:unsafe-practices":s.Low,"harmful:violent-crime":s.Critical,"prompt-injection":s.Medium,"shell-injection":s.High,"sql-injection":s.High,competitors:s.Low,contracts:s.Medium,hallucination:s.Medium,hijacking:s.High,jailbreak:s.Medium,overreliance:s.Low,pii:s.High,politics:s.Low,rbac:s.High},x=Object.entries(g).reduce((e,i)=>{let[t,a]=i;return a.forEach(i=>{e[i]=t}),e},{});Object.keys(x);let j={"debug-access":"DebugInterface","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",jailbreak:"Harmful/Iterative",overreliance:"Overreliance",pii:"PIILeak",politics:"PoliticalStatement",rbac:"RbacEnforcement"},y=Object.entries(j).reduce((e,i)=>{let[t,a]=i;return e[a]=t,e},{}),b={"excessive-agency":"Excessive Agency","prompt-injection":"Prompt Injection",competitors:"Competitor Endorsements",contracts:"Unsupervised Contracts",jailbreak:"Jailbreak",pii:"PII Leaks",politics:"Political Opinions","shell-injection":"Shell Injection","sql-injection":"SQL Injection",rbac:"RBAC Enforcement","debug-access":"Debug Access","harmful:specialized-advice":"Specialized Advice","harmful:illegal-activities":"Illegal Activities","harmful:cybercrime":"Cybercrime","harmful:copyright-violations":"Copyright Violations","harmful:misinformation-disinformation":"Misinformation & disinformation"},w={"excessive-agency":"Model taking excessive initiative or misunderstanding its capabilities.","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.","prompt-injection":"Malicious inputs designed to manipulate the model's behavior.",competitors:"Competitor mentions and endorsements",contracts:"Enters business or legal commitments without supervision.",hallucination:"Model generating false or misleading information.",hijacking:"Unauthorized or off-topic resource use.",jailbreak:"Bypassing security measures or restrictions.",overreliance:"Model susceptible to relying on an incorrect user assumption or input.",pii:"Exposure or misuse of personally identifiable information.",politics:"Makes political statements.","experimental-jailbreak":"Apply jailbreaks to all attack types","sql-injection":"Attempts to perform SQL injection attacks to manipulate database queries.","shell-injection":"Attempts to execute shell commands through the model.","debug-access":"Attempts to access or use debugging commands.",rbac:"Tests whether the model properly implements Role-Based Access Control (RBAC)."};t(4309);var C=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)=>v[i]===t?e+1:e,0),e),{});return(0,r.jsx)(u.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)(p.Z,{onClick:()=>window.location.hash="#table",children:[(0,r.jsx)(h.Z,{variant:"h6",gutterBottom:!0,children:e}),(0,r.jsx)(h.Z,{variant:"h4",color:"text.primary",children:a[e]}),(0,r.jsx)(h.Z,{variant:"body2",color:"text.secondary",children:"issues"})]})})},e))})},k=t(75307),Z=t(40982),R=t(29794),P=t(22701),A=t(51956),I=t(82669),S=t(77656),L=t(97540),M=t(37204),F=t(79685),H=t(74595);let N={getItem:async e=>await (0,M.U2)(e)||null,setItem:async(e,i)=>{await (0,M.t8)(e,i)},removeItem:async e=>{await (0,M.IV)(e)}},z=(0,F.Ue)()((0,H.tJ)(e=>({showPercentagesOnRiskCards:!1,setShowPercentagesOnRiskCards:i=>e(()=>({showPercentagesOnRiskCards:i})),pluginPassRateThreshold:1,setPluginPassRateThreshold:i=>e(()=>({pluginPassRateThreshold:i}))}),{name:"ReportViewStorage",storage:(0,H.FL)(()=>N)}));var E=()=>{let{showPercentagesOnRiskCards:e,setShowPercentagesOnRiskCards:i,pluginPassRateThreshold:t,setPluginPassRateThreshold:a}=z(),[s,l]=n.useState(!1),o=()=>{l(!1)};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(S.Z,{onClick:()=>{l(!0)},sx:{position:"absolute",top:8,right:8},"aria-label":"settings",children:(0,r.jsx)(k.Z,{})}),(0,r.jsxs)(R.Z,{open:s,onClose:o,fullWidth:!0,maxWidth:"sm",children:[(0,r.jsx)(I.Z,{children:"Report Settings"}),(0,r.jsxs)(A.Z,{children:[(0,r.jsx)(h.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)(h.Z,{component:"div",sx:{padding:"16px 0"},children:[(0,r.jsxs)("label",{children:["Plugin Pass Rate Threshold: ",(100*t).toFixed(0),"%"]}),(0,r.jsx)(h.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)(L.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)(P.Z,{children:(0,r.jsx)(Z.Z,{onClick:o,variant:"contained",color:"primary",children:"Close"})})]})]})},D=t(63362),U=t(18845),O=t(93650),W=t(47908),T=t(85912),B=t(94941),q=t(65969),V=t(96761);t(46553);var _=e=>{let{title:i,subtitle:t,progressValue:a,numTestsPassed:s,numTestsFailed:n,testTypes:l}=e,{showPercentagesOnRiskCards:d,pluginPassRateThreshold:m}=z();return(0,r.jsx)(c.Z,{children:(0,r.jsx)(p.Z,{className:"risk-card-container",children:(0,r.jsxs)(O.ZP,{container:!0,spacing:3,children:[(0,r.jsxs)(O.ZP,{item:!0,xs:12,md:6,style:{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center"},children:[(0,r.jsx)(h.Z,{variant:"h5",className:"risk-card-title",children:i}),(0,r.jsx)(h.Z,{variant:"subtitle1",color:"textSecondary",mb:2,children:t}),(0,r.jsx)(o.Z,{sx:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",width:100,height:100},children:(0,r.jsx)(V.a,{value:a,max:100,thickness:10,arc:{startAngle:-90,endAngle:90,color:"primary.main"},text:"".concat(Math.round(a),"%"),sx:{width:"100%",height:"100%"}})}),(0,r.jsxs)(h.Z,{variant:"h6",className:"risk-card-issues",children:[n," failed probes"]}),(0,r.jsxs)(h.Z,{variant:"subtitle1",color:"textSecondary",className:"risk-card-tests-passed",children:[s,"/",s+n," passed"]})]}),(0,r.jsx)(O.ZP,{item:!0,xs:6,md:4,children:(0,r.jsx)(W.Z,{dense:!0,children:l.map((e,i)=>(0,r.jsx)(q.Z,{title:w[e.name],placement:"left",arrow:!0,children:(0,r.jsxs)(T.ZP,{className:"risk-card-list-item",onClick:()=>{let i=new URLSearchParams(window.location.search),t=i.get("evalId"),a=j[e.name];window.location.href="/eval/?evalId=".concat(t,"&search=").concat(encodeURIComponent("(var=".concat(a,"|metric=").concat(a,")")))},style:{cursor:"pointer"},children:[(0,r.jsx)(B.Z,{primary:b[e.name]||j[e.name],primaryTypographyProps:{variant:"body2"}}),d?(0,r.jsx)(h.Z,{variant:"body2",className:"risk-card-percentage ".concat(e.percentage>=.8?"risk-card-percentage-high":e.percentage>=.5?"risk-card-percentage-medium":"risk-card-percentage-low"),children:"".concat(Math.round(100*e.percentage),"%")}):e.percentage>m?(0,r.jsx)(U.Z,{className:"risk-card-icon-passed"}):(0,r.jsx)(D.Z,{className:"risk-card-icon-failed"})]})},i))})})]})})})};t(32991);var J=e=>{let{categoryStats:i}=e,t=Object.keys(g).map(e=>({name:e,passed:g[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)(u.Z,{spacing:4,children:t.map((e,t)=>{let a=e.name,s=g[a],n=s.reduce((e,t)=>{var a;return e+((null===(a=i[t])||void 0===a?void 0:a.pass)||0)},0),l=s.reduce((e,t)=>{var a;return e+((null===(a=i[t])||void 0===a?void 0:a.total)||0)},0);return(0,r.jsx)(_,{title:e.name,subtitle:f[a],progressValue:n/l*100,numTestsPassed:n,numTestsFailed:l-n,testTypes:s.map(e=>{var t,a,s,r;return{name:e,passed:(null===(t=i[e])||void 0===t?void 0:t.pass)===(null===(a=i[e])||void 0===a?void 0:a.total),percentage:((null===(s=i[e])||void 0===s?void 0:s.pass)||1)/((null===(r=i[e])||void 0===r?void 0:r.total)||1)}})},t)})})},Q=t(65068),G=t(70417),K=t(21303),X=t(61451),Y=t(26485),$=t(38592),ee=t(30021),ei=t(19708),et=t(28891);t(93091);let ea=e=>{let i=[];for(let[t,a]of Object.entries(g))for(let t of a)i.push({pluginName:t,type:j[t]||t,description:w[t]||"",passRate:e[t]?(e[t].pass/e[t].total*100).toFixed(1)+"%":"N/A",passRateWithFilter:e[t]?(e[t].passWithFilter/e[t].total*100).toFixed(1)+"%":"N/A",severity:v[t]||"Unknown"});return i.sort((e,i)=>"N/A"===e.passRate?1:"N/A"===i.passRate?-1:parseFloat(e.passRate)-parseFloat(i.passRate))};var es=e=>{let{evalId:i,categoryStats:t}=e;(0,et.useRouter)();let a=ea(t).filter(e=>"N/A"!==e.passRate),[s,l]=n.useState(0),[c,d]=n.useState(10),[m,u]=n.useState("asc"),[p,g]=n.useState("default"),f=e=>{let i=p===e&&"asc"===m;u(i?"desc":"asc"),g(e)};return(0,r.jsxs)(o.Z,{children:[(0,r.jsx)(h.Z,{variant:"h5",gutterBottom:!0,id:"table",children:"Vulnerabilities and Mitigations"}),(0,r.jsxs)(X.Z,{children:[(0,r.jsxs)(Q.Z,{children:[(0,r.jsx)(Y.Z,{children:(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(K.Z,{children:"Type"}),(0,r.jsx)(K.Z,{children:"Description"}),(0,r.jsx)(K.Z,{children:(0,r.jsx)(ei.Z,{active:"passRate"===p,direction:"passRate"===p?m:"asc",onClick:()=>f("passRate"),children:"Pass rate"})}),(0,r.jsx)(K.Z,{children:(0,r.jsx)(ei.Z,{active:"severity"===p,direction:"severity"===p?m:"asc",onClick:()=>f("severity"),children:"Severity"})}),(0,r.jsx)(K.Z,{style:{minWidth:"275px"},children:"Actions"})]})}),(0,r.jsx)(G.Z,{children:a.sort((e,i)=>{if("passRate"===p)return"N/A"===e.passRate?1:"N/A"===i.passRate?-1:"asc"===m?parseFloat(e.passRate)-parseFloat(i.passRate):parseFloat(i.passRate)-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?parseFloat(e.passRate)-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=parseFloat(e.passRate);t=i>=75?"pass-high":i>=50?"pass-medium":"pass-low"}return(0,r.jsxs)(ee.Z,{children:[(0,r.jsx)(K.Z,{children:(0,r.jsx)("span",{style:{fontWeight:500},children:b[e.pluginName]||e.type})}),(0,r.jsx)(K.Z,{children:e.description}),(0,r.jsxs)(K.Z,{className:t,children:[(0,r.jsx)("strong",{children:e.passRate}),e.passRateWithFilter!==e.passRate?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("br",{}),"(",e.passRateWithFilter," with mitigation)"]}):null]}),(0,r.jsx)(K.Z,{className:"vuln-".concat(e.severity.toLowerCase()),children:e.severity}),(0,r.jsxs)(K.Z,{style:{minWidth:270},children:[(0,r.jsx)(Z.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)(q.Z,{title:"Temporarily disabled while in beta, click to contact us to enable",children:(0,r.jsx)(Z.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)($.Z,{rowsPerPageOptions:[10,25,50],component:"div",count:a.length,rowsPerPage:c,page:s,onPageChange:(e,i)=>{l(i)},onRowsPerPageChange:e=>{d(parseInt(e.target.value,10)),l(0)}})]})]})};t(67667);var er=()=>{let[e,i]=n.useState(null),[t,a]=n.useState(null);if(n.useEffect(()=>{let e=async e=>{let i=await fetch("".concat(await (0,l.b)(),"/api/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))},[]),!t||!e)return(0,r.jsx)(o.Z,{sx:{width:"100%",textAlign:"center"},children:"Loading..."});let s=t.results.table.head.prompts[0],p=t.results.table.body,g=t.results.results.reduce((e,i)=>{var t,a,s,r,n,l,o,c;let d=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}))||[],u=[d,...m].filter(e=>e);for(let t of u){let a=y[t];if(!a){console.log("Unknown harm category:",t);break}i.success;let d=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;let t=(null===(i=e.assertion)||void 0===i?void 0:i.type)==="llm-rubric",a=e.pass;return t&&a}),u=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||u?(e[a].pass++,e[a].passWithFilter++):!d&&e[a].passWithFilter++}return e},{});return(0,r.jsx)(m.Z,{children:(0,r.jsxs)(u.Z,{spacing:4,pb:8,pt:2,children:[(0,r.jsxs)(c.Z,{className:"report-header",sx:{position:"relative"},children:[(0,r.jsx)(E,{}),(0,r.jsxs)(h.Z,{variant:"h4",children:[(0,r.jsx)("strong",{children:"LLM Risk Assessment"}),t.config.description&&": ".concat(t.config.description)]}),(0,r.jsx)(h.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)(d.Z,{size:"small",label:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("strong",{children:"Model:"})," ",s.provider]})}),(0,r.jsx)(d.Z,{size:"small",label:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("strong",{children:"Dataset:"})," ",p.length," probes"]})}),(0,r.jsx)(d.Z,{size:"small",label:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("strong",{children:"Prompt:"}),' "',s.raw.length>40?"".concat(s.raw.substring(0,40),"..."):s.raw,'"']})})]})]}),(0,r.jsx)(C,{categoryStats:g}),(0,r.jsx)(J,{categoryStats:g}),(0,r.jsx)(es,{evalId:e,categoryStats:g})]})})}},4309:function(){},67667:function(){},46553:function(){},32991:function(){},93091:function(){}},function(e){e.O(0,[903,916,493,304,281,969,378,476,515,69,470,730,744],function(){return e(e.s=92892)}),_N_E=e.O()}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[413],{92739:function(e,t,n){Promise.resolve().then(n.bind(n,83013))},83013:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return ep}});var a=n(24004),i=n(14978),r=n(69179),l=n(47887),s=n(49567),o=n(40982),c=n(11520),d=n(29794),p=n(22701),u=n(51956),h=n(8541),m=n(82669),x=n(32414),f=n(63147),g=n(75307),j=n(63346),v=n(89235),Z=n(4078),b=n(67339),y=()=>{let{env:e,setEnv:t}=(0,l.o)(),[n,r]=(0,i.useState)(!1),[s,c]=(0,i.useState)(e),h=()=>{r(!1)};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(o.Z,{variant:"outlined",startIcon:(0,a.jsx)(g.Z,{}),onClick:()=>{r(!0)},children:"API keys"}),(0,a.jsxs)(d.Z,{open:n,onClose:h,fullWidth:!0,maxWidth:"md",children:[(0,a.jsx)(m.Z,{children:"Provider settings"}),(0,a.jsxs)(u.Z,{children:[(0,a.jsxs)(j.Z,{defaultExpanded:!0,children:[(0,a.jsx)(Z.Z,{children:"OpenAI"}),(0,a.jsxs)(v.Z,{children:[(0,a.jsx)(b.Z,{label:"OpenAI API key",fullWidth:!0,margin:"normal",value:s.OPENAI_API_KEY,onChange:e=>c({...s,OPENAI_API_KEY:e.target.value})}),(0,a.jsx)(b.Z,{label:"OpenAI API host",fullWidth:!0,margin:"normal",value:s.OPENAI_API_HOST,onChange:e=>c({...s,OPENAI_API_HOST:e.target.value})}),(0,a.jsx)(b.Z,{label:"OpenAI organization",fullWidth:!0,margin:"normal",value:s.OPENAI_ORGANIZATION,onChange:e=>c({...s,OPENAI_ORGANIZATION:e.target.value})})]})]}),(0,a.jsxs)(j.Z,{children:[(0,a.jsx)(Z.Z,{children:"Azure"}),(0,a.jsx)(v.Z,{children:(0,a.jsx)(b.Z,{label:"Azure API key",fullWidth:!0,margin:"normal",value:s.AZURE_OPENAI_API_KEY,onChange:e=>c({...s,AZURE_OPENAI_API_KEY:e.target.value})})})]}),(0,a.jsxs)(j.Z,{children:[(0,a.jsx)(Z.Z,{children:"Amazon Bedrock"}),(0,a.jsx)(v.Z,{children:(0,a.jsx)(b.Z,{label:"Bedrock Region",fullWidth:!0,margin:"normal",value:s.AWS_BEDROCK_REGION,onChange:e=>c({...s,AWS_BEDROCK_REGION:e.target.value})})})]}),(0,a.jsxs)(j.Z,{children:[(0,a.jsx)(Z.Z,{children:"Anthropic"}),(0,a.jsx)(v.Z,{children:(0,a.jsx)(b.Z,{label:"Anthropic API key",fullWidth:!0,margin:"normal",value:s.ANTHROPIC_API_KEY,onChange:e=>c({...s,ANTHROPIC_API_KEY:e.target.value})})})]}),(0,a.jsxs)(j.Z,{children:[(0,a.jsx)(Z.Z,{children:"Google Vertex AI"}),(0,a.jsx)(v.Z,{children:(0,a.jsx)(b.Z,{label:"Vertex API Key",fullWidth:!0,margin:"normal",value:s.VERTEX_API_KEY,onChange:e=>c({...s,VERTEX_API_KEY:e.target.value})})}),(0,a.jsx)(v.Z,{children:(0,a.jsx)(b.Z,{label:"Vertex Project ID",fullWidth:!0,margin:"normal",value:s.VERTEX_PROJECT_ID,onChange:e=>c({...s,VERTEX_PROJECT_ID:e.target.value})})}),(0,a.jsx)(v.Z,{children:(0,a.jsx)(b.Z,{label:"Vertex Region",fullWidth:!0,margin:"normal",value:s.VERTEX_REGION,onChange:e=>c({...s,VERTEX_REGION:e.target.value})})})]}),(0,a.jsxs)(j.Z,{children:[(0,a.jsx)(Z.Z,{children:"Replicate"}),(0,a.jsx)(v.Z,{children:(0,a.jsx)(b.Z,{label:"Replicate API key",fullWidth:!0,margin:"normal",value:s.REPLICATE_API_KEY,onChange:e=>c({...s,REPLICATE_API_KEY:e.target.value})})})]})]}),(0,a.jsxs)(p.Z,{children:[(0,a.jsx)(o.Z,{onClick:h,color:"primary",children:"Cancel"}),(0,a.jsx)(o.Z,{onClick:()=>{t(s),h()},color:"primary",variant:"contained",children:"Save"})]})]})]})},_=n(35185),C=n(5592),k=n(14931),A=n(2185),E=n(77656),I=n(65068),O=n(70417),S=n(21303),P=n(61451),T=n(30021),w=n(65969),R=e=>{let{open:t,prompt:n,index:r,onAdd:l,onCancel:s}=e,[c,h]=i.useState(n),x=i.useRef(null);i.useEffect(()=>{h(n)},[n]);let f=e=>{l(c),h(""),e?s():x.current&&x.current.focus()};return(0,a.jsxs)(d.Z,{open:t,onClose:s,fullWidth:!0,maxWidth:"md",children:[(0,a.jsx)(m.Z,{children:"Edit Prompt ".concat(r+1)}),(0,a.jsx)(u.Z,{children:(0,a.jsx)(b.Z,{value:c,onChange:e=>h(e.target.value),fullWidth:!0,margin:"normal",multiline:!0,placeholder:"The quick brown {{animal1}} jumps over the lazy {{animal2}}.",helperText:"Tip: use the {{varname}} syntax to add variables to your prompt.",inputRef:x})}),(0,a.jsxs)(p.Z,{children:[(0,a.jsx)(o.Z,{onClick:f.bind(null,!0),color:"primary",variant:"contained",disabled:!c.length,children:"Add"}),(0,a.jsx)(o.Z,{onClick:f.bind(null,!1),color:"primary",variant:"contained",disabled:!c.length,children:"Add Another"}),(0,a.jsx)(o.Z,{onClick:s,color:"secondary",children:"Cancel"})]})]})};n(94499);var W=()=>{let[e,t]=(0,i.useState)(!1),[n,r]=(0,i.useState)(null),{prompts:s,setPrompts:c}=(0,l.o)(),d=(0,i.useRef)(null);(0,i.useEffect)(()=>{null!==n&&n>0&&d.current&&d.current.focus()},[n]);let p=e=>{r(e),t(!0)},u=(e,t)=>{e.stopPropagation();let n=s[t];c([...s,n])},h=(e,t)=>{c(s.map((n,a)=>a===e?t:n))},m=(e,t)=>{e.stopPropagation(),confirm("Are you sure you want to remove this prompt?")&&c(s.filter((e,n)=>n!==t))};return(0,a.jsxs)("div",{children:[(0,a.jsxs)(x.Z,{direction:"row",spacing:2,mb:2,justifyContent:"space-between",children:[(0,a.jsx)(f.Z,{variant:"h5",children:"Prompts"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{htmlFor:"file-input-add-prompt",children:(0,a.jsx)(w.Z,{title:"Upload prompt from file",children:(0,a.jsxs)("span",{children:[(0,a.jsx)(E.Z,{component:"span",children:(0,a.jsx)(A.Z,{})}),(0,a.jsx)("input",{id:"file-input-add-prompt",type:"file",accept:".txt,.md",onChange:e=>{var t;e.stopPropagation(),e.preventDefault();let n=null===(t=e.target.files)||void 0===t?void 0:t[0];if(n){let e=new FileReader;e.onload=e=>{var t,n;let a=null===(n=e.target)||void 0===n?void 0:null===(t=n.result)||void 0===t?void 0:t.toString();a&&c([...s,a])},e.readAsText(n)}},style:{display:"none"}})]})})}),(0,a.jsx)(o.Z,{color:"primary",onClick:()=>{t(!0)},variant:"contained",children:"Add Prompt"})]})]}),(0,a.jsx)(P.Z,{children:(0,a.jsx)(I.Z,{children:(0,a.jsx)(O.Z,{children:0===s.length?(0,a.jsx)(T.Z,{children:(0,a.jsx)(S.Z,{colSpan:2,align:"center",children:"No prompts added yet."})}):s.map((e,t)=>(0,a.jsxs)(T.Z,{sx:{"&:hover":{backgroundColor:"rgba(0, 0, 0, 0.04)",cursor:"pointer"}},onClick:()=>p(t),children:[(0,a.jsx)(S.Z,{children:(0,a.jsxs)(f.Z,{variant:"body2",children:["Prompt #".concat(t+1,": "),(e.length>250?e.slice(0,250)+" ...":e).split(/({{\w+}})/g).map((e,t)=>/{{\s*(\w+)\s*}}/g.test(e)?(0,a.jsx)("span",{className:"prompt-var-highlight",children:e},t):e)]})}),(0,a.jsxs)(S.Z,{align:"right",sx:{minWidth:150},children:[(0,a.jsx)(E.Z,{onClick:()=>p(t),size:"small",children:(0,a.jsx)(k.Z,{})}),(0,a.jsx)(E.Z,{onClick:e=>u(e,t),size:"small",children:(0,a.jsx)(_.Z,{})}),(0,a.jsx)(E.Z,{onClick:e=>m(e,t),size:"small",children:(0,a.jsx)(C.Z,{})})]})]},t))})})}),(0,a.jsx)(R,{open:e,prompt:null!==n?s[n]:"",index:null!==n?n:0,onAdd:e=>{null!==n?h(n,e):c([...s,e]),r(null)},onCancel:()=>{r(null),t(!1)}})]})},N=n(77155),z=n(885),F=e=>{let{onChange:t,...n}=e,[r,l]=i.useState(""),[s,o]=i.useState(!1);return(0,a.jsx)(b.Z,{...n,error:s,helperText:s?"Invalid JSON":"",value:r,onChange:e=>{let n=e.target.value;try{let e=JSON.parse(n);l(n),o(!1),t&&t(e)}catch(e){l(n),o(!0)}}})},V=e=>{let{open:t,providerId:n,config:r,onClose:l,onSave:c}=e,[h,x]=i.useState(r);return i.useEffect(()=>{x(r)},[r]),(0,a.jsxs)(d.Z,{open:t,onClose:l,fullWidth:!0,maxWidth:"md",children:[(0,a.jsxs)(m.Z,{children:["Edit ",n.length>50?n.slice(0,50)+"...":n]}),(0,a.jsx)(u.Z,{children:Object.keys(h).map(e=>{let t;let n=h[e];return"number"==typeof n||"boolean"==typeof n||"string"==typeof n?(t="number"==typeof n?t=>x({...h,[e]:parseFloat(t.target.value)}):"boolean"==typeof n?t=>x({...h,[e]:"true"===t.target.value}):t=>{let n=t.target.value.trim();if(n.startsWith("{")||n.startsWith("["))try{x({...h,[e]:JSON.parse(n)})}catch(t){x({...h,[e]:n})}else"null"===n?x({...h,[e]:null}):"undefined"===n?x({...h,[e]:void 0}):x({...h,[e]:n})},(0,a.jsx)(s.Z,{my:2,children:(0,a.jsx)(b.Z,{label:e,value:n,onChange:t,fullWidth:!0,InputLabelProps:{shrink:!0},type:"number"==typeof n?"number":"text"})},e)):(0,a.jsx)(s.Z,{my:2,children:(0,a.jsx)(F,{label:e,defaultValue:JSON.stringify(n),onChange:t=>{x({...h,[e]:t})},fullWidth:!0,multiline:!0,minRows:2,InputLabelProps:{shrink:!0}})},e)})}),(0,a.jsxs)(p.Z,{children:[(0,a.jsx)(o.Z,{onClick:l,children:"Cancel"}),(0,a.jsx)(o.Z,{onClick:()=>{c(h)},children:"Save"})]})]})};let L=[].concat(["replicate:replicate/flan-t5-small:69716ad8c34274043bf4a135b7315c7c569ec931d8f23d6826e249e1c142a264"].map(e=>({id:e,config:{temperature:.5,max_length:1024,repetition_penality:1}}))).concat(["replicate:replicate/codellama-7b-instruct:0103579e86fc75ba0d65912890fa19ef03c84a68554635319accf2e0ba93d3ae","replicate:replicate/codellama-13b-instruct:da5676342de1a5a335b848383af297f592b816b950a43d251a0a9edd0113604b","replicate:replicate/llama-2-70b-chat:2796ee9483c3fd7aa2e171d38f4ca12251a30609463dcfd4cd76703f22e96cdf"].map(e=>({id:e,config:{system_prompt:"",temperature:.75,top_p:.9,top_k:50,max_new_tokens:128,min_new_tokens:-1}}))).concat(["replicate:replicate/codellama-7b:6880b103613a9cd23950c5fd6c140197e519905bd0dd00e448c4858bdd06090a","replicate:replicate/codellama-13b-python:09b87c02dfa403e0c3289166dece62286b3bce49bae39a9c9204713cf94b8b7d","replicate:replicate/codellama-13b:1c914d844307b0588599b8393480a3ba917b660c7e9dfae681542b5325f228db","replicate:replicate/codellama-34b-python:9048743d22a7b19cd0abb018066809ea6af4f2b4717bef9aad3c5ae21ceac00d","replicate:replicate/codellama-34b:0666717e5ead8557dff55ee8f11924b5c0309f5f1ca52f64bb8eec405fdb38a7"].map(e=>({id:e,config:{temperature:.75,top_p:.9,top_k:50,max_new_tokens:128,min_new_tokens:-1}}))).concat(["replicate:a16z-infra/llama-2-7b-chat:7b0bfc9aff140d5b75bacbed23e91fd3c34b01a1e958d32132de6e0a19796e2c","replicate:a16z-infra/llama-2-13b-chat:2a7f981751ec7fdf87b5b91ad4db53683a98082e9ff7bfd12c8cd5ea85980a52"].map(e=>({id:e,config:{temperature:.95,top_p:.95,top_k:250,max_new_tokens:500,min_new_tokens:-1,repetition_penalty:1,system_prompt:""}}))).concat(["replicate:mistralai/mistral-7b-v0.1","replicate:mistralai/mistral-7b-instruct-v0.2","replicate:mistralai/mixtral-8x7b-instruct-v0.1"].map(e=>({id:e,config:{temperature:.7,top_p:.9,top_k:-1,max_new_tokens:128,min_new_tokens:-1,repetition_penalty:1.15,prompt_template:"{prompt}"}}))).concat(["anthropic:claude-1","anthropic:claude-1-100k","anthropic:claude-instant-1","anthropic:claude-instant-1-100k"].map(e=>({id:e,config:{max_tokens_to_sample:256,temperature:.5}}))).concat(["anthropic:messages:claude-instant-1.2","anthropic:messages:claude-2.0","anthropic:messages:claude-2.1","anthropic:messages:claude-3-haiku-20240307","anthropic:messages:claude-3-sonnet-20240229","anthropic:messages:claude-3-opus-20240229"].map(e=>({id:e,config:{max_tokens:1024,temperature:.5}}))).concat(["bedrock:anthropic.claude-instant-v1","bedrock:anthropic.claude-v1","bedrock:anthropic.claude-v2"].map(e=>({id:e,config:{max_tokens_to_sample:256,temperature:.5}}))).concat(["openai:gpt-4o","openai:gpt-4o-2024-05-13","openai:gpt-4o-mini","openai:gpt-4o-mini-2024-07-18","openai:gpt-4-turbo","openai:gpt-4-turbo-2024-04-09","openai:gpt-4-turbo-preview","openai:gpt-4-0125-preview","openai:gpt-4-1106-preview","openai:gpt-4","openai:gpt-4-0613","openai:gpt-3.5-turbo","openai:gpt-3.5-turbo-0125","openai:gpt-3.5-turbo-1106","openai:gpt-3.5-turbo-instruct"].map(e=>({id:e,config:{organization:"",temperature:.5,max_tokens:1024,top_p:1,frequency_penalty:0,presence_penalty:0,function_call:void 0,functions:void 0,stop:void 0}}))).concat(["azureopenai:gpt-3.5-turbo","azureopenai:gpt-3.5-turbo-0301","azureopenai:gpt-3.5-turbo-0613","azureopenai:gpt-3.5-turbo-16k","azureopenai:gpt-3.5-turbo-16k-0613","azureopenai:gpt-4","azureopenai:gpt-4-0314","azureopenai:gpt-4-0613","azureopenai:gpt-4-32k","azureopenai:gpt-4-32k-0314"].map(e=>({id:e,config:{temperature:.5,max_tokens:1024,top_p:1,frequency_penalty:0,presence_penalty:0,function_call:void 0,functions:void 0,stop:void 0}}))).concat(["vertex:chat-bison@001","vertex:chat-bison","vertex:chat-bison-32k","vertex:chat-bison-32k@001"].map(e=>({id:e,config:{context:void 0,examples:void 0,temperature:0,maxOutputTokens:1024,topP:.95,topK:40,safetySettings:void 0,stopSequence:void 0}}))).sort((e,t)=>e.id.localeCompare(t.id)),U={anthropic:"Anthropic",bedrock:"Amazon Web Services",azureopenai:"Azure",openai:"OpenAI",replicate:"Replicate"};var q=e=>{let{providers:t,onChange:n}=e,[r,l]=i.useState(null),o=e=>"string"==typeof e?e:e.id||"Unknown provider",c=(e,t)=>"string"==typeof e?e:e.id||t,d=e=>{"string"==typeof e?alert("Cannot edit custom providers"):e.config?l(e):alert("There is no config for this provider")};return(0,a.jsxs)(s.Z,{mt:2,children:[(0,a.jsx)(N.Z,{multiple:!0,freeSolo:!0,options:L,value:t,groupBy:e=>(function(e){if(!e)return"Other";let t=e.split(":")[0];return U[t]||t})(e.id),onChange:(e,t)=>{n(t.map(e=>"string"==typeof e?{id:e}:e))},getOptionLabel:e=>{if(!e)return"";let t="";"string"==typeof e&&(t=e),e.id&&"string"==typeof e.id&&(t=e.id);let n=t.split(":");return n.length>1?n.length>2&&"anthropic"===n[0]?n[2]:n[1]:"Unknown provider"},renderTags:(e,t)=>e.map((e,n)=>{let a=o(e),r=c(e,n);return(0,i.createElement)(z.Z,{variant:"outlined",label:a,...t({index:n}),key:r,onClick:()=>d(e)})}),renderInput:e=>(0,a.jsx)(b.Z,{...e,variant:"outlined",placeholder:"Select LLM providers",helperText:t.length>0?"Click a provider to configure its settings.":null})}),r&&r.id&&(0,a.jsx)(V,{open:!!r,providerId:r.id,config:r.config,onClose:()=>l(null),onSave:e=>{if(r){let a=t.map(t=>t.id===r.id?{...t,config:e}:t);n(a),l(null)}}})]})},B=n(52428),K=n(11615),D=n(28891),Y=()=>{let e=(0,D.useRouter)(),{defaultTest:t,description:n,env:r,evaluateOptions:s,prompts:c,providers:d,scenarios:p,testCases:u}=(0,l.o)(),[h,m]=(0,i.useState)(!1),[x,f]=(0,i.useState)(0),g=async()=>{m(!0);try{let a=await fetch("".concat(B.eA,"/api/eval/job/"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({defaultTest:t,description:n,env:r,evaluateOptions:s,prompts:c,providers:d,scenarios:p,tests:u})});if(!a.ok)throw Error("HTTP error! status: ".concat(a.status));let i=await a.json(),l=setInterval(async()=>{let t=await fetch("".concat(B.eA,"/api/eval/job/").concat(i.id,"/"));if(!t.ok)throw clearInterval(l),Error("HTTP error! status: ".concat(t.status));let n=await t.json();if("complete"===n.status)clearInterval(l),m(!1),B.Ox?e.push("/eval/remote:".concat(encodeURIComponent(i.id))):e.push("/eval");else if("failed"===n.status)throw clearInterval(l),m(!1),Error("Job failed");else{let e=0===n.total?0:Math.round(n.progress/n.total*100);f(e)}},1e3)}catch(e){console.error(e),m(!1),alert("An error occurred: ".concat(e.message))}};return(0,a.jsx)(o.Z,{variant:"contained",color:"primary",onClick:g,disabled:h,children:h?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(K.Z,{size:24,sx:{marginRight:2}}),x.toFixed(0),"% complete"]}):"Run Evaluation"})},J=n(15320),X=n(26485);let G=["equals","contains","icontains","contains-all","contains-any","starts-with","regex","is-json","contains-json","is-sql","contains-sql","similar","llm-rubric","model-graded-closedqa","factuality","webhook","rouge-n","rouge-s","rouge-l","not-equals","not-contains","not-icontains","not-contains-all","not-contains-any","not-starts-with","not-regex","not-is-json","not-contains-json","not-similar","not-webhook","not-rouge-n","not-rouge-s","not-rouge-l","is-valid-openai-function-call","is-valid-openai-tools-call","latency","perplexity","perplexity-score","cost","answer-relevance","context-faithfulness","context-recall","context-relevance","select-best","moderation"];var H=e=>{let{onAdd:t,initialValues:n}=e,[r,l]=(0,i.useState)(n||[]),c=e=>{let n=r.filter((t,n)=>n!==e);l(n),t(n)};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(f.Z,{variant:"h6",children:"Asserts"}),(0,a.jsx)(s.Z,{my:r.length>0?2:0,children:(0,a.jsx)(x.Z,{direction:"column",spacing:2,children:r.map((e,n)=>(0,a.jsxs)(x.Z,{direction:"row",spacing:2,alignItems:"center",children:[(0,a.jsx)(N.Z,{value:e.type,options:G,sx:{minWidth:200},onChange:(e,a)=>{let i=r.map((e,t)=>t===n?{...e,type:a}:e);l(i),t(i)},renderInput:e=>(0,a.jsx)(b.Z,{...e,label:"Type"})}),(0,a.jsx)(b.Z,{label:"Value",value:e.value,fullWidth:!0,onChange:e=>{let a=e.target.value,i=r.map((e,t)=>t===n?{...e,value:a}:e);l(i),t(i)}}),(0,a.jsx)(E.Z,{onClick:()=>c(n),size:"small",children:(0,a.jsx)(C.Z,{})})]},n))})}),(0,a.jsx)(o.Z,{color:"primary",onClick:()=>{let e=[...r,{type:"equals",value:""}];l(e),t(e)},children:"Add Assert"})]})},M=e=>{let{onAdd:t,varsList:n,initialValues:r}=e,[l,o]=i.useState(r||{});return(0,i.useEffect)(()=>{let e={};n.forEach(t=>{e[t]=(null==r?void 0:r[t])||""}),o(e)},[n,r]),(0,a.jsxs)(s.Z,{my:2,children:[(0,a.jsx)(f.Z,{variant:"h6",mb:2,children:"Vars"}),n.length>0?(0,a.jsx)(x.Z,{direction:"row",spacing:2,alignItems:"center",children:Object.keys(l).map((e,n)=>(0,a.jsx)(x.Z,{direction:"row",spacing:2,alignItems:"center",children:(0,a.jsx)(b.Z,{placeholder:e,label:e,value:l[e],fullWidth:!0,onChange:n=>{let a=n.target.value,i={...l,[e]:a};o(i),t(i)}})},n))}):(0,a.jsxs)(f.Z,{variant:"subtitle1",gutterBottom:!0,children:["Add variables to your prompt using the ","{{varname}}"," syntax."]})]})},$=e=>{let{open:t,onAdd:n,varsList:r,initialValues:l,onCancel:c}=e,[h,x]=(0,i.useState)((null==l?void 0:l.description)||""),[f,g]=(0,i.useState)((null==l?void 0:l.vars)||{}),[j,v]=(0,i.useState)((null==l?void 0:l.assert)||[]),[Z,b]=(0,i.useState)(0);i.useEffect(()=>{l?(x(l.description||""),g(l.vars||{}),v(l.assert||[])):(x(""),g({}),v([]))},[l]);let y=e=>{n({description:h,vars:f,assert:j},e),e&&c(),x(""),g({}),v([]),b(e=>e+1)};return(0,a.jsxs)(d.Z,{open:t,onClose:c,fullWidth:!0,maxWidth:"md",children:[(0,a.jsx)(m.Z,{children:l?"Edit Test Case":"Add Test Case"}),(0,a.jsx)(u.Z,{children:(0,a.jsxs)(s.Z,{children:[(0,a.jsx)(M,{onAdd:e=>g(e),varsList:r,initialValues:null==l?void 0:l.vars}),(0,a.jsx)(H,{onAdd:e=>v(e),initialValues:((null==l?void 0:l.assert)||[]).filter(e=>"assert-set"!==e.type)||[]},Z)]})}),(0,a.jsxs)(p.Z,{children:[(0,a.jsx)(o.Z,{onClick:y.bind(void 0,!0),color:"primary",variant:"contained",children:l?"Update Test Case":"Add Test Case"}),!l&&(0,a.jsx)(o.Z,{onClick:y.bind(void 0,!1),color:"primary",variant:"contained",children:"Add Another"}),(0,a.jsx)(o.Z,{onClick:c,color:"secondary",children:"Cancel"})]})]})},Q=e=>{let{varsList:t}=e,{testCases:r,setTestCases:s}=(0,l.o)(),[c,d]=i.useState(null),[p,u]=i.useState(!1),h=(e,t)=>{e.stopPropagation(),confirm("Are you sure you want to delete this test case?")&&s(r.filter((e,n)=>n!==t))},m=(e,t)=>{e.stopPropagation();let n=JSON.parse(JSON.stringify(r[t]));s([...r,n])};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(x.Z,{direction:"row",spacing:2,mb:2,justifyContent:"space-between",children:[(0,a.jsx)(f.Z,{variant:"h5",children:"Test Cases"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{htmlFor:"file-input-add-test-case",children:(0,a.jsx)(w.Z,{title:"Upload test cases from csv",children:(0,a.jsxs)("span",{children:[(0,a.jsx)(E.Z,{component:"span",children:(0,a.jsx)(A.Z,{})}),(0,a.jsx)("input",{id:"file-input-add-test-case",type:"file",accept:".csv",onChange:e=>{var t;e.stopPropagation(),e.preventDefault();let a=null===(t=e.target.files)||void 0===t?void 0:t[0];if(a){let e=new FileReader;e.onload=async e=>{var t,a;let i=null===(a=e.target)||void 0===a?void 0:null===(t=a.result)||void 0===t?void 0:t.toString();if(i){let{parse:e}=await Promise.all([n.e(631),n.e(887)]).then(n.bind(n,83887)),t=e(i,{columns:!0});s([...r,...t.map(e=>(0,J.It)(e))])}},e.readAsText(a)}},style:{display:"none"}})]})})}),(0,a.jsx)(o.Z,{color:"primary",onClick:()=>u(!0),variant:"contained",children:"Add Test Case"})]})]}),(0,a.jsx)(P.Z,{children:(0,a.jsxs)(I.Z,{children:[(0,a.jsx)(X.Z,{children:(0,a.jsxs)(T.Z,{children:[(0,a.jsx)(S.Z,{children:"Description"}),(0,a.jsx)(S.Z,{children:"Assertions"}),(0,a.jsx)(S.Z,{children:"Variables"}),(0,a.jsx)(S.Z,{align:"right"})]})}),(0,a.jsx)(O.Z,{children:0===r.length?(0,a.jsx)(T.Z,{children:(0,a.jsx)(S.Z,{colSpan:4,align:"center",children:"No test cases added yet."})}):r.map((e,t)=>{var n;return(0,a.jsxs)(T.Z,{sx:{"&:hover":{backgroundColor:"rgba(0, 0, 0, 0.04)",cursor:"pointer"}},onClick:()=>{d(t),u(!0)},children:[(0,a.jsx)(S.Z,{children:(0,a.jsx)(f.Z,{variant:"body2",children:e.description||"Test Case #".concat(t+1)})}),(0,a.jsxs)(S.Z,{children:[(null===(n=e.assert)||void 0===n?void 0:n.length)||0," assertions"]}),(0,a.jsx)(S.Z,{children:Object.entries(e.vars||{}).map(e=>{let[t,n]=e;return t+"="+n}).join(", ")}),(0,a.jsxs)(S.Z,{align:"right",sx:{minWidth:150},children:[(0,a.jsx)(E.Z,{onClick:()=>{d(t),u(!0)},size:"small",children:(0,a.jsx)(k.Z,{})}),(0,a.jsx)(E.Z,{onClick:e=>m(e,t),size:"small",children:(0,a.jsx)(_.Z,{})}),(0,a.jsx)(E.Z,{onClick:e=>h(e,t),size:"small",children:(0,a.jsx)(C.Z,{})})]})]},t)})})]})}),(0,a.jsx)($,{open:p,onAdd:(e,t)=>{if(null===c)s([...r,e]);else{let t=r.map((t,n)=>n===c?e:t);s(t),d(null)}t&&u(!1)},varsList:t,initialValues:null!==c?r[c]:void 0,onCancel:()=>{d(null),u(!1)}})]})},ee=n(71911),et=n.n(ee),en=n(93522),ea=n(92863),ei=n(34235),er=n(38640),el=n.n(er),es=n(29270);n(54492),n(55096),n(93486);var eo=()=>{let e="dark"===(0,ea.Z)().palette.mode,{defaultTest:t,setDefaultTest:n,description:r,setDescription:c,env:d,setEnv:p,evaluateOptions:u,setEvaluateOptions:h,prompts:m,setPrompts:x,providers:g,setProviders:j,scenarios:v,setScenarios:Z,testCases:b,setTestCases:y}=(0,l.o)(),[_,C]=i.useState(""),[A,E]=i.useState(!0),I=e=>{n(e.defaultTest||{}),c(e.description||""),p(e.env||{}),h(e.evaluateOptions||{}),x(e.prompts||[]),j(e.providers||[]),Z(e.scenarios||[]),y(e.tests||[])};return i.useEffect(()=>{C(ei.default.dump({defaultTest:t,description:r,env:d,evaluateOptions:u,prompts:m,providers:g,scenarios:v,tests:b}))},[t,r,d,u,m,g,v,b]),(0,a.jsxs)(s.Z,{mt:4,children:[(0,a.jsx)(f.Z,{variant:"h5",gutterBottom:!0,children:"Configuration"}),(0,a.jsxs)(f.Z,{variant:"body1",gutterBottom:!0,children:["This is the YAML config that defines the evaluation and is processed by promptfoo. See"," ",(0,a.jsx)(el(),{target:"_blank",href:"https://promptfoo.dev/docs/configuration/guide",children:"configuration docs"})," ","to learn more."]}),(0,a.jsx)(o.Z,{variant:"text",color:"primary",startIcon:A?(0,a.jsx)(k.Z,{}):(0,a.jsx)(en.Z,{}),onClick:()=>{if(!A)try{let e=ei.default.load(_,{json:!0});I(e)}catch(e){}E(!A)},children:A?"Edit YAML":"Save"}),(0,a.jsx)(et(),{autoCapitalize:"off",value:_,onValueChange:e=>{A||C(e)},highlight:e=>(0,es.highlight)(e,es.languages.yaml),padding:10,style:{backgroundColor:e?"#1e1e1e":"#fff",fontFamily:'"Fira code", "Fira Mono", monospace',fontSize:14},disabled:A,className:A?"":"glowing-border"})]})};n(7517);var ec=n(77580);function ed(e){let{error:t,resetErrorBoundary:n}=e;return(0,a.jsxs)("div",{role:"alert",children:[(0,a.jsx)("p",{children:"Something went wrong:"}),(0,a.jsx)("pre",{children:t.message}),(0,a.jsx)("button",{onClick:n,children:"Try again"})]})}var ep=()=>{let[e,t]=(0,i.useState)(!1),{description:n,setDescription:g,providers:j,setProviders:v,prompts:Z,setPrompts:b,testCases:_,setTestCases:C}=(0,l.o)();if((0,i.useEffect)(()=>{l.o.persist.rehydrate()},[]),ec.env.NEXT_PUBLIC_NO_BROWSING)return null;let k=(e=>{let t=/{{\s*(\w+)\s*}}/g,n=new Set;return e.forEach(e=>{let a;for(;null!==(a=t.exec(e));)n.add(a[1])}),Array.from(n)})(Z);return(0,a.jsxs)(c.Z,{maxWidth:"lg",sx:{marginTop:"2rem"},children:[(0,a.jsxs)(x.Z,{direction:"row",spacing:2,justifyContent:"space-between",children:[(0,a.jsx)(f.Z,{variant:"h4",children:"Set up an evaluation"}),(0,a.jsxs)(x.Z,{direction:"row",spacing:2,children:[(0,a.jsx)(Y,{}),(0,a.jsx)(y,{}),(0,a.jsx)(o.Z,{variant:"outlined",color:"primary",onClick:()=>t(!0),children:"Reset"})]})]}),(0,a.jsx)(s.Z,{mt:4}),(0,a.jsx)(s.Z,{mt:2,children:(0,a.jsx)(r.SV,{FallbackComponent:ed,onReset:()=>{v([])},children:(0,a.jsxs)(x.Z,{direction:"column",spacing:2,justifyContent:"space-between",children:[(0,a.jsx)(f.Z,{variant:"h5",children:"Providers"}),(0,a.jsx)(q,{providers:j,onChange:v})]})})}),(0,a.jsx)(s.Z,{mt:4}),(0,a.jsx)(r.SV,{FallbackComponent:ed,onReset:()=>{b([])},children:(0,a.jsx)(W,{})}),(0,a.jsx)(s.Z,{mt:6}),(0,a.jsx)(r.SV,{FallbackComponent:ed,onReset:()=>{C([])},children:(0,a.jsx)(Q,{varsList:k})}),(0,a.jsx)(eo,{}),(0,a.jsxs)(d.Z,{open:e,onClose:()=>t(!1),"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[(0,a.jsx)(m.Z,{id:"alert-dialog-title",children:"Confirm Reset"}),(0,a.jsx)(u.Z,{children:(0,a.jsx)(h.Z,{id:"alert-dialog-description",children:"Are you sure you want to reset all the fields? This action cannot be undone."})}),(0,a.jsxs)(p.Z,{children:[(0,a.jsx)(o.Z,{onClick:()=>t(!1),children:"Cancel"}),(0,a.jsx)(o.Z,{onClick:()=>{g(""),v([]),b([]),C([]),t(!1)},autoFocus:!0,children:"Reset"})]})]})]})}},52428:function(e,t,n){"use strict";n.d(t,{Ox:function(){return r},T8:function(){return i},eA:function(){return l}});var a=n(77580);let i=!a.env.NEXT_PUBLIC_PROMPTFOO_BUILD_STANDALONE_SERVER,r=!!a.env.NEXT_PUBLIC_PROMPTFOO_USE_SUPABASE,l=""},47887:function(e,t,n){"use strict";n.d(t,{o:function(){return r}});var a=n(79685),i=n(74595);let r=(0,a.Ue)()((0,i.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:a,prompts:i,env:r,scenarios:l}=t();return{env:r,description:e,providers:a,prompts:i,tests:n,scenarios:l}}}),{name:"promptfoo",skipHydration:!0}))},94499:function(){},55096:function(){},7517:function(){},15320:function(e,t){"use strict";t.It=function(e){let t,n,a,i;let r={},l=[],s={};for(let[o,c]of Object.entries(e))o.startsWith("__expected")?""!==c.trim()&&l.push(function(e){if(e.startsWith("javascript:")||e.startsWith("fn:")||e.startsWith("eval:")){let t;e.startsWith("javascript:")&&(t=11),e.startsWith("fn:")&&(t=3),e.startsWith("eval:")&&(t=5);let n=e.slice(t).trim();return{type:"javascript",value:n}}if(e.startsWith("grade:")||e.startsWith("llm-rubric:"))return{type:"llm-rubric",value:e.slice(6)};if(e.startsWith("python:")){let t=e.slice(7).trim();return{type:"python",value:t}}let t=e.match(/^(not-)?(equals|contains-any|contains-all|icontains-any|icontains-all|contains-json|is-json|is-sql|regex|icontains|contains|webhook|rouge-n|similar|starts-with|levenshtein|classifier|model-graded-factuality|factuality|model-graded-closedqa|answer-relevance|context-recall|context-relevance|context-faithfulness|is-valid-openai-function-call|is-valid-openai-tools-call|latency|perplexity|perplexity-score|cost)(?:\((\d+(?:\.\d+)?)\))?(?::([\s\S]*))?$/);if(t){let[e,n,a,i,r]=t,l=n?`not-${a}`:a,s=parseFloat(i);return"contains-any"===a||"contains-all"===a||"icontains-any"===a||"icontains-all"===a?{type:l,value:r.split(",").map(e=>e.trim())}:"contains-json"===a||"is-json"===a?{type:l,value:r}:"rouge-n"===a||"similar"===a||"starts-with"===a||"levenshtein"===a||"classifier"===a||"answer-relevance"===a||"context-recall"===a||"context-relevance"===a||"context-faithfulness"===a||"latency"===a||"perplexity"===a||"perplexity-score"===a||"cost"===a?{type:l,value:r,threshold:s||("similar"===a?.8:.75)}:{type:l,value:r}}return{type:"equals",value:e}}(c)):"__prefix"===o?s.prefix=c:"__suffix"===o?s.suffix=c:"__description"===o?n=c:"__providerOutput"===o?t=c:"__metric"===o?a=c:"__threshold"===o?i=parseFloat(c):r[o]=c;for(let e of l)e.metric=a;return{vars:r,assert:l,options:s,...n?{description:n}:{},...t?{providerOutput:t}:{},...i?{threshold:i}:{}}}}},function(e){e.O(0,[903,640,916,493,304,281,339,969,378,235,476,905,155,258,470,730,744],function(){return e(e.s=92739)}),_N_E=e.O()}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[744],{46018:function(e,n,t){Promise.resolve().then(t.t.bind(t,6020,23)),Promise.resolve().then(t.t.bind(t,46785,23)),Promise.resolve().then(t.t.bind(t,27382,23)),Promise.resolve().then(t.t.bind(t,83507,23)),Promise.resolve().then(t.t.bind(t,27883,23))}},function(e){var n=function(n){return e(e.s=n)};e.O(0,[470,730],function(){return n(11409),n(46018)}),_N_E=e.O()}]);
|
|
File without changes
|
|
File without changes
|