promptfoo 0.20.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/package.json +4 -4
- package/dist/src/assertions.d.ts.map +1 -1
- package/dist/src/assertions.js +5 -0
- package/dist/src/assertions.js.map +1 -1
- package/dist/src/evaluator.js +1 -1
- package/dist/src/evaluator.js.map +1 -1
- package/dist/src/index.d.ts +1 -5
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/matchers.d.ts +3 -2
- package/dist/src/matchers.d.ts.map +1 -1
- package/dist/src/matchers.js +37 -9
- package/dist/src/matchers.js.map +1 -1
- package/dist/src/providers/anthropic.d.ts +5 -3
- package/dist/src/providers/anthropic.d.ts.map +1 -1
- package/dist/src/providers/anthropic.js +8 -10
- package/dist/src/providers/anthropic.js.map +1 -1
- package/dist/src/providers/azureopenai.d.ts +9 -8
- package/dist/src/providers/azureopenai.d.ts.map +1 -1
- package/dist/src/providers/azureopenai.js +33 -36
- package/dist/src/providers/azureopenai.js.map +1 -1
- package/dist/src/providers/openai.d.ts +12 -12
- package/dist/src/providers/openai.d.ts.map +1 -1
- package/dist/src/providers/openai.js +54 -65
- package/dist/src/providers/openai.js.map +1 -1
- package/dist/src/providers/replicate.d.ts +4 -2
- package/dist/src/providers/replicate.d.ts.map +1 -1
- package/dist/src/providers/replicate.js +10 -8
- package/dist/src/providers/replicate.js.map +1 -1
- package/dist/src/providers/webhook.d.ts +9 -0
- package/dist/src/providers/webhook.d.ts.map +1 -0
- package/dist/src/providers/webhook.js +54 -0
- package/dist/src/providers/webhook.js.map +1 -0
- package/dist/src/providers.d.ts +1 -1
- package/dist/src/providers.d.ts.map +1 -1
- package/dist/src/providers.js +36 -28
- package/dist/src/providers.js.map +1 -1
- package/dist/src/suggestions.d.ts.map +1 -1
- package/dist/src/suggestions.js +1 -3
- package/dist/src/suggestions.js.map +1 -1
- package/dist/src/types.d.ts +7 -1
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/util.js +1 -1
- package/dist/src/util.js.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/Bl3o5lF4ON7Fjki46lPhr/_buildManifest.js +1 -0
- package/dist/src/web/nextui/_next/static/chunks/226-7bbb6c98a19542fd.js +37 -0
- package/dist/src/web/nextui/_next/static/chunks/249-ea9c0f034888ccff.js +125 -0
- package/dist/src/web/nextui/_next/static/chunks/339-501c32916b785ef1.js +1 -0
- package/dist/src/web/nextui/_next/static/chunks/365-e426ea5bc7e815fc.js +8 -0
- package/dist/src/web/nextui/_next/static/chunks/396-0a51429a01e24cdd.js +1 -0
- package/dist/src/web/nextui/_next/static/chunks/596-297f7ff4a0436e87.js +25 -0
- package/dist/src/web/nextui/_next/static/chunks/613-572c22424de64659.js +1 -0
- package/dist/src/web/nextui/_next/static/chunks/706-ae1d3352d28419e9.js +9 -0
- package/dist/src/web/nextui/_next/static/chunks/891-7035926a62c1c4e0.js +1 -0
- package/dist/src/web/nextui/_next/static/chunks/app/eval/[id]/not-found-366629541fd598e9.js +1 -0
- package/dist/src/web/nextui/_next/static/chunks/app/eval/[id]/page-319d2ee38d37574e.js +1 -0
- package/dist/src/web/nextui/_next/static/chunks/app/eval/page-a6b1ff91723b7beb.js +1 -0
- package/dist/src/web/nextui/_next/static/chunks/app/layout-024c4adc71c9feb0.js +1 -0
- package/dist/src/web/nextui/_next/static/chunks/app/page-1ae60660130041b2.js +1 -0
- package/dist/src/web/nextui/_next/static/chunks/app/setup/page-6ef16148040bf4f4.js +1 -0
- package/dist/src/web/nextui/_next/static/chunks/{ca377847-cb6ae6a6a073aebb.js → ca377847-26b462611379a4f7.js} +3 -3
- package/dist/src/web/nextui/_next/static/chunks/{fd9d1056-ac777be631f5a9e9.js → fd9d1056-fba4b53a2f01213b.js} +1 -1
- package/dist/src/web/nextui/_next/static/chunks/framework-8883d1e9be70c3da.js +25 -0
- package/dist/src/web/nextui/_next/static/chunks/main-8ea85465d428ecfe.js +1 -0
- package/dist/src/web/nextui/_next/static/chunks/main-app-581ccf0003955b21.js +1 -0
- package/dist/src/web/nextui/_next/static/chunks/pages/_app-52924524f99094ab.js +1 -0
- package/dist/src/web/nextui/_next/static/chunks/pages/_error-c92d5c4bb2b49926.js +1 -0
- package/dist/src/web/nextui/_next/static/chunks/webpack-55c264ce2fd85eb7.js +1 -0
- package/dist/src/web/nextui/_next/static/css/4d399fceacd06992.css +1 -0
- package/dist/src/web/nextui/eval/index.html +1 -1
- package/dist/src/web/nextui/eval/index.txt +6 -6
- package/dist/src/web/nextui/index.html +1 -1
- package/dist/src/web/nextui/index.txt +5 -5
- package/dist/src/web/nextui/setup/index.html +27 -1
- package/dist/src/web/nextui/setup/index.txt +9 -9
- package/dist/src/web/server.d.ts.map +1 -1
- package/dist/src/web/server.js +9 -5
- package/dist/src/web/server.js.map +1 -1
- package/package.json +4 -4
- package/dist/src/web/nextui/_next/static/US6gOx8LHTX_Hzm9aYNrC/_buildManifest.js +0 -1
- package/dist/src/web/nextui/_next/static/chunks/339-4fc8a80fa840e771.js +0 -1
- package/dist/src/web/nextui/_next/static/chunks/373-8a280796c0f2d1af.js +0 -1
- package/dist/src/web/nextui/_next/static/chunks/583-125d32af505e9bc4.js +0 -1
- package/dist/src/web/nextui/_next/static/chunks/596-07e4a23a5c6cdf04.js +0 -25
- package/dist/src/web/nextui/_next/static/chunks/658-a62210d07dc4dcb6.js +0 -15
- package/dist/src/web/nextui/_next/static/chunks/707-699cbd84b259c37b.js +0 -37
- package/dist/src/web/nextui/_next/static/chunks/858-ceb6fa22e614492b.js +0 -125
- package/dist/src/web/nextui/_next/static/chunks/891-3000ea7c0a292558.js +0 -1
- package/dist/src/web/nextui/_next/static/chunks/app/eval/[id]/not-found-50e40614fa05600e.js +0 -1
- package/dist/src/web/nextui/_next/static/chunks/app/eval/[id]/page-c19c44ed1b2dfb58.js +0 -1
- package/dist/src/web/nextui/_next/static/chunks/app/eval/page-d4a1813b2f8c4532.js +0 -1
- package/dist/src/web/nextui/_next/static/chunks/app/layout-664a8d716d2d24b1.js +0 -1
- package/dist/src/web/nextui/_next/static/chunks/app/page-1f8ef6a00a2355f0.js +0 -1
- package/dist/src/web/nextui/_next/static/chunks/app/setup/page-182018a3c6397345.js +0 -1
- package/dist/src/web/nextui/_next/static/chunks/framework-43665103d101a22d.js +0 -25
- package/dist/src/web/nextui/_next/static/chunks/main-50cc0a98559591ce.js +0 -1
- package/dist/src/web/nextui/_next/static/chunks/main-app-c9dc13756d166550.js +0 -1
- package/dist/src/web/nextui/_next/static/chunks/pages/_app-6b79a29ad0d63b21.js +0 -1
- package/dist/src/web/nextui/_next/static/chunks/pages/_error-9aeb3e4d490fe4b8.js +0 -1
- package/dist/src/web/nextui/_next/static/chunks/webpack-6e474e42be502dd7.js +0 -1
- package/dist/src/web/nextui/_next/static/css/a35c840ac696f161.css +0 -1
- package/dist/src/web/nextui/api +0 -1
- package/src/__mocks__/esm.ts +0 -3
- package/src/assertions.ts +0 -580
- package/src/cache.ts +0 -109
- package/src/esm.ts +0 -13
- package/src/evaluator.ts +0 -500
- package/src/index.ts +0 -52
- package/src/logger.ts +0 -46
- package/src/main.ts +0 -442
- package/src/matchers.ts +0 -120
- package/src/onboarding.ts +0 -69
- package/src/prompts.ts +0 -39
- package/src/providers/anthropic.ts +0 -88
- package/src/providers/azureopenai.ts +0 -299
- package/src/providers/llama.ts +0 -95
- package/src/providers/localai.ts +0 -111
- package/src/providers/ollama.ts +0 -89
- package/src/providers/openai.ts +0 -337
- package/src/providers/replicate.ts +0 -99
- package/src/providers/scriptCompletion.ts +0 -35
- package/src/providers/shared.ts +0 -34
- package/src/providers.ts +0 -192
- package/src/share.ts +0 -27
- package/src/suggestions.ts +0 -63
- package/src/table.ts +0 -43
- package/src/tableOutput.html +0 -52
- package/src/telemetry.ts +0 -70
- package/src/types.ts +0 -299
- package/src/updates.ts +0 -46
- package/src/util.ts +0 -543
- package/src/web/nextui/.eslintrc.json +0 -3
- package/src/web/nextui/next.config.js +0 -14
- package/src/web/nextui/package-lock.json +0 -4644
- package/src/web/nextui/package.json +0 -47
- package/src/web/nextui/public/favicon.ico +0 -0
- package/src/web/nextui/public/logo.svg +0 -30
- package/src/web/nextui/src/app/Home.css +0 -3
- package/src/web/nextui/src/app/api/route.ts +0 -6
- package/src/web/nextui/src/app/components/DarkMode.css +0 -22
- package/src/web/nextui/src/app/components/DarkMode.tsx +0 -17
- package/src/web/nextui/src/app/components/Logo.css +0 -32
- package/src/web/nextui/src/app/components/Logo.tsx +0 -11
- package/src/web/nextui/src/app/components/PageShell.css +0 -33
- package/src/web/nextui/src/app/components/PageShell.tsx +0 -87
- package/src/web/nextui/src/app/eval/ConfigModal.tsx +0 -84
- package/src/web/nextui/src/app/eval/Eval.css +0 -13
- package/src/web/nextui/src/app/eval/Eval.tsx +0 -79
- package/src/web/nextui/src/app/eval/EvalOutputPromptDialog.tsx +0 -127
- package/src/web/nextui/src/app/eval/ResultsCharts.tsx +0 -355
- package/src/web/nextui/src/app/eval/ResultsTable.css +0 -179
- package/src/web/nextui/src/app/eval/ResultsTable.tsx +0 -503
- package/src/web/nextui/src/app/eval/ResultsView.tsx +0 -301
- package/src/web/nextui/src/app/eval/ShareModal.tsx +0 -70
- package/src/web/nextui/src/app/eval/[id]/not-found.tsx +0 -5
- package/src/web/nextui/src/app/eval/[id]/page.css +0 -9
- package/src/web/nextui/src/app/eval/[id]/page.tsx +0 -20
- package/src/web/nextui/src/app/eval/index.css +0 -0
- package/src/web/nextui/src/app/eval/page.tsx +0 -8
- package/src/web/nextui/src/app/eval/store.ts +0 -18
- package/src/web/nextui/src/app/eval/types.ts +0 -20
- package/src/web/nextui/src/app/globals.css +0 -58
- package/src/web/nextui/src/app/layout.tsx +0 -25
- package/src/web/nextui/src/app/page.tsx +0 -7
- package/src/web/nextui/src/app/setup/AssertsForm.tsx +0 -118
- package/src/web/nextui/src/app/setup/PromptDialog.tsx +0 -77
- package/src/web/nextui/src/app/setup/PromptsSection.tsx +0 -190
- package/src/web/nextui/src/app/setup/ProviderConfigDialog.tsx +0 -99
- package/src/web/nextui/src/app/setup/ProviderSelector.tsx +0 -149
- package/src/web/nextui/src/app/setup/RunTestSuiteButton.tsx +0 -88
- package/src/web/nextui/src/app/setup/TestCaseDialog.tsx +0 -108
- package/src/web/nextui/src/app/setup/TestCasesSection.tsx +0 -154
- package/src/web/nextui/src/app/setup/VarsForm.tsx +0 -57
- package/src/web/nextui/src/app/setup/page.css +0 -3
- package/src/web/nextui/src/app/setup/page.tsx +0 -160
- package/src/web/nextui/src/util/api.ts +0 -1
- package/src/web/nextui/src/util/store.ts +0 -53
- package/src/web/nextui/tsconfig.json +0 -28
- package/src/web/server.ts +0 -151
- /package/dist/src/web/nextui/_next/static/{US6gOx8LHTX_Hzm9aYNrC → Bl3o5lF4ON7Fjki46lPhr}/_ssgManifest.js +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[421],{6427:function(e,n,t){Promise.resolve().then(t.t.bind(t,6656,23)),Promise.resolve().then(t.t.bind(t,6208,23)),Promise.resolve().then(t.t.bind(t,8169,23)),Promise.resolve().then(t.t.bind(t,3699,23)),Promise.resolve().then(t.bind(t,6891)),Promise.resolve().then(t.t.bind(t,4116,23))},3699: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(1024),t(2265);let r=t(7669);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}},4116:function(){}},function(e){e.O(0,[674,706,249,226,891,971,596,744],function(){return e(e.s=6427)}),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[11],{724:function(n,e,u){Promise.resolve().then(u.bind(u,6891))}},function(n){n.O(0,[674,706,249,226,891,971,596,744],function(){return n(n.s=724)}),_N_E=n.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[185],{8845:function(e,n,t){Promise.resolve().then(t.bind(t,898)),Promise.resolve().then(t.t.bind(t,9362,23)),Promise.resolve().then(t.t.bind(t,2471,23))},898:function(e,n,t){"use strict";t.r(n),t.d(n,{PageShell:function(){return k}});var r=t(7437),o=t(2265),s=t(1396),i=t.n(s),c=t(2135),d=t(3457),l=t(8595),a=t(3948),u=t(6691),h=t.n(u),m=t(6507);function f(){return(0,r.jsxs)(m.Z,{className:"logo",children:[(0,r.jsx)(h(),{width:25,height:25,src:"/logo.svg",alt:"Promptfoo logo"})," ",(0,r.jsx)("span",{children:"promptfoo"})]})}t(1320);var j=t(9864),x=t(7028);function g(e){let{darkMode:n,onToggleDarkMode:t}=e;return(0,r.jsx)("div",{className:"dark-mode-toggle",onClick:t,children:n?(0,r.jsx)(j.Z,{}):(0,r.jsx)(x.Z,{})})}t(2794),t(5587);var v=t(2601);function k(e){let{children:n}=e,t=(0,c.Z)("(prefers-color-scheme: dark)"),[s,i]=o.useState(t),d=o.useMemo(()=>(0,l.Z)({typography:{fontFamily:"inherit"},palette:{mode:s?"dark":"light"}}),[s]);return o.useEffect(()=>{t&&document.documentElement.setAttribute("data-theme","dark")},[t]),(0,r.jsx)(o.StrictMode,{children:(0,r.jsx)(a.Z,{theme:d,children:(0,r.jsxs)(p,{children:[(0,r.jsx)(N,{darkMode:s,onToggleDarkMode:()=>{i(!s),s?document.documentElement.removeAttribute("data-theme"):document.documentElement.setAttribute("data-theme","dark")}}),(0,r.jsx)("div",{children:n})]})})})}function p(e){let{children:n}=e;return(0,r.jsx)("div",{children:n})}function N(e){let{darkMode:n,onToggleDarkMode:t}=e;return v.env.NEXT_PUBLIC_NO_BROWSING?(0,r.jsxs)(d.Z,{direction:"row",spacing:2,className:"nav",children:[(0,r.jsx)(f,{}),(0,r.jsx)(g,{darkMode:n,onToggleDarkMode:t})]}):(0,r.jsxs)(d.Z,{direction:"row",spacing:2,className:"nav",children:[(0,r.jsx)(f,{}),(0,r.jsx)(i(),{href:"/setup",children:"New Eval"}),(0,r.jsx)(i(),{href:"/eval",children:"View Evals"}),(0,r.jsx)(g,{darkMode:n,onToggleDarkMode:t})]})}},2794:function(){},1320:function(){},5587:function(){},2471:function(){}},function(e){e.O(0,[706,396,613,971,596,744],function(){return e(e.s=8845)}),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{8803:function(e,n,t){Promise.resolve().then(t.t.bind(t,6656,23)),Promise.resolve().then(t.t.bind(t,6208,23)),Promise.resolve().then(t.t.bind(t,8169,23)),Promise.resolve().then(t.t.bind(t,3699,23)),Promise.resolve().then(t.t.bind(t,6339,23))},3699: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(1024),t(2265);let r=t(7669);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}},6339:function(){}},function(e){e.O(0,[971,596,744],function(){return e(e.s=8803)}),_N_E=e.O()}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[413],{3515:function(e,t,n){Promise.resolve().then(n.bind(n,6435))},6435:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return er}});var r=n(7437),i=n(2265),a=n(5551),s=n(8938),o=n(3226),l=n(6507),c=n(3457),d=n(9394),p=n(2834),u=n(6337),h=n(4173),x=n(1797),m=n(4740),j=n(4033),g=n(6882),f=n(1938),v=n(279),Z=()=>{let e=(0,j.useRouter)(),{description:t,providers:n,prompts:s,testCases:o}=(0,f.o)(),[l,c]=(0,i.useState)(!1),[d,p]=(0,i.useState)(0),u=async()=>{c(!0);try{let r=await fetch("".concat(v.eA,"/api/eval/"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({description:t,providers:n,prompts:s,tests:o})});if(!r.ok)throw Error("HTTP error! status: ".concat(r.status));let i=await r.json(),a=setInterval(async()=>{let t=await fetch("".concat(v.eA,"/api/eval/").concat(i.id,"/"));if(!t.ok)throw clearInterval(a),Error("HTTP error! status: ".concat(t.status));let n=await t.json();if("complete"===n.status)clearInterval(a),c(!1),v.T8?e.push("/eval"):e.push("/eval/remote:".concat(encodeURIComponent(i.id)));else if("failed"===n.status)throw clearInterval(a),c(!1),Error("Job failed");else{let e=0===n.total?0:Math.round(n.progress/n.total*100);p(e)}},1e3)}catch(e){console.error(e),c(!1),alert("An error occurred: ".concat(e.message))}};return(0,r.jsx)(a.Z,{variant:"contained",color:"primary",onClick:u,disabled:l,children:l?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(g.Z,{size:24,sx:{marginRight:2}}),d.toFixed(0),"% complete"]}):"Run Evaluation"})},y=n(2653),b=n(3701),C=n(9279),k=n(666),S=n(5795),w=n(8489),_=n(8276),T=n(3391),A=n(6446),E=n(1280),z=n(9329),P=n(1975),W=e=>{let{open:t,prompt:n,index:s,onAdd:o,onCancel:l}=e,[c,h]=i.useState(n),m=i.useRef(null);i.useEffect(()=>{h(n)},[n]);let j=e=>{o(c),h(""),e?l():m.current&&m.current.focus()};return(0,r.jsxs)(d.Z,{open:t,onClose:l,fullWidth:!0,maxWidth:"md",children:[(0,r.jsx)(x.Z,{children:"Edit Prompt ".concat(s+1)}),(0,r.jsx)(u.Z,{children:(0,r.jsx)(P.Z,{value:c,onChange:e=>h(e.target.value),fullWidth:!0,margin:"normal",multiline:!0,placeholder:"The quick brown {{animal1}} jumps over the lazy {{animal2}}.",helperText:"Tip: use the {{varname}} syntax to add variables to your prompt.",inputRef:m})}),(0,r.jsxs)(p.Z,{children:[(0,r.jsx)(a.Z,{onClick:j.bind(null,!0),color:"primary",variant:"contained",disabled:!c.length,children:"Add"}),(0,r.jsx)(a.Z,{onClick:j.bind(null,!1),color:"primary",variant:"contained",disabled:!c.length,children:"Add Another"}),(0,r.jsx)(a.Z,{onClick:l,color:"secondary",children:"Cancel"})]})]})},I=()=>{let[e,t]=(0,i.useState)(!1),[n,s]=(0,i.useState)(null),{prompts:l,setPrompts:d}=(0,f.o)(),p=(0,i.useRef)(null);(0,i.useEffect)(()=>{null!==n&&n>0&&p.current&&p.current.focus()},[n]);let u=e=>{s(e),t(!0)},h=(e,t)=>{e.stopPropagation();let n=l[t];d([...l,n])},x=(e,t)=>{d(l.map((n,r)=>r===e?t:n))},m=(e,t)=>{e.stopPropagation(),confirm("Are you sure you want to remove this prompt?")&&d(l.filter((e,n)=>n!==t))};return(0,r.jsxs)("div",{children:[(0,r.jsxs)(c.Z,{direction:"row",spacing:2,justifyContent:"space-between",children:[(0,r.jsx)(o.Z,{variant:"h5",children:"Prompts"}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{htmlFor:"file-input-add-prompt",children:(0,r.jsx)(_.Z,{title:"Upload prompt from file",children:(0,r.jsxs)("span",{children:[(0,r.jsx)(y.Z,{component:"span",children:(0,r.jsx)(E.Z,{})}),(0,r.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 r=null===(n=e.target)||void 0===n?void 0:null===(t=n.result)||void 0===t?void 0:t.toString();r&&d([...l,r])},e.readAsText(n)}},style:{display:"none"}})]})})}),(0,r.jsx)(a.Z,{color:"primary",onClick:()=>{t(!0)},variant:"contained",children:"Add Prompt"})]})]}),(0,r.jsx)(S.Z,{children:(0,r.jsx)(b.Z,{children:(0,r.jsx)(C.Z,{children:0===l.length?(0,r.jsx)(w.Z,{children:(0,r.jsx)(k.Z,{colSpan:2,align:"center",children:"No prompts added yet."})}):l.map((e,t)=>(0,r.jsxs)(w.Z,{sx:{"&:hover":{backgroundColor:"rgba(0, 0, 0, 0.04)",cursor:"pointer"}},onClick:()=>u(t),children:[(0,r.jsx)(k.Z,{children:(0,r.jsxs)(o.Z,{variant:"body2",children:["Prompt #".concat(t+1,": "),(e.length>250?e.slice(0,250)+" ...":e).split(/({{\w+}})/g).map((e,t)=>/{{\w+}}/g.test(e)?(0,r.jsx)("span",{style:{backgroundColor:"linen",padding:"0.25rem",borderRadius:"4px"},children:e},t):e)]})}),(0,r.jsxs)(k.Z,{align:"right",sx:{minWidth:150},children:[(0,r.jsx)(y.Z,{onClick:()=>u(t),size:"small",children:(0,r.jsx)(T.Z,{})}),(0,r.jsx)(y.Z,{onClick:e=>h(e,t),size:"small",children:(0,r.jsx)(z.Z,{})}),(0,r.jsx)(y.Z,{onClick:e=>m(e,t),size:"small",children:(0,r.jsx)(A.Z,{})})]})]},t))})})}),(0,r.jsx)(W,{open:e,prompt:null!==n?l[n]:"",index:null!==n?n:0,onAdd:e=>{null!==n?x(n,e):d([...l,e]),s(null)},onCancel:()=>{s(null),t(!1)}})]})},O=n(6988),R=e=>{let{onAdd:t,varsList:n,initialValues:a}=e,[s,d]=i.useState(a||{});return(0,i.useEffect)(()=>{let e={};n.forEach(t=>{e[t]=(null==a?void 0:a[t])||""}),d(e)},[n,a]),(0,r.jsxs)(l.Z,{my:2,children:[(0,r.jsx)(o.Z,{variant:"h6",mb:2,children:"Vars"}),n.length>0?(0,r.jsx)(c.Z,{direction:"row",spacing:2,alignItems:"center",children:Object.keys(s).map((e,n)=>(0,r.jsx)(c.Z,{direction:"row",spacing:2,alignItems:"center",children:(0,r.jsx)(P.Z,{placeholder:e,label:e,value:s[e],fullWidth:!0,onChange:n=>{let r=n.target.value,i={...s,[e]:r};d(i),t(i)}})},n))}):(0,r.jsxs)(o.Z,{variant:"subtitle1",gutterBottom:!0,children:["Add variables to your prompt using the ","{{varname}}"," syntax."]})]})},N=n(8440);let F=["equals","contains","icontains","contains-all","contains-any","starts-with","regex","is-json","contains-json","javascript","python","similar","llm-rubric","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-javascript","not-python","not-similar","not-llm-rubric","not-webhook","not-rouge-n","not-rouge-s","not-rouge-l"];var L=e=>{let{onAdd:t,initialValues:n}=e,[s,d]=(0,i.useState)(n||[]),p=e=>{let n=s.filter((t,n)=>n!==e);d(n),t(n)};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.Z,{variant:"h6",children:"Asserts"}),(0,r.jsx)(l.Z,{my:s.length>0?2:0,children:(0,r.jsx)(c.Z,{direction:"column",spacing:2,children:s.map((e,n)=>(0,r.jsxs)(c.Z,{direction:"row",spacing:2,alignItems:"center",children:[(0,r.jsx)(N.Z,{value:e.type,options:F,sx:{minWidth:200},onChange:(e,r)=>{let i=s.map((e,t)=>t===n?{...e,type:r}:e);d(i),t(i)},renderInput:e=>(0,r.jsx)(P.Z,{...e,label:"Type"})}),(0,r.jsx)(P.Z,{label:"Value",value:e.value,fullWidth:!0,onChange:e=>{let r=e.target.value,i=s.map((e,t)=>t===n?{...e,value:r}:e);d(i),t(i)}}),(0,r.jsx)(y.Z,{onClick:()=>p(n),size:"small",children:(0,r.jsx)(A.Z,{})})]},n))})}),(0,r.jsx)(a.Z,{color:"primary",onClick:()=>{let e=[...s,{type:"equals",value:""}];d(e),t(e)},children:"Add Assert"})]})},V=e=>{let{open:t,onAdd:n,varsList:s,initialValues:o,onCancel:c}=e,[h,m]=(0,i.useState)((null==o?void 0:o.description)||""),[j,g]=(0,i.useState)((null==o?void 0:o.vars)||{}),[f,v]=(0,i.useState)((null==o?void 0:o.assert)||[]),[Z,y]=(0,i.useState)(0);i.useEffect(()=>{o?(m(o.description||""),g(o.vars||{}),v(o.assert||[])):(m(""),g({}),v([]))},[o]);let b=e=>{n({description:h,vars:j,assert:f},e),e&&c(),m(""),g({}),v([]),y(e=>e+1)};return(0,r.jsxs)(d.Z,{open:t,onClose:c,fullWidth:!0,maxWidth:"md",children:[(0,r.jsx)(x.Z,{children:o?"Edit Test Case":"Add Test Case"}),(0,r.jsx)(u.Z,{children:(0,r.jsxs)(l.Z,{children:[(0,r.jsx)(R,{onAdd:e=>g(e),varsList:s,initialValues:null==o?void 0:o.vars}),(0,r.jsx)(L,{onAdd:e=>v(e),initialValues:(null==o?void 0:o.assert)||[]},Z)]})}),(0,r.jsxs)(p.Z,{children:[(0,r.jsx)(a.Z,{onClick:b.bind(void 0,!0),color:"primary",variant:"contained",children:o?"Update Test Case":"Add Test Case"}),!o&&(0,r.jsx)(a.Z,{onClick:b.bind(void 0,!1),color:"primary",variant:"contained",children:"Add Another"}),(0,r.jsx)(a.Z,{onClick:c,color:"secondary",children:"Cancel"})]})]})},J=e=>{let{varsList:t}=e,{testCases:n,setTestCases:s}=(0,f.o)(),[l,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(n.filter((e,n)=>n!==t))},x=(e,t)=>{e.stopPropagation();let r=JSON.parse(JSON.stringify(n[t]));s([...n,r])};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(c.Z,{direction:"row",spacing:2,justifyContent:"space-between",children:[(0,r.jsx)(o.Z,{variant:"h5",children:"Test Cases"}),(0,r.jsx)(a.Z,{color:"primary",onClick:()=>u(!0),variant:"contained",children:"Add Test Case"})]}),(0,r.jsx)(S.Z,{children:(0,r.jsxs)(b.Z,{children:[(0,r.jsx)(O.Z,{children:(0,r.jsxs)(w.Z,{children:[(0,r.jsx)(k.Z,{children:"Description"}),(0,r.jsx)(k.Z,{children:"Assertions"}),(0,r.jsx)(k.Z,{children:"Variables"}),(0,r.jsx)(k.Z,{align:"right"})]})}),(0,r.jsx)(C.Z,{children:0===n.length?(0,r.jsx)(w.Z,{children:(0,r.jsx)(k.Z,{colSpan:4,align:"center",children:"No test cases added yet."})}):n.map((e,t)=>{var n;return(0,r.jsxs)(w.Z,{sx:{"&:hover":{backgroundColor:"rgba(0, 0, 0, 0.04)",cursor:"pointer"}},onClick:()=>{d(t),u(!0)},children:[(0,r.jsx)(k.Z,{children:(0,r.jsx)(o.Z,{variant:"body2",children:e.description||"Test Case #".concat(t+1)})}),(0,r.jsxs)(k.Z,{children:[(null===(n=e.assert)||void 0===n?void 0:n.length)||0," assertions"]}),(0,r.jsx)(k.Z,{children:Object.entries(e.vars||{}).map(e=>{let[t,n]=e;return t+"="+n}).join(", ")}),(0,r.jsxs)(k.Z,{align:"right",sx:{minWidth:150},children:[(0,r.jsx)(y.Z,{onClick:()=>{d(t),u(!0)},size:"small",children:(0,r.jsx)(T.Z,{})}),(0,r.jsx)(y.Z,{onClick:e=>x(e,t),size:"small",children:(0,r.jsx)(z.Z,{})}),(0,r.jsx)(y.Z,{onClick:e=>h(e,t),size:"small",children:(0,r.jsx)(A.Z,{})})]})]},t)})})]})}),(0,r.jsx)(V,{open:p,onAdd:(e,t)=>{if(null===l)s([...n,e]);else{let t=n.map((t,n)=>n===l?e:t);s(t),d(null)}t&&u(!1)},varsList:t,initialValues:null!==l?n[l]:void 0,onCancel:()=>{d(null),u(!1)}})]})},U=n(7827),B=e=>{let{onChange:t,...n}=e,[a,s]=i.useState(""),[o,l]=i.useState(!1);return(0,r.jsx)(P.Z,{...n,error:o,helperText:o?"Invalid JSON":"",value:a,onChange:e=>{let n=e.target.value;try{let e=JSON.parse(n);s(n),l(!1),t&&t(e)}catch(e){s(n),l(!0)}}})},q=e=>{let{open:t,providerId:n,config:s,onClose:o,onSave:c}=e,[h,m]=i.useState(s);return i.useEffect(()=>{m(s)},[s]),(0,r.jsxs)(d.Z,{open:t,onClose:o,fullWidth:!0,maxWidth:"md",children:[(0,r.jsxs)(x.Z,{children:["Edit ",n.length>50?n.slice(0,50)+"...":n]}),(0,r.jsx)(u.Z,{children:Object.keys(h).map(e=>{let t;let n=h[e];return"number"==typeof n||"boolean"==typeof n||"string"==typeof n?(t="number"==typeof n?t=>m({...h,[e]:parseFloat(t.target.value)}):"boolean"==typeof n?t=>m({...h,[e]:"true"===t.target.value}):t=>{let n=t.target.value.trim();if(n.startsWith("{")||n.startsWith("["))try{m({...h,[e]:JSON.parse(n)})}catch(t){m({...h,[e]:n})}else"null"===n?m({...h,[e]:null}):"undefined"===n?m({...h,[e]:void 0}):m({...h,[e]:n})},(0,r.jsx)(l.Z,{my:2,children:(0,r.jsx)(P.Z,{label:e,value:n,onChange:t,fullWidth:!0,InputLabelProps:{shrink:!0},type:"number"==typeof n?"number":"text"})},e)):(0,r.jsx)(l.Z,{my:2,children:(0,r.jsx)(B,{label:e,defaultValue:JSON.stringify(n),onChange:t=>{m({...h,[e]:t})},fullWidth:!0,multiline:!0,minRows:2,InputLabelProps:{shrink:!0}})},e)})}),(0,r.jsxs)(p.Z,{children:[(0,r.jsx)(a.Z,{onClick:o,children:"Cancel"}),(0,r.jsx)(a.Z,{onClick:()=>{c(h)},children:"Save"})]})]})};let M=[].concat(["replicate:replicate/llama70b-v2-chat:e951f18578850b652510200860fc4ea62b3b16fac280f83ff32282f87bbd2e48","replicate:replicate/flan-t5-small:69716ad8c34274043bf4a135b7315c7c569ec931d8f23d6826e249e1c142a264"].map(e=>({id:e,config:{apiKey:"",temperature:.5,max_length:1024,repetition_penality:1}}))).concat(["replicate:a16z-infra/llama-2-7b-chat:7b0bfc9aff140d5b75bacbed23e91fd3c34b01a1e958d32132de6e0a19796e2c","replicate:a16z-infra/llama-2-13b-chat:2a7f981751ec7fdf87b5b91ad4db53683a98082e9ff7bfd12c8cd5ea85980a52"].map(e=>({id:e,config:{apiKey:"",temperature:.95,top_p:.95,top_k:250,max_new_tokens:500,min_new_tokens:-1,repetition_penality:1,system_prompt:""}}))).concat(["anthropic:claude-1","anthropic:claude-1-100k","anthropic:claude-instant-1","anthropic:claude-instant-1-100k"].map(e=>({id:e,config:{apiKey:"",max_tokens_to_sample:256,temperature:.5}}))).concat(["openai:gpt-3.5-turbo","openai:gpt-3.5-turbo-0301","openai:gpt-3.5-turbo-0613","openai:gpt-3.5-turbo-16k","openai:gpt-3.5-turbo-16k-0613","openai:gpt-4","openai:gpt-4-0314","openai:gpt-4-0613","openai:gpt-4-32k","openai:gpt-4-32k-0314"].map(e=>({id:e,config:{apiKey:"",organization:"",apiHost:"api.openai.com",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:{apiKey:"",temperature:.5,max_tokens:1024,top_p:1,frequency_penalty:0,presence_penalty:0,function_call:void 0,functions:void 0,stop:void 0}}))).sort((e,t)=>e.id.localeCompare(t.id));var D=e=>{let{providers:t,onChange:n}=e,[a,s]=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?s(e):alert("There is no config for this provider")};return(0,r.jsxs)(l.Z,{mt:2,children:[(0,r.jsx)(N.Z,{multiple:!0,freeSolo:!0,options:M,value:t,onChange:(e,t)=>{n(t.map(e=>"string"==typeof e?{id:e}:e))},getOptionLabel:e=>e?"string"==typeof e?e:e.id||"Unknown provider":"",renderTags:(e,t)=>e.map((e,n)=>{let r=o(e),a=c(e,n);return(0,i.createElement)(U.Z,{variant:"outlined",label:r,...t({index:n}),key:a,onClick:()=>d(e)})}),renderInput:e=>(0,r.jsx)(P.Z,{...e,variant:"outlined",placeholder:"Select LLM providers",helperText:t.length>0?"Click a provider to configure its settings.":null})}),a&&a.id&&(0,r.jsx)(q,{open:!!a,providerId:a.id,config:a.config,onClose:()=>s(null),onSave:e=>{if(a){let r=t.map(t=>t.id===a.id?{...t,config:e}:t);n(r),s(null)}}})]})},K=n(3425),H=n.n(K),X=n(4759);n(5341),n(7555);var Y=n(8339),G=n(9963),Q=n(1396),$=n.n(Q);n(695);var ee=()=>{let{description:e,setDescription:t,providers:n,setProviders:s,prompts:c,setPrompts:d,testCases:p,setTestCases:u}=(0,f.o)(),[h,x]=i.useState(""),[m,j]=i.useState(!0);i.useEffect(()=>{x(Y.default.dump({description:e,providers:n,prompts:c,tests:p}))},[e,n,c,p]);let g=e=>{t(e.description||""),s(e.providers||[]),d(e.prompts||[]),u(e.tests||[])};return(0,r.jsxs)(l.Z,{mt:4,children:[(0,r.jsx)(o.Z,{variant:"h5",gutterBottom:!0,children:"Configuration"}),(0,r.jsxs)(o.Z,{variant:"body1",gutterBottom:!0,children:["This is the YAML config that defines the evaluation and is processed by promptfoo. See"," ",(0,r.jsx)($(),{target:"_blank",href:"https://promptfoo.dev/docs/configuration/guide",children:"configuration docs"})," ","to learn more."]}),(0,r.jsx)(a.Z,{variant:"text",color:"primary",startIcon:m?(0,r.jsx)(T.Z,{}):(0,r.jsx)(G.Z,{}),onClick:()=>{if(!m)try{let e=Y.default.load(h,{json:!0});g(e)}catch(e){}j(!m)},children:m?"Edit YAML":"Save"}),(0,r.jsx)(H(),{autoCapitalize:"off",value:h,onValueChange:e=>{m||x(e)},highlight:e=>(0,X.highlight)(e,X.languages.yaml),padding:10,style:{fontFamily:'"Fira code", "Fira Mono", monospace',fontSize:12},disabled:m,className:m?"":"glowing-border"})]})};n(284);var et=n(2601);function en(e){let{error:t,resetErrorBoundary:n}=e;return(0,r.jsxs)("div",{role:"alert",children:[(0,r.jsx)("p",{children:"Something went wrong:"}),(0,r.jsx)("pre",{children:t.message}),(0,r.jsx)("button",{onClick:n,children:"Try again"})]})}var er=()=>{let[e,t]=(0,i.useState)(!1),{description:n,setDescription:j,providers:g,setProviders:v,prompts:y,setPrompts:b,testCases:C,setTestCases:k}=(0,f.o)();if((0,i.useEffect)(()=>{f.o.persist.rehydrate()},[]),et.env.NEXT_PUBLIC_NO_BROWSING)return null;let S=(e=>{let t=/{{(\w+)}}/g,n=new Set;return e.forEach(e=>{let r;for(;null!==(r=t.exec(e));)n.add(r[1])}),Array.from(n)})(y);return(0,r.jsxs)(s.Z,{maxWidth:"lg",sx:{marginTop:"2rem"},children:[(0,r.jsxs)(c.Z,{direction:"row",spacing:2,justifyContent:"space-between",children:[(0,r.jsx)(o.Z,{variant:"h4",children:"Set up an evaluation"}),(0,r.jsxs)(c.Z,{direction:"row",spacing:2,children:[(0,r.jsx)(Z,{}),(0,r.jsx)(a.Z,{variant:"outlined",color:"primary",onClick:()=>t(!0),children:"Reset"})]})]}),(0,r.jsx)(l.Z,{mt:4}),(0,r.jsx)(l.Z,{mt:2,children:(0,r.jsx)(m.SV,{FallbackComponent:en,onReset:()=>{v([])},children:(0,r.jsxs)(c.Z,{direction:"column",spacing:2,justifyContent:"space-between",children:[(0,r.jsx)(o.Z,{variant:"h5",children:"Providers"}),(0,r.jsx)(D,{providers:g,onChange:v})]})})}),(0,r.jsx)(l.Z,{mt:4}),(0,r.jsx)(m.SV,{FallbackComponent:en,onReset:()=>{b([])},children:(0,r.jsx)(I,{})}),(0,r.jsx)(l.Z,{mt:6}),(0,r.jsx)(m.SV,{FallbackComponent:en,onReset:()=>{k([])},children:(0,r.jsx)(J,{varsList:S})}),(0,r.jsx)(ee,{}),(0,r.jsxs)(d.Z,{open:e,onClose:()=>t(!1),"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[(0,r.jsx)(x.Z,{id:"alert-dialog-title",children:"Confirm Reset"}),(0,r.jsx)(u.Z,{children:(0,r.jsx)(h.Z,{id:"alert-dialog-description",children:"Are you sure you want to reset all the fields? This action cannot be undone."})}),(0,r.jsxs)(p.Z,{children:[(0,r.jsx)(a.Z,{onClick:()=>t(!1),children:"Cancel"}),(0,r.jsx)(a.Z,{onClick:()=>{j(""),v([]),b([]),k([]),t(!1)},autoFocus:!0,children:"Reset"})]})]})]})}},279:function(e,t,n){"use strict";n.d(t,{CT:function(){return a},T8:function(){return i},eA:function(){return s}});var r=n(2601);let i=!r.env.NEXT_PUBLIC_PROMPTFOO_BUILD_STANDALONE_SERVER,a="http://localhost:15500",s=""},1938:function(e,t,n){"use strict";n.d(t,{o:function(){return a}});var r=n(4660),i=n(4810);let a=(0,r.Ue)()((0,i.tJ)(e=>({testCases:[],description:"",providers:[],prompts:[],setTestCases:t=>e({testCases:t}),setDescription:t=>e({description:t}),setProviders:t=>e({providers:t}),setPrompts:t=>e({prompts:t}),setStateFromConfig:t=>{let n={};t.description&&(n.description=t.description||""),t.tests&&(n.testCases=t.tests),t.providers&&(n.providers=t.providers),t.prompts&&("string"==typeof t.prompts?n.prompts=[t.prompts]:Array.isArray(t.prompts)?n.prompts=t.prompts.filter(e=>!e.endsWith(".txt")&&!e.endsWith(".json")&&!e.endsWith(".yaml")):console.warn("Invalid prompts config",t.prompts)),e(n)}}),{name:"promptfoo",skipHydration:!0}))},695:function(){},284:function(){}},function(e){e.O(0,[706,249,339,396,365,971,596,744],function(){return e(e.s=3515)}),_N_E=e.O()}]);
|