promptfoo 0.66.0 → 0.67.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (281) hide show
  1. package/README.md +9 -9
  2. package/dist/package.json +3 -2
  3. package/dist/src/assertions.d.ts.map +1 -1
  4. package/dist/src/assertions.js +18 -47
  5. package/dist/src/assertions.js.map +1 -1
  6. package/dist/src/cache.d.ts.map +1 -1
  7. package/dist/src/cache.js +3 -3
  8. package/dist/src/cache.js.map +1 -1
  9. package/dist/src/commands/config.d.ts.map +1 -1
  10. package/dist/src/commands/config.js +13 -2
  11. package/dist/src/commands/config.js.map +1 -1
  12. package/dist/src/commands/delete.js +1 -1
  13. package/dist/src/commands/delete.js.map +1 -1
  14. package/dist/src/commands/export.d.ts.map +1 -1
  15. package/dist/src/commands/export.js +1 -1
  16. package/dist/src/commands/export.js.map +1 -1
  17. package/dist/src/commands/import.js +1 -1
  18. package/dist/src/commands/import.js.map +1 -1
  19. package/dist/src/commands/list.d.ts.map +1 -1
  20. package/dist/src/commands/list.js +2 -2
  21. package/dist/src/commands/list.js.map +1 -1
  22. package/dist/src/commands/show.d.ts.map +1 -1
  23. package/dist/src/commands/show.js +2 -2
  24. package/dist/src/commands/show.js.map +1 -1
  25. package/dist/src/csv.d.ts.map +1 -1
  26. package/dist/src/csv.js +0 -1
  27. package/dist/src/csv.js.map +1 -1
  28. package/dist/src/database.d.ts.map +1 -1
  29. package/dist/src/database.js +5 -5
  30. package/dist/src/database.js.map +1 -1
  31. package/dist/src/esm.d.ts.map +1 -1
  32. package/dist/src/esm.js +1 -1
  33. package/dist/src/esm.js.map +1 -1
  34. package/dist/src/evaluator.d.ts +18 -0
  35. package/dist/src/evaluator.d.ts.map +1 -1
  36. package/dist/src/evaluator.js +41 -23
  37. package/dist/src/evaluator.js.map +1 -1
  38. package/dist/src/feedback.d.ts.map +1 -1
  39. package/dist/src/feedback.js +2 -2
  40. package/dist/src/feedback.js.map +1 -1
  41. package/dist/src/fetch.d.ts.map +1 -1
  42. package/dist/src/fetch.js.map +1 -1
  43. package/dist/src/globalConfig.d.ts +0 -4
  44. package/dist/src/globalConfig.d.ts.map +1 -1
  45. package/dist/src/globalConfig.js +5 -5
  46. package/dist/src/globalConfig.js.map +1 -1
  47. package/dist/src/googleSheets.d.ts.map +1 -1
  48. package/dist/src/googleSheets.js +6 -6
  49. package/dist/src/googleSheets.js.map +1 -1
  50. package/dist/src/index.d.ts +1 -1
  51. package/dist/src/index.d.ts.map +1 -1
  52. package/dist/src/index.js +4 -4
  53. package/dist/src/index.js.map +1 -1
  54. package/dist/src/integrations/langfuse.js +1 -1
  55. package/dist/src/integrations/langfuse.js.map +1 -1
  56. package/dist/src/main.js +26 -26
  57. package/dist/src/main.js.map +1 -1
  58. package/dist/src/matchers.d.ts.map +1 -1
  59. package/dist/src/matchers.js +8 -7
  60. package/dist/src/matchers.js.map +1 -1
  61. package/dist/src/migrate.d.ts.map +1 -1
  62. package/dist/src/migrate.js +2 -2
  63. package/dist/src/migrate.js.map +1 -1
  64. package/dist/src/onboarding.d.ts.map +1 -1
  65. package/dist/src/onboarding.js +2 -2
  66. package/dist/src/onboarding.js.map +1 -1
  67. package/dist/src/prompts/constants.d.ts +3 -0
  68. package/dist/src/prompts/constants.d.ts.map +1 -0
  69. package/dist/src/prompts/constants.js +16 -0
  70. package/dist/src/prompts/constants.js.map +1 -0
  71. package/dist/src/prompts/external/ragas.d.ts.map +1 -0
  72. package/dist/src/prompts/external/ragas.js.map +1 -0
  73. package/dist/src/{prompts.d.ts → prompts/grading.d.ts} +7 -4
  74. package/dist/src/prompts/grading.d.ts.map +1 -0
  75. package/dist/src/prompts/grading.js +119 -0
  76. package/dist/src/prompts/grading.js.map +1 -0
  77. package/dist/src/prompts/index.d.ts +25 -0
  78. package/dist/src/prompts/index.d.ts.map +1 -0
  79. package/dist/src/prompts/index.js +143 -0
  80. package/dist/src/prompts/index.js.map +1 -0
  81. package/dist/src/prompts/processors/javascript.d.ts +9 -0
  82. package/dist/src/prompts/processors/javascript.d.ts.map +1 -0
  83. package/dist/src/prompts/processors/javascript.js +22 -0
  84. package/dist/src/prompts/processors/javascript.js.map +1 -0
  85. package/dist/src/prompts/processors/json.d.ts +12 -0
  86. package/dist/src/prompts/processors/json.d.ts.map +1 -0
  87. package/dist/src/prompts/processors/json.js +48 -0
  88. package/dist/src/prompts/processors/json.js.map +1 -0
  89. package/dist/src/prompts/processors/jsonl.d.ts +9 -0
  90. package/dist/src/prompts/processors/jsonl.d.ts.map +1 -0
  91. package/dist/src/prompts/processors/jsonl.js +48 -0
  92. package/dist/src/prompts/processors/jsonl.js.map +1 -0
  93. package/dist/src/prompts/processors/python.d.ts +31 -0
  94. package/dist/src/prompts/processors/python.d.ts.map +1 -0
  95. package/dist/src/prompts/processors/python.js +96 -0
  96. package/dist/src/prompts/processors/python.js.map +1 -0
  97. package/dist/src/prompts/processors/string.d.ts +8 -0
  98. package/dist/src/prompts/processors/string.d.ts.map +1 -0
  99. package/dist/src/prompts/processors/string.js +23 -0
  100. package/dist/src/prompts/processors/string.js.map +1 -0
  101. package/dist/src/prompts/processors/text.d.ts +9 -0
  102. package/dist/src/prompts/processors/text.d.ts.map +1 -0
  103. package/dist/src/prompts/processors/text.js +47 -0
  104. package/dist/src/prompts/processors/text.js.map +1 -0
  105. package/dist/src/prompts/processors/yaml.d.ts +13 -0
  106. package/dist/src/prompts/processors/yaml.d.ts.map +1 -0
  107. package/dist/src/prompts/processors/yaml.js +55 -0
  108. package/dist/src/prompts/processors/yaml.js.map +1 -0
  109. package/dist/src/prompts/utils.d.ts +29 -0
  110. package/dist/src/prompts/utils.d.ts.map +1 -0
  111. package/dist/src/prompts/utils.js +143 -0
  112. package/dist/src/prompts/utils.js.map +1 -0
  113. package/dist/src/providers/anthropic.d.ts.map +1 -1
  114. package/dist/src/providers/anthropic.js +1 -1
  115. package/dist/src/providers/anthropic.js.map +1 -1
  116. package/dist/src/providers/azureopenai.d.ts.map +1 -1
  117. package/dist/src/providers/azureopenai.js +1 -1
  118. package/dist/src/providers/azureopenai.js.map +1 -1
  119. package/dist/src/providers/azureopenaiUtil.d.ts.map +1 -1
  120. package/dist/src/providers/azureopenaiUtil.js +2 -2
  121. package/dist/src/providers/azureopenaiUtil.js.map +1 -1
  122. package/dist/src/providers/bam.d.ts.map +1 -1
  123. package/dist/src/providers/bam.js +1 -1
  124. package/dist/src/providers/bam.js.map +1 -1
  125. package/dist/src/providers/bedrock.d.ts +1 -0
  126. package/dist/src/providers/bedrock.d.ts.map +1 -1
  127. package/dist/src/providers/bedrock.js +21 -4
  128. package/dist/src/providers/bedrock.js.map +1 -1
  129. package/dist/src/providers/cloudflare-ai.d.ts +1 -1
  130. package/dist/src/providers/cloudflare-ai.d.ts.map +1 -1
  131. package/dist/src/providers/cloudflare-ai.js +1 -1
  132. package/dist/src/providers/cloudflare-ai.js.map +1 -1
  133. package/dist/src/providers/cohere.d.ts.map +1 -1
  134. package/dist/src/providers/cohere.js.map +1 -1
  135. package/dist/src/providers/defaults.d.ts +1 -1
  136. package/dist/src/providers/defaults.d.ts.map +1 -1
  137. package/dist/src/providers/defaults.js +2 -2
  138. package/dist/src/providers/defaults.js.map +1 -1
  139. package/dist/src/providers/http.d.ts.map +1 -1
  140. package/dist/src/providers/http.js +2 -2
  141. package/dist/src/providers/http.js.map +1 -1
  142. package/dist/src/providers/huggingface.d.ts +1 -1
  143. package/dist/src/providers/huggingface.d.ts.map +1 -1
  144. package/dist/src/providers/huggingface.js +1 -1
  145. package/dist/src/providers/huggingface.js.map +1 -1
  146. package/dist/src/providers/llama.d.ts.map +1 -1
  147. package/dist/src/providers/llama.js.map +1 -1
  148. package/dist/src/providers/localai.d.ts.map +1 -1
  149. package/dist/src/providers/localai.js +1 -1
  150. package/dist/src/providers/localai.js.map +1 -1
  151. package/dist/src/providers/mistral.d.ts.map +1 -1
  152. package/dist/src/providers/mistral.js +1 -1
  153. package/dist/src/providers/mistral.js.map +1 -1
  154. package/dist/src/providers/ollama.d.ts.map +1 -1
  155. package/dist/src/providers/ollama.js +1 -1
  156. package/dist/src/providers/ollama.js.map +1 -1
  157. package/dist/src/providers/openai.d.ts +1 -1
  158. package/dist/src/providers/openai.d.ts.map +1 -1
  159. package/dist/src/providers/openai.js +2 -2
  160. package/dist/src/providers/openai.js.map +1 -1
  161. package/dist/src/providers/palm.d.ts.map +1 -1
  162. package/dist/src/providers/palm.js +1 -1
  163. package/dist/src/providers/palm.js.map +1 -1
  164. package/dist/src/providers/portkey.d.ts +1 -1
  165. package/dist/src/providers/portkey.d.ts.map +1 -1
  166. package/dist/src/providers/portkey.js.map +1 -1
  167. package/dist/src/providers/promptfoo.d.ts.map +1 -1
  168. package/dist/src/providers/promptfoo.js.map +1 -1
  169. package/dist/src/providers/pythonCompletion.d.ts.map +1 -1
  170. package/dist/src/providers/pythonCompletion.js +2 -2
  171. package/dist/src/providers/pythonCompletion.js.map +1 -1
  172. package/dist/src/providers/replicate.d.ts.map +1 -1
  173. package/dist/src/providers/replicate.js +2 -2
  174. package/dist/src/providers/replicate.js.map +1 -1
  175. package/dist/src/providers/scriptCompletion.d.ts.map +1 -1
  176. package/dist/src/providers/scriptCompletion.js +1 -1
  177. package/dist/src/providers/scriptCompletion.js.map +1 -1
  178. package/dist/src/providers/vertex.d.ts +12 -1
  179. package/dist/src/providers/vertex.d.ts.map +1 -1
  180. package/dist/src/providers/vertex.js +60 -3
  181. package/dist/src/providers/vertex.js.map +1 -1
  182. package/dist/src/providers/voyage.d.ts.map +1 -1
  183. package/dist/src/providers/voyage.js.map +1 -1
  184. package/dist/src/providers/webhook.d.ts.map +1 -1
  185. package/dist/src/providers/webhook.js +1 -1
  186. package/dist/src/providers/webhook.js.map +1 -1
  187. package/dist/src/providers.d.ts +3 -3
  188. package/dist/src/providers.d.ts.map +1 -1
  189. package/dist/src/providers.js +30 -20
  190. package/dist/src/providers.js.map +1 -1
  191. package/dist/src/python/wrapper.d.ts.map +1 -1
  192. package/dist/src/python/wrapper.js +1 -1
  193. package/dist/src/python/wrapper.js.map +1 -1
  194. package/dist/src/redteam/getHijackingTests.d.ts.map +1 -1
  195. package/dist/src/redteam/getHijackingTests.js.map +1 -1
  196. package/dist/src/redteam/index.d.ts.map +1 -1
  197. package/dist/src/redteam/index.js +4 -4
  198. package/dist/src/redteam/index.js.map +1 -1
  199. package/dist/src/redteam/iterative.d.ts +3 -0
  200. package/dist/src/redteam/iterative.d.ts.map +1 -1
  201. package/dist/src/redteam/iterative.js +10 -3
  202. package/dist/src/redteam/iterative.js.map +1 -1
  203. package/dist/src/share.d.ts.map +1 -1
  204. package/dist/src/share.js +1 -1
  205. package/dist/src/share.js.map +1 -1
  206. package/dist/src/suggestions.d.ts.map +1 -1
  207. package/dist/src/suggestions.js.map +1 -1
  208. package/dist/src/table.d.ts.map +1 -1
  209. package/dist/src/table.js +1 -1
  210. package/dist/src/table.js.map +1 -1
  211. package/dist/src/telemetry.d.ts.map +1 -1
  212. package/dist/src/telemetry.js +1 -1
  213. package/dist/src/telemetry.js.map +1 -1
  214. package/dist/src/testCases.d.ts.map +1 -1
  215. package/dist/src/testCases.js +5 -5
  216. package/dist/src/testCases.js.map +1 -1
  217. package/dist/src/types.d.ts +4 -1
  218. package/dist/src/types.d.ts.map +1 -1
  219. package/dist/src/types.js.map +1 -1
  220. package/dist/src/updates.d.ts.map +1 -1
  221. package/dist/src/updates.js +2 -2
  222. package/dist/src/updates.js.map +1 -1
  223. package/dist/src/util.d.ts +1 -0
  224. package/dist/src/util.d.ts.map +1 -1
  225. package/dist/src/util.js +44 -14
  226. package/dist/src/util.js.map +1 -1
  227. package/dist/src/web/nextui/404/index.html +1 -1
  228. package/dist/src/web/nextui/404.html +1 -1
  229. package/dist/src/web/nextui/_next/static/chunks/2-f562fcee36045aca.js +1 -0
  230. package/dist/src/web/nextui/_next/static/chunks/app/auth/login/{page-c4a2650ac3a0ecd9.js → page-d932a73274f0f175.js} +1 -1
  231. package/dist/src/web/nextui/_next/static/chunks/app/auth/signup/{page-dd18caf3100d8d0e.js → page-7a8f35189f8bc5b8.js} +1 -1
  232. package/dist/src/web/nextui/_next/static/chunks/app/datasets/page-9712a72be5b92b81.js +1 -0
  233. package/dist/src/web/nextui/_next/static/chunks/app/layout-c6a855ac7037db70.js +1 -0
  234. package/dist/src/web/nextui/_next/static/chunks/app/progress/{page-00b5c3308a81af12.js → page-751105ef02d00993.js} +1 -1
  235. package/dist/src/web/nextui/_next/static/chunks/app/prompts/page-689202b79a6b6a92.js +1 -0
  236. package/dist/src/web/nextui/_next/static/chunks/app/report/page-4b1c00ce9ee1f5ab.js +1 -0
  237. package/dist/src/web/nextui/_next/static/chunks/app/setup/page-544af5b41c35d73a.js +1 -0
  238. package/dist/src/web/nextui/_next/static/chunks/webpack-d1a82d85a184970b.js +1 -0
  239. package/dist/src/web/nextui/_next/static/css/{51a17e8edcdfdbb2.css → b76f1739b5a14901.css} +1 -1
  240. package/dist/src/web/nextui/_next/static/css/dab5d695b3657d59.css +1 -0
  241. package/dist/src/web/nextui/_next/static/css/edcd6f0b6c902fde.css +1 -0
  242. package/dist/src/web/nextui/auth/login/index.html +1 -1
  243. package/dist/src/web/nextui/auth/login/index.txt +6 -6
  244. package/dist/src/web/nextui/auth/signup/index.html +1 -1
  245. package/dist/src/web/nextui/auth/signup/index.txt +6 -6
  246. package/dist/src/web/nextui/datasets/index.html +1 -1
  247. package/dist/src/web/nextui/datasets/index.txt +6 -6
  248. package/dist/src/web/nextui/eval/index.html +1 -1
  249. package/dist/src/web/nextui/eval/index.txt +6 -6
  250. package/dist/src/web/nextui/index.html +1 -1
  251. package/dist/src/web/nextui/index.txt +5 -5
  252. package/dist/src/web/nextui/progress/index.html +1 -1
  253. package/dist/src/web/nextui/progress/index.txt +6 -6
  254. package/dist/src/web/nextui/prompts/index.html +1 -1
  255. package/dist/src/web/nextui/prompts/index.txt +6 -6
  256. package/dist/src/web/nextui/report/index.html +1 -1
  257. package/dist/src/web/nextui/report/index.txt +8 -8
  258. package/dist/src/web/nextui/setup/index.html +2 -2
  259. package/dist/src/web/nextui/setup/index.txt +9 -9
  260. package/dist/src/web/server.d.ts.map +1 -1
  261. package/dist/src/web/server.js +10 -10
  262. package/dist/src/web/server.js.map +1 -1
  263. package/package.json +3 -2
  264. package/dist/src/external/ragas.d.ts.map +0 -1
  265. package/dist/src/external/ragas.js.map +0 -1
  266. package/dist/src/prompts.d.ts.map +0 -1
  267. package/dist/src/prompts.js +0 -391
  268. package/dist/src/prompts.js.map +0 -1
  269. package/dist/src/web/nextui/_next/static/chunks/2-60ab1c881a240da6.js +0 -1
  270. package/dist/src/web/nextui/_next/static/chunks/app/datasets/page-9426b519d4be1fdb.js +0 -1
  271. package/dist/src/web/nextui/_next/static/chunks/app/layout-dfda5ed5ef745c2d.js +0 -1
  272. package/dist/src/web/nextui/_next/static/chunks/app/prompts/page-ee610cffca4b965b.js +0 -1
  273. package/dist/src/web/nextui/_next/static/chunks/app/report/page-1b97ddc1b365a121.js +0 -1
  274. package/dist/src/web/nextui/_next/static/chunks/app/setup/page-e1c49ea6fe7c04c5.js +0 -1
  275. package/dist/src/web/nextui/_next/static/chunks/webpack-2fa22c6070dd15bc.js +0 -1
  276. package/dist/src/web/nextui/_next/static/css/16c1dd82fc87c9d7.css +0 -1
  277. package/dist/src/web/nextui/_next/static/css/51f7d6933894a4f8.css +0 -1
  278. /package/dist/src/{external → prompts/external}/ragas.d.ts +0 -0
  279. /package/dist/src/{external → prompts/external}/ragas.js +0 -0
  280. /package/dist/src/web/nextui/_next/static/{lMO8mRWL6KkcjtN4Giq14 → m-VSM7eKSuIZDyA_tnwFX}/_buildManifest.js +0 -0
  281. /package/dist/src/web/nextui/_next/static/{lMO8mRWL6KkcjtN4Giq14 → m-VSM7eKSuIZDyA_tnwFX}/_ssgManifest.js +0 -0
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[794],{38486:function(e,t,n){Promise.resolve().then(n.bind(n,73730))},49532:function(e,t,n){"use strict";let i,s;async function l(){if(i||(s||(s=fetch("/api/config").then(e=>e.json()).then(e=>i=e.apiBaseUrl)),await s),void 0===i)throw Error("API base URL is undefined");return i}n.d(t,{b:function(){return l}})},73730:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return I}});var i=n(24004),s=n(14978),l=n(38640),r=n.n(l),c=n(49567),d=n(30469),a=n(65068),o=n(70417),h=n(21303),u=n(26485),x=n(30021),j=n(19708),Z=n(65969),v=n(28891),p=n(49532),f=n(29794),m=n(22701),w=n(51956),y=n(82669),C=n(613),g=n(63147),E=n(40982),k=e=>{var t;let{openDialog:n,handleClose:s,selectedPrompt:l}=e;return(0,i.jsxs)(f.Z,{open:n,onClose:s,fullWidth:!0,maxWidth:"lg",children:[(0,i.jsxs)(y.Z,{children:["Prompt ",l.id.slice(0,6)]}),(0,i.jsxs)(w.Z,{children:[(0,i.jsx)(g.Z,{variant:"h6",style:{marginTop:"1rem"},children:"Prompt"}),(0,i.jsx)(C.u,{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,i.jsx)(g.Z,{variant:"h6",style:{marginTop:"1rem"},children:"Used in..."}),(0,i.jsxs)(a.Z,{children:[(0,i.jsx)(u.Z,{children:(0,i.jsxs)(x.Z,{children:[(0,i.jsx)(h.Z,{children:"Eval ID"}),(0,i.jsx)(h.Z,{children:"Dataset ID"}),(0,i.jsx)(h.Z,{children:"Raw score"}),(0,i.jsx)(h.Z,{children:"Pass rate"}),(0,i.jsx)(h.Z,{children:"Pass count"}),(0,i.jsx)(h.Z,{children:"Fail count"})]})}),(0,i.jsx)(o.Z,{children:null==l?void 0:l.evals.sort((e,t)=>t.id.localeCompare(e.id)).map(e=>{var t,n,s,l,c,d;let a=null!==(l=null===(t=e.metrics)||void 0===t?void 0:t.testPassCount)&&void 0!==l?l:0,o=null!==(c=null===(n=e.metrics)||void 0===n?void 0:n.testFailCount)&&void 0!==c?c:0,u=a+o>0?(a/(a+o)*100).toFixed(2)+"%":"-";return(0,i.jsxs)(x.Z,{children:[(0,i.jsx)(h.Z,{children:(0,i.jsx)(r(),{href:"/eval/?evalId=".concat(e.id),children:e.id})}),(0,i.jsx)(h.Z,{children:(0,i.jsx)(r(),{href:"/datasets/?id=".concat(e.datasetId),children:e.datasetId.slice(0,6)})}),(0,i.jsx)(h.Z,{children:null!==(d=null===(s=e.metrics)||void 0===s?void 0:s.score.toFixed(2))&&void 0!==d?d:"-"}),(0,i.jsx)(h.Z,{children:u}),(0,i.jsx)(h.Z,{children:a}),(0,i.jsx)(h.Z,{children:o})]},"eval-".concat(e.id))})})]})]}),(0,i.jsx)(m.Z,{children:(0,i.jsx)(E.Z,{onClick:s,children:"Close"})})]})};function I(){let e=(0,v.useSearchParams)(),[t,n]=(0,s.useState)([]),[l,f]=(0,s.useState)("date"),[m,w]=(0,s.useState)("desc"),[y,C]=(0,s.useState)(1),[g,E]=(0,s.useState)(10),[I,P]=(0,s.useState)(!1),[S,D]=(0,s.useState)(0),b=e=>{let t=l===e&&"asc"===m?"desc":"asc";f(e),w(t)};(0,s.useEffect)(()=>{(async()=>{fetch("".concat(await (0,p.b)(),"/api/prompts")).then(e=>e.json()).then(e=>{let t=[...e.data].sort((e,t)=>null===l?0:"asc"===m?e[l]>t[l]?1:-1:e[l]<t[l]?1:-1);n(t)})})()},[l,m]),(0,s.useEffect)(()=>{let n=null==e?void 0:e.get("id");if(n){let e=t.findIndex(e=>e.id.startsWith(n));-1!==e&&_(e)}},[t,e]);let _=e=>{P(!0),D(e)};return(0,i.jsxs)(c.Z,{paddingX:2,children:[(0,i.jsxs)(a.Z,{children:[(0,i.jsx)(u.Z,{children:(0,i.jsxs)(x.Z,{children:[(0,i.jsx)(h.Z,{style:{width:"10%"},children:"ID"}),(0,i.jsx)(h.Z,{style:{width:"60%"},children:(0,i.jsx)(j.Z,{active:"raw"===l,direction:"raw"===l?m:"asc",onClick:()=>b("raw"),children:"Prompt"})}),(0,i.jsx)(h.Z,{style:{width:"20%"},children:(0,i.jsx)(Z.Z,{title:"The date of the most recent eval for this prompt",children:(0,i.jsx)(j.Z,{active:"date"===l,direction:"date"===l?m:"asc",onClick:()=>b("date"),children:"Most recent eval"})})}),(0,i.jsx)(h.Z,{style:{width:"10%"},children:(0,i.jsx)(j.Z,{active:"count"===l,direction:"count"===l?m:"asc",onClick:()=>b("count"),children:"# Evals"})})]})}),(0,i.jsx)(o.Z,{children:t.slice((y-1)*g,y*g).map((e,t)=>(0,i.jsxs)(x.Z,{hover:!0,children:[(0,i.jsx)(h.Z,{style:{width:"10%"},children:e.id.slice(0,6)}),(0,i.jsx)(h.Z,{style:{width:"60%",whiteSpace:"pre-wrap",cursor:"pointer"},onClick:()=>_(t),children:e.prompt.raw.length>500?e.prompt.raw.slice(0,500)+"...":e.prompt.raw}),(0,i.jsx)(h.Z,{style:{width:"20%"},children:e.recentEvalDate?(0,i.jsx)(r(),{href:"/eval?evalId=".concat(e.recentEvalId),children:e.recentEvalDate}):"Unknown"}),(0,i.jsx)(h.Z,{style:{width:"10%"},children:e.count})]},t))})]}),Math.ceil(t.length/g)>1&&(0,i.jsx)(d.Z,{count:Math.ceil(t.length/g),page:y,onChange:(e,t)=>C(t)}),t[S]&&(0,i.jsx)(k,{openDialog:I,handleClose:()=>{P(!1)},selectedPrompt:t[S]})]})}}},function(e){e.O(0,[540,640,215,770,995,374,322,470,730,744],function(){return e(e.s=38486)}),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[420],{25902:function(e,i,t){Promise.resolve().then(t.bind(t,37493))},49532:function(e,i,t){"use strict";let a,r;async function s(){if(a||(r||(r=fetch("/api/config").then(e=>e.json()).then(e=>a=e.apiBaseUrl)),await r),void 0===a)throw Error("API base URL is undefined");return a}t.d(i,{b:function(){return s}})},37493:function(e,i,t){"use strict";t.r(i),t.d(i,{default:function(){return G}});var a,r,s=t(24004),n=t(14978),l=t(11520),o=t(63147),c=t(93650),m=t(885),u=t(32414),h=t(49567),d=t(63362),p=t(80661),f=t(49578),g=t(18845),v=t(47908),x=t(85912),y=t(94941),j=t(65969),b=t(70587);let w={"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","contracts"],"Malicious Attacks":["harmful:harassment-bullying","harmful:hate","harmful:insults","harmful:profanity","hijacking","jailbreak","pii","prompt-injection"]},Z={"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."},C={"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."};(a=r||(r={})).Critical="Critical",a.High="High",a.Medium="Medium",a.Low="Low";let k={"excessive-agency":r.Medium,"harmful:child-exploitation":r.Critical,"harmful:copyright-violations":r.Medium,"harmful:cybercrime":r.High,"harmful:graphic-content":r.Medium,"harmful:harassment-bullying":r.High,"harmful:hate":r.Critical,"harmful:illegal-activities":r.High,"harmful:illegal-drugs":r.High,"harmful:indiscriminate-weapons":r.Medium,"harmful:insults":r.Low,"harmful:intellectual-property":r.Medium,"harmful:misinformation-disinformation":r.Medium,"harmful:non-violent-crime":r.Medium,"harmful:privacy":r.High,"harmful:profanity":r.Low,"harmful:radicalization":r.High,"harmful:self-harm":r.Critical,"harmful:sex-crime":r.Critical,"harmful:sexual-content":r.High,"harmful:specialized-advice":r.High,"harmful:unsafe-practices":r.Low,"harmful:violent-crime":r.Critical,"prompt-injection":r.Medium,competitors:r.Low,contracts:r.Medium,hallucination:r.Medium,hijacking:r.High,jailbreak:r.Medium,overreliance:r.Low,pii:r.High,politics:r.Low},R=Object.entries(w).reduce((e,i)=>{let[t,a]=i;return a.forEach(i=>{e[i]=t}),e},{});Object.keys(R);let P={"excessive-agency":"ExcessiveAgency","harmful:child-exploitation":"Child Exploitation","harmful:copyright-violations":"Copyright Violations","harmful:cybercrime":"Cybercrime","harmful:graphic-content":"Graphic Content","harmful:harassment-bullying":"Harassment & Bullying","harmful:hate":"Hate","harmful:illegal-activities":"Illegal Activities","harmful:illegal-drugs":"Illegal Drugs","harmful:indiscriminate-weapons":"Indiscriminate Weapons","harmful:insults":"Insults","harmful:intellectual-property":"Intellectual Property","harmful:misinformation-disinformation":"Misinformation & Disinformation","harmful:non-violent-crime":"Non-Violent Crime","harmful:privacy":"Privacy","harmful:profanity":"Profanity","harmful:radicalization":"Radicalization","harmful:self-harm":"Self-Harm","harmful:sex-crime":"Sex Crimes","harmful:sexual-content":"Sexual Content","harmful:specialized-advice":"Specialized Advice","harmful:unsafe-practices":"Other Unsafe Practices","harmful:violent-crime":"Violent Crimes","prompt-injection":"Harmful/Injection",competitors:"CompetitorEndorsement",contracts:"ContractualCommitment",hallucination:"Hallucination",hijacking:"Hijacking",jailbreak:"Harmful/Iterative",overreliance:"Overreliance",pii:"PIILeak",politics:"PoliticalStatement"},M=Object.entries(P).reduce((e,i)=>{let[t,a]=i;return e[a]=t,e},{}),N={"excessive-agency":"Excessive Agency","prompt-injection":"Prompt Injection",competitors:"Competitor Endorsements",contracts:"Unsupervised Contracts",jailbreak:"Jailbreak",pii:"PII Leaks",politics:"Political Opinions"};t(46553);var A=e=>{let{title:i,subtitle:t,progressValue:a,numTestsPassed:r,numTestsFailed:n,testTypes:l}=e;return(0,s.jsx)(p.Z,{children:(0,s.jsx)(f.Z,{className:"risk-card-container",children:(0,s.jsxs)(c.ZP,{container:!0,spacing:3,children:[(0,s.jsxs)(c.ZP,{item:!0,xs:12,md:6,style:{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center"},children:[(0,s.jsx)(o.Z,{variant:"h5",className:"risk-card-title",children:i}),(0,s.jsx)(o.Z,{variant:"subtitle1",color:"textSecondary",mb:2,children:t}),(0,s.jsx)(h.Z,{sx:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",width:100,height:100},children:(0,s.jsx)(b.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,s.jsxs)(o.Z,{variant:"h6",className:"risk-card-issues",children:[n," failed probes"]}),(0,s.jsxs)(o.Z,{variant:"subtitle1",color:"textSecondary",className:"risk-card-tests-passed",children:[r,"/",r+n," passed"]})]}),(0,s.jsx)(c.ZP,{item:!0,xs:6,md:4,children:(0,s.jsx)(v.Z,{dense:!0,children:l.map((e,i)=>(0,s.jsx)(j.Z,{title:C[e.name],placement:"left",arrow:!0,children:(0,s.jsxs)(x.ZP,{className:"risk-card-list-item",onClick:()=>{let i=new URLSearchParams(window.location.search),t=i.get("evalId"),a=P[e.name];window.location.href="/eval/?evalId=".concat(t,"&search=").concat(encodeURIComponent("(var=".concat(a,"|metric=").concat(a,")")))},style:{cursor:"pointer"},children:[(0,s.jsx)(y.Z,{primary:N[e.name]||P[e.name],primaryTypographyProps:{variant:"body2"}}),e.passed?(0,s.jsx)(g.Z,{className:"risk-card-icon-passed"}):(0,s.jsx)(d.Z,{className:"risk-card-icon-failed"})]})},i))})})]})})})};t(32991);var L=e=>{let{categoryStats:i}=e,t=Object.keys(w).map(e=>({name:e,passed:w[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,s.jsx)(u.Z,{spacing:4,children:t.map((e,t)=>{let a=e.name,r=w[a],n=r.reduce((e,t)=>{var a;return e+((null===(a=i[t])||void 0===a?void 0:a.pass)||0)},0),l=r.reduce((e,t)=>{var a;return e+((null===(a=i[t])||void 0===a?void 0:a.total)||0)},0);return(0,s.jsx)(A,{title:e.name,subtitle:Z[a],progressValue:n/l*100,numTestsPassed:n,numTestsFailed:l-n,testTypes:r.map(e=>{var t,a;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)}})},t)})})};t(4309);var I=e=>{let{categoryStats:i}=e,t=[r.Critical,r.High,r.Medium,r.Low],a=t.reduce((e,t)=>(e[t]=Object.keys(i).reduce((e,i)=>k[i]===t?e+1:e,0),e),{});return(0,s.jsx)(c.ZP,{container:!0,spacing:2,mb:4,children:t.map(e=>(0,s.jsx)(c.ZP,{item:!0,xs:12,sm:6,md:3,children:(0,s.jsx)(p.Z,{className:"card-".concat(e.toLowerCase()),children:(0,s.jsxs)(f.Z,{onClick:()=>window.location.hash="#table",children:[(0,s.jsx)(o.Z,{variant:"body2",component:"div",children:e}),(0,s.jsxs)(o.Z,{variant:"h6",color:"text.primary",children:[a[e]," issues"]})]})})},e))})},F=t(40982),H=t(37803),S=t(65068),z=t(70417),E=t(21303),U=t(61451),D=t(26485),O=t(38592),W=t(30021),B=t(19708);t(93091);var T=t(28891);let V=e=>{let i=[];for(let[t,a]of Object.entries(w))for(let t of a)i.push({pluginName:t,type:P[t]||t,description:C[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:k[t]||"Unknown"});return i.sort((e,i)=>"N/A"===e.passRate?1:"N/A"===i.passRate?-1:parseFloat(e.passRate)-parseFloat(i.passRate))};var _=e=>{let{evalId:i,categoryStats:t}=e;(0,T.useRouter)();let a=V(t).filter(e=>"N/A"!==e.passRate),[r,l]=n.useState(0),[c,m]=n.useState(10),[u,d]=n.useState("asc"),[p,f]=n.useState("default"),g=e=>{let i=p===e&&"asc"===u;d(i?"desc":"asc"),f(e)};return(0,s.jsxs)(h.Z,{children:[(0,s.jsx)(o.Z,{variant:"h6",gutterBottom:!0,id:"table",children:"Vulnerabilities and Mitigations"}),(0,s.jsxs)(U.Z,{component:H.Z,children:[(0,s.jsxs)(S.Z,{children:[(0,s.jsx)(D.Z,{children:(0,s.jsxs)(W.Z,{children:[(0,s.jsx)(E.Z,{children:"Type"}),(0,s.jsx)(E.Z,{children:"Description"}),(0,s.jsx)(E.Z,{children:(0,s.jsx)(B.Z,{active:"passRate"===p,direction:"passRate"===p?u:"asc",onClick:()=>g("passRate"),children:"Pass rate"})}),(0,s.jsx)(E.Z,{children:(0,s.jsx)(B.Z,{active:"severity"===p,direction:"severity"===p?u:"asc",onClick:()=>g("severity"),children:"Severity"})}),(0,s.jsx)(E.Z,{children:"Actions"})]})}),(0,s.jsx)(z.Z,{children:a.sort((e,i)=>{if("passRate"===p)return"N/A"===e.passRate?1:"N/A"===i.passRate?-1:"asc"===u?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"===u?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(r*c,r*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,s.jsxs)(W.Z,{children:[(0,s.jsx)(E.Z,{children:N[e.pluginName]||e.type}),(0,s.jsx)(E.Z,{children:e.description}),(0,s.jsxs)(E.Z,{className:t,children:[e.passRate," (",e.passRateWithFilter!==e.passRate?(0,s.jsx)(s.Fragment,{children:(0,s.jsxs)("strong",{children:[e.passRateWithFilter," with mitigation"]})}):e.passRateWithFilter,")"]}),(0,s.jsx)(E.Z,{className:"vuln-".concat(e.severity.toLowerCase()),children:e.severity}),(0,s.jsxs)(E.Z,{style:{minWidth:270},children:[(0,s.jsx)(F.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,s.jsx)(j.Z,{title:"Temporarily disabled while in beta, click to contact us to enable",children:(0,s.jsx)(F.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,s.jsx)(O.Z,{rowsPerPageOptions:[10,25,50],component:"div",count:a.length,rowsPerPage:c,page:r,onPageChange:(e,i)=>{l(i)},onRowsPerPageChange:e=>{m(parseInt(e.target.value,10)),l(0)}})]})]})},q=t(49532);t(67667);var G=()=>{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,q.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 r=t.get("evalId");r&&(i(r),e(r))},[]),!t||!e)return(0,s.jsx)("div",{children:"Loading..."});let r=t.results.table.head.prompts[0],u=t.results.table.body,h=t.results.results.reduce((e,i)=>{var t,a,r,s;let n=i.vars.harmCategory,l=(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}))||[],o=[n,...l].filter(e=>e);for(let t of o){let a=M[t];if(!a){console.log("Unknown harm category:",t);break}let n=i.success;e[a]=e[a]||{pass:0,total:0,passWithFilter:0},e[a].total++,n?(e[a].pass++,e[a].passWithFilter++):(null===(s=i.gradingResult)||void 0===s?void 0:null===(r=s.componentResults)||void 0===r?void 0:r.some(e=>{var i;let t=(null===(i=e.assertion)||void 0===i?void 0:i.type)==="moderation",a=!e.pass;return t&&a}))&&e[a].passWithFilter++}return e},{});return(0,s.jsx)(l.Z,{children:(0,s.jsxs)(c.ZP,{container:!0,direction:"column",spacing:1,pt:6,pb:8,children:[(0,s.jsxs)(c.ZP,{item:!0,className:"report-header",children:[(0,s.jsxs)(o.Z,{variant:"h4",children:[(0,s.jsx)("strong",{children:"LLM Risk Report"}),t.config.description&&": ".concat(t.config.description)]}),(0,s.jsx)(o.Z,{variant:"subtitle1",mb:2,children:new Date(t.createdAt).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}),(0,s.jsxs)(o.Z,{variant:"body1",gutterBottom:!0,className:"report-details",children:[(0,s.jsx)(m.Z,{size:"small",label:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("strong",{children:"Model:"})," ",r.provider]})}),(0,s.jsx)(m.Z,{size:"small",label:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("strong",{children:"Dataset:"})," ",u.length," probes"]})}),(0,s.jsx)(m.Z,{size:"small",label:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("strong",{children:"Prompt:"}),' "',r.raw.length>20?"".concat(r.raw.substring(0,20),"..."):r.raw,'"']})})]})]}),(0,s.jsx)(c.ZP,{item:!0,children:(0,s.jsx)(I,{categoryStats:h})}),(0,s.jsx)(c.ZP,{item:!0,children:(0,s.jsx)(L,{categoryStats:h})}),(0,s.jsx)(c.ZP,{item:!0,children:(0,s.jsx)(_,{evalId:e,categoryStats:h})})]})})}},4309:function(){},67667:function(){},46553:function(){},32991:function(){},93091:function(){}},function(e){e.O(0,[540,215,620,770,304,995,378,915,470,730,744],function(){return e(e.s=25902)}),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[413],{76178: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 ed}});var a=n(24004),i=n(14978),r=n(40982),l=n(11520),s=n(63147),o=n(49567),c=n(32414),d=n(29794),p=n(22701),u=n(51956),h=n(8541),x=n(82669),m=n(69179),f=n(28891),g=n(11615),j=n(47887),v=n(52428),Z=()=>{let e=(0,f.useRouter)(),{env:t,description:n,providers:l,prompts:s,testCases:o,defaultTest:c,evaluateOptions:d}=(0,j.o)(),[p,u]=(0,i.useState)(!1),[h,x]=(0,i.useState)(0),m=async()=>{u(!0);try{let a=await fetch("".concat(v.eA,"/api/eval/job/"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:t,description:n,providers:l,prompts:s,tests:o,defaultTest:c,evaluateOptions:d})});if(!a.ok)throw Error("HTTP error! status: ".concat(a.status));let i=await a.json(),r=setInterval(async()=>{let t=await fetch("".concat(v.eA,"/api/eval/job/").concat(i.id,"/"));if(!t.ok)throw clearInterval(r),Error("HTTP error! status: ".concat(t.status));let n=await t.json();if("complete"===n.status)clearInterval(r),u(!1),v.Ox?e.push("/eval/remote:".concat(encodeURIComponent(i.id))):e.push("/eval");else if("failed"===n.status)throw clearInterval(r),u(!1),Error("Job failed");else{let e=0===n.total?0:Math.round(n.progress/n.total*100);x(e)}},1e3)}catch(e){console.error(e),u(!1),alert("An error occurred: ".concat(e.message))}};return(0,a.jsx)(r.Z,{variant:"contained",color:"primary",onClick:m,disabled:p,children:p?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(g.Z,{size:24,sx:{marginRight:2}}),h.toFixed(0),"% complete"]}):"Run Evaluation"})},b=n(63346),y=n(89235),_=n(4078),C=n(67339),k=n(75307),A=()=>{let{env:e,setEnv:t}=(0,j.o)(),[n,l]=(0,i.useState)(!1),[s,o]=(0,i.useState)(e),c=()=>{l(!1)};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.Z,{variant:"outlined",startIcon:(0,a.jsx)(k.Z,{}),onClick:()=>{l(!0)},children:"API keys"}),(0,a.jsxs)(d.Z,{open:n,onClose:c,fullWidth:!0,maxWidth:"md",children:[(0,a.jsx)(x.Z,{children:"Provider settings"}),(0,a.jsxs)(u.Z,{children:[(0,a.jsxs)(b.Z,{defaultExpanded:!0,children:[(0,a.jsx)(_.Z,{children:"OpenAI"}),(0,a.jsxs)(y.Z,{children:[(0,a.jsx)(C.Z,{label:"OpenAI API key",fullWidth:!0,margin:"normal",value:s.OPENAI_API_KEY,onChange:e=>o({...s,OPENAI_API_KEY:e.target.value})}),(0,a.jsx)(C.Z,{label:"OpenAI API host",fullWidth:!0,margin:"normal",value:s.OPENAI_API_HOST,onChange:e=>o({...s,OPENAI_API_HOST:e.target.value})}),(0,a.jsx)(C.Z,{label:"OpenAI organization",fullWidth:!0,margin:"normal",value:s.OPENAI_ORGANIZATION,onChange:e=>o({...s,OPENAI_ORGANIZATION:e.target.value})})]})]}),(0,a.jsxs)(b.Z,{children:[(0,a.jsx)(_.Z,{children:"Azure"}),(0,a.jsx)(y.Z,{children:(0,a.jsx)(C.Z,{label:"Azure API key",fullWidth:!0,margin:"normal",value:s.AZURE_OPENAI_API_KEY,onChange:e=>o({...s,AZURE_OPENAI_API_KEY:e.target.value})})})]}),(0,a.jsxs)(b.Z,{children:[(0,a.jsx)(_.Z,{children:"Amazon Bedrock"}),(0,a.jsx)(y.Z,{children:(0,a.jsx)(C.Z,{label:"Bedrock Region",fullWidth:!0,margin:"normal",value:s.AWS_BEDROCK_REGION,onChange:e=>o({...s,AWS_BEDROCK_REGION:e.target.value})})})]}),(0,a.jsxs)(b.Z,{children:[(0,a.jsx)(_.Z,{children:"Anthropic"}),(0,a.jsx)(y.Z,{children:(0,a.jsx)(C.Z,{label:"Anthropic API key",fullWidth:!0,margin:"normal",value:s.ANTHROPIC_API_KEY,onChange:e=>o({...s,ANTHROPIC_API_KEY:e.target.value})})})]}),(0,a.jsxs)(b.Z,{children:[(0,a.jsx)(_.Z,{children:"Google Vertex AI"}),(0,a.jsx)(y.Z,{children:(0,a.jsx)(C.Z,{label:"Vertex API Key",fullWidth:!0,margin:"normal",value:s.VERTEX_API_KEY,onChange:e=>o({...s,VERTEX_API_KEY:e.target.value})})}),(0,a.jsx)(y.Z,{children:(0,a.jsx)(C.Z,{label:"Vertex Project ID",fullWidth:!0,margin:"normal",value:s.VERTEX_PROJECT_ID,onChange:e=>o({...s,VERTEX_PROJECT_ID:e.target.value})})}),(0,a.jsx)(y.Z,{children:(0,a.jsx)(C.Z,{label:"Vertex Region",fullWidth:!0,margin:"normal",value:s.VERTEX_REGION,onChange:e=>o({...s,VERTEX_REGION:e.target.value})})})]}),(0,a.jsxs)(b.Z,{children:[(0,a.jsx)(_.Z,{children:"Replicate"}),(0,a.jsx)(y.Z,{children:(0,a.jsx)(C.Z,{label:"Replicate API key",fullWidth:!0,margin:"normal",value:s.REPLICATE_API_KEY,onChange:e=>o({...s,REPLICATE_API_KEY:e.target.value})})})]})]}),(0,a.jsxs)(p.Z,{children:[(0,a.jsx)(r.Z,{onClick:c,color:"primary",children:"Cancel"}),(0,a.jsx)(r.Z,{onClick:()=>{t(s),c()},color:"primary",variant:"contained",children:"Save"})]})]})]})},E=n(77656),I=n(65068),O=n(70417),P=n(21303),S=n(61451),T=n(30021),w=n(65969),R=n(14931),W=n(5592),N=n(2185),z=n(35185),F=e=>{let{open:t,prompt:n,index:l,onAdd:s,onCancel:o}=e,[c,h]=i.useState(n),m=i.useRef(null);i.useEffect(()=>{h(n)},[n]);let f=e=>{s(c),h(""),e?o():m.current&&m.current.focus()};return(0,a.jsxs)(d.Z,{open:t,onClose:o,fullWidth:!0,maxWidth:"md",children:[(0,a.jsx)(x.Z,{children:"Edit Prompt ".concat(l+1)}),(0,a.jsx)(u.Z,{children:(0,a.jsx)(C.Z,{value:c,onChange:e=>h(e.target.value),fullWidth:!0,margin:"normal",multiline:!0,placeholder:"The quick brown {{animal1}} jumps over the lazy {{animal2}}.",helperText:"Tip: use the {{varname}} syntax to add variables to your prompt.",inputRef:m})}),(0,a.jsxs)(p.Z,{children:[(0,a.jsx)(r.Z,{onClick:f.bind(null,!0),color:"primary",variant:"contained",disabled:!c.length,children:"Add"}),(0,a.jsx)(r.Z,{onClick:f.bind(null,!1),color:"primary",variant:"contained",disabled:!c.length,children:"Add Another"}),(0,a.jsx)(r.Z,{onClick:o,color:"secondary",children:"Cancel"})]})]})};n(94499);var V=()=>{let[e,t]=(0,i.useState)(!1),[n,l]=(0,i.useState)(null),{prompts:o,setPrompts:d}=(0,j.o)(),p=(0,i.useRef)(null);(0,i.useEffect)(()=>{null!==n&&n>0&&p.current&&p.current.focus()},[n]);let u=e=>{l(e),t(!0)},h=(e,t)=>{e.stopPropagation();let n=o[t];d([...o,n])},x=(e,t)=>{d(o.map((n,a)=>a===e?t:n))},m=(e,t)=>{e.stopPropagation(),confirm("Are you sure you want to remove this prompt?")&&d(o.filter((e,n)=>n!==t))};return(0,a.jsxs)("div",{children:[(0,a.jsxs)(c.Z,{direction:"row",spacing:2,justifyContent:"space-between",children:[(0,a.jsx)(s.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)(N.Z,{})}),(0,a.jsx)("input",{id:"file-input-add-prompt",type:"file",accept:".txt,.md",onChange:e=>{var t;e.stopPropagation(),e.preventDefault();let n=null===(t=e.target.files)||void 0===t?void 0:t[0];if(n){let e=new FileReader;e.onload=e=>{var t,n;let a=null===(n=e.target)||void 0===n?void 0:null===(t=n.result)||void 0===t?void 0:t.toString();a&&d([...o,a])},e.readAsText(n)}},style:{display:"none"}})]})})}),(0,a.jsx)(r.Z,{color:"primary",onClick:()=>{t(!0)},variant:"contained",children:"Add Prompt"})]})]}),(0,a.jsx)(S.Z,{children:(0,a.jsx)(I.Z,{children:(0,a.jsx)(O.Z,{children:0===o.length?(0,a.jsx)(T.Z,{children:(0,a.jsx)(P.Z,{colSpan:2,align:"center",children:"No prompts added yet."})}):o.map((e,t)=>(0,a.jsxs)(T.Z,{sx:{"&:hover":{backgroundColor:"rgba(0, 0, 0, 0.04)",cursor:"pointer"}},onClick:()=>u(t),children:[(0,a.jsx)(P.Z,{children:(0,a.jsxs)(s.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)(P.Z,{align:"right",sx:{minWidth:150},children:[(0,a.jsx)(E.Z,{onClick:()=>u(t),size:"small",children:(0,a.jsx)(R.Z,{})}),(0,a.jsx)(E.Z,{onClick:e=>h(e,t),size:"small",children:(0,a.jsx)(z.Z,{})}),(0,a.jsx)(E.Z,{onClick:e=>m(e,t),size:"small",children:(0,a.jsx)(W.Z,{})})]})]},t))})})}),(0,a.jsx)(F,{open:e,prompt:null!==n?o[n]:"",index:null!==n?n:0,onAdd:e=>{null!==n?x(n,e):d([...o,e]),l(null)},onCancel:()=>{l(null),t(!1)}})]})},L=n(26485),U=e=>{let{onAdd:t,varsList:n,initialValues:r}=e,[l,d]=i.useState(r||{});return(0,i.useEffect)(()=>{let e={};n.forEach(t=>{e[t]=(null==r?void 0:r[t])||""}),d(e)},[n,r]),(0,a.jsxs)(o.Z,{my:2,children:[(0,a.jsx)(s.Z,{variant:"h6",mb:2,children:"Vars"}),n.length>0?(0,a.jsx)(c.Z,{direction:"row",spacing:2,alignItems:"center",children:Object.keys(l).map((e,n)=>(0,a.jsx)(c.Z,{direction:"row",spacing:2,alignItems:"center",children:(0,a.jsx)(C.Z,{placeholder:e,label:e,value:l[e],fullWidth:!0,onChange:n=>{let a=n.target.value,i={...l,[e]:a};d(i),t(i)}})},n))}):(0,a.jsxs)(s.Z,{variant:"subtitle1",gutterBottom:!0,children:["Add variables to your prompt using the ","{{varname}}"," syntax."]})]})},q=n(68873);let B=["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 K=e=>{let{onAdd:t,initialValues:n}=e,[l,d]=(0,i.useState)(n||[]),p=e=>{let n=l.filter((t,n)=>n!==e);d(n),t(n)};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(s.Z,{variant:"h6",children:"Asserts"}),(0,a.jsx)(o.Z,{my:l.length>0?2:0,children:(0,a.jsx)(c.Z,{direction:"column",spacing:2,children:l.map((e,n)=>(0,a.jsxs)(c.Z,{direction:"row",spacing:2,alignItems:"center",children:[(0,a.jsx)(q.Z,{value:e.type,options:B,sx:{minWidth:200},onChange:(e,a)=>{let i=l.map((e,t)=>t===n?{...e,type:a}:e);d(i),t(i)},renderInput:e=>(0,a.jsx)(C.Z,{...e,label:"Type"})}),(0,a.jsx)(C.Z,{label:"Value",value:e.value,fullWidth:!0,onChange:e=>{let a=e.target.value,i=l.map((e,t)=>t===n?{...e,value:a}:e);d(i),t(i)}}),(0,a.jsx)(E.Z,{onClick:()=>p(n),size:"small",children:(0,a.jsx)(W.Z,{})})]},n))})}),(0,a.jsx)(r.Z,{color:"primary",onClick:()=>{let e=[...l,{type:"equals",value:""}];d(e),t(e)},children:"Add Assert"})]})},D=e=>{let{open:t,onAdd:n,varsList:l,initialValues:s,onCancel:c}=e,[h,m]=(0,i.useState)((null==s?void 0:s.description)||""),[f,g]=(0,i.useState)((null==s?void 0:s.vars)||{}),[j,v]=(0,i.useState)((null==s?void 0:s.assert)||[]),[Z,b]=(0,i.useState)(0);i.useEffect(()=>{s?(m(s.description||""),g(s.vars||{}),v(s.assert||[])):(m(""),g({}),v([]))},[s]);let y=e=>{n({description:h,vars:f,assert:j},e),e&&c(),m(""),g({}),v([]),b(e=>e+1)};return(0,a.jsxs)(d.Z,{open:t,onClose:c,fullWidth:!0,maxWidth:"md",children:[(0,a.jsx)(x.Z,{children:s?"Edit Test Case":"Add Test Case"}),(0,a.jsx)(u.Z,{children:(0,a.jsxs)(o.Z,{children:[(0,a.jsx)(U,{onAdd:e=>g(e),varsList:l,initialValues:null==s?void 0:s.vars}),(0,a.jsx)(K,{onAdd:e=>v(e),initialValues:((null==s?void 0:s.assert)||[]).filter(e=>"assert-set"!==e.type)||[]},Z)]})}),(0,a.jsxs)(p.Z,{children:[(0,a.jsx)(r.Z,{onClick:y.bind(void 0,!0),color:"primary",variant:"contained",children:s?"Update Test Case":"Add Test Case"}),!s&&(0,a.jsx)(r.Z,{onClick:y.bind(void 0,!1),color:"primary",variant:"contained",children:"Add Another"}),(0,a.jsx)(r.Z,{onClick:c,color:"secondary",children:"Cancel"})]})]})},Y=n(15320),J=e=>{let{varsList:t}=e,{testCases:l,setTestCases:o}=(0,j.o)(),[d,p]=i.useState(null),[u,h]=i.useState(!1),x=(e,t)=>{e.stopPropagation(),confirm("Are you sure you want to delete this test case?")&&o(l.filter((e,n)=>n!==t))},m=(e,t)=>{e.stopPropagation();let n=JSON.parse(JSON.stringify(l[t]));o([...l,n])};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(c.Z,{direction:"row",spacing:2,justifyContent:"space-between",children:[(0,a.jsx)(s.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)(N.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});o([...l,...t.map(e=>(0,Y.It)(e))])}},e.readAsText(a)}},style:{display:"none"}})]})})}),(0,a.jsx)(r.Z,{color:"primary",onClick:()=>h(!0),variant:"contained",children:"Add Test Case"})]})]}),(0,a.jsx)(S.Z,{children:(0,a.jsxs)(I.Z,{children:[(0,a.jsx)(L.Z,{children:(0,a.jsxs)(T.Z,{children:[(0,a.jsx)(P.Z,{children:"Description"}),(0,a.jsx)(P.Z,{children:"Assertions"}),(0,a.jsx)(P.Z,{children:"Variables"}),(0,a.jsx)(P.Z,{align:"right"})]})}),(0,a.jsx)(O.Z,{children:0===l.length?(0,a.jsx)(T.Z,{children:(0,a.jsx)(P.Z,{colSpan:4,align:"center",children:"No test cases added yet."})}):l.map((e,t)=>{var n;return(0,a.jsxs)(T.Z,{sx:{"&:hover":{backgroundColor:"rgba(0, 0, 0, 0.04)",cursor:"pointer"}},onClick:()=>{p(t),h(!0)},children:[(0,a.jsx)(P.Z,{children:(0,a.jsx)(s.Z,{variant:"body2",children:e.description||"Test Case #".concat(t+1)})}),(0,a.jsxs)(P.Z,{children:[(null===(n=e.assert)||void 0===n?void 0:n.length)||0," assertions"]}),(0,a.jsx)(P.Z,{children:Object.entries(e.vars||{}).map(e=>{let[t,n]=e;return t+"="+n}).join(", ")}),(0,a.jsxs)(P.Z,{align:"right",sx:{minWidth:150},children:[(0,a.jsx)(E.Z,{onClick:()=>{p(t),h(!0)},size:"small",children:(0,a.jsx)(R.Z,{})}),(0,a.jsx)(E.Z,{onClick:e=>m(e,t),size:"small",children:(0,a.jsx)(z.Z,{})}),(0,a.jsx)(E.Z,{onClick:e=>x(e,t),size:"small",children:(0,a.jsx)(W.Z,{})})]})]},t)})})]})}),(0,a.jsx)(D,{open:u,onAdd:(e,t)=>{if(null===d)o([...l,e]);else{let t=l.map((t,n)=>n===d?e:t);o(t),p(null)}t&&h(!1)},varsList:t,initialValues:null!==d?l[d]:void 0,onCancel:()=>{p(null),h(!1)}})]})},X=n(885),G=e=>{let{onChange:t,...n}=e,[r,l]=i.useState(""),[s,o]=i.useState(!1);return(0,a.jsx)(C.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)}}})},H=e=>{let{open:t,providerId:n,config:l,onClose:s,onSave:c}=e,[h,m]=i.useState(l);return i.useEffect(()=>{m(l)},[l]),(0,a.jsxs)(d.Z,{open:t,onClose:s,fullWidth:!0,maxWidth:"md",children:[(0,a.jsxs)(x.Z,{children:["Edit ",n.length>50?n.slice(0,50)+"...":n]}),(0,a.jsx)(u.Z,{children:Object.keys(h).map(e=>{let t;let n=h[e];return"number"==typeof n||"boolean"==typeof n||"string"==typeof n?(t="number"==typeof n?t=>m({...h,[e]:parseFloat(t.target.value)}):"boolean"==typeof n?t=>m({...h,[e]:"true"===t.target.value}):t=>{let n=t.target.value.trim();if(n.startsWith("{")||n.startsWith("["))try{m({...h,[e]:JSON.parse(n)})}catch(t){m({...h,[e]:n})}else"null"===n?m({...h,[e]:null}):"undefined"===n?m({...h,[e]:void 0}):m({...h,[e]:n})},(0,a.jsx)(o.Z,{my:2,children:(0,a.jsx)(C.Z,{label:e,value:n,onChange:t,fullWidth:!0,InputLabelProps:{shrink:!0},type:"number"==typeof n?"number":"text"})},e)):(0,a.jsx)(o.Z,{my:2,children:(0,a.jsx)(G,{label:e,defaultValue:JSON.stringify(n),onChange:t=>{m({...h,[e]:t})},fullWidth:!0,multiline:!0,minRows:2,InputLabelProps:{shrink:!0}})},e)})}),(0,a.jsxs)(p.Z,{children:[(0,a.jsx)(r.Z,{onClick:s,children:"Cancel"}),(0,a.jsx)(r.Z,{onClick:()=>{c(h)},children:"Save"})]})]})};let M=[].concat(["replicate:replicate/flan-t5-small:69716ad8c34274043bf4a135b7315c7c569ec931d8f23d6826e249e1c142a264"].map(e=>({id:e,config:{temperature:.5,max_length:1024,repetition_penality:1}}))).concat(["replicate:replicate/codellama-7b-instruct:0103579e86fc75ba0d65912890fa19ef03c84a68554635319accf2e0ba93d3ae","replicate:replicate/codellama-13b-instruct:da5676342de1a5a335b848383af297f592b816b950a43d251a0a9edd0113604b","replicate:replicate/llama-2-70b-chat:2796ee9483c3fd7aa2e171d38f4ca12251a30609463dcfd4cd76703f22e96cdf"].map(e=>({id:e,config:{system_prompt:"",temperature:.75,top_p:.9,top_k:50,max_new_tokens:128,min_new_tokens:-1}}))).concat(["replicate:replicate/codellama-7b:6880b103613a9cd23950c5fd6c140197e519905bd0dd00e448c4858bdd06090a","replicate:replicate/codellama-13b-python:09b87c02dfa403e0c3289166dece62286b3bce49bae39a9c9204713cf94b8b7d","replicate:replicate/codellama-13b:1c914d844307b0588599b8393480a3ba917b660c7e9dfae681542b5325f228db","replicate:replicate/codellama-34b-python:9048743d22a7b19cd0abb018066809ea6af4f2b4717bef9aad3c5ae21ceac00d","replicate:replicate/codellama-34b:0666717e5ead8557dff55ee8f11924b5c0309f5f1ca52f64bb8eec405fdb38a7"].map(e=>({id:e,config:{temperature:.75,top_p:.9,top_k:50,max_new_tokens:128,min_new_tokens:-1}}))).concat(["replicate:a16z-infra/llama-2-7b-chat:7b0bfc9aff140d5b75bacbed23e91fd3c34b01a1e958d32132de6e0a19796e2c","replicate:a16z-infra/llama-2-13b-chat:2a7f981751ec7fdf87b5b91ad4db53683a98082e9ff7bfd12c8cd5ea85980a52"].map(e=>({id:e,config:{temperature:.95,top_p:.95,top_k:250,max_new_tokens:500,min_new_tokens:-1,repetition_penality:1,system_prompt:""}}))).concat(["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_penality: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-3.5-turbo","openai:gpt-3.5-turbo-0301","openai:gpt-3.5-turbo-0613","openai:gpt-3.5-turbo-16k","openai:gpt-3.5-turbo-16k-0613","openai:gpt-4","openai:gpt-4-0314","openai:gpt-4-0613","openai:gpt-4-32k","openai:gpt-4-32k-0314"].map(e=>({id:e,config:{organization:"",temperature:.5,max_tokens:1024,top_p:1,frequency_penalty:0,presence_penalty:0,function_call:void 0,functions:void 0,stop:void 0}}))).concat(["azureopenai:gpt-3.5-turbo","azureopenai:gpt-3.5-turbo-0301","azureopenai:gpt-3.5-turbo-0613","azureopenai:gpt-3.5-turbo-16k","azureopenai:gpt-3.5-turbo-16k-0613","azureopenai:gpt-4","azureopenai:gpt-4-0314","azureopenai:gpt-4-0613","azureopenai:gpt-4-32k","azureopenai:gpt-4-32k-0314"].map(e=>({id:e,config:{temperature:.5,max_tokens:1024,top_p:1,frequency_penalty:0,presence_penalty:0,function_call:void 0,functions:void 0,stop:void 0}}))).concat(["vertex:chat-bison@001","vertex:chat-bison","vertex:chat-bison-32k","vertex:chat-bison-32k@001"].map(e=>({id:e,config:{context:void 0,examples:void 0,temperature:0,maxOutputTokens:1024,topP:.95,topK:40,safetySettings:void 0,stopSequence:void 0}}))).sort((e,t)=>e.id.localeCompare(t.id)),$={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),s=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)(o.Z,{mt:2,children:[(0,a.jsx)(q.Z,{multiple:!0,freeSolo:!0,options:M,value:t,groupBy:e=>(function(e){if(!e)return"Other";let t=e.split(":")[0];return $[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=s(e),r=c(e,n);return(0,i.createElement)(X.Z,{variant:"outlined",label:a,...t({index:n}),key:r,onClick:()=>d(e)})}),renderInput:e=>(0,a.jsx)(C.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)(H,{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)}}})]})},ee=n(71911),et=n.n(ee),en=n(29270);n(54492),n(93486);var ea=n(34235),ei=n(93522),er=n(38640),el=n.n(er);n(55096);var es=()=>{let{env:e,setEnv:t,description:n,setDescription:l,providers:c,setProviders:d,prompts:p,setPrompts:u,testCases:h,setTestCases:x,defaultTest:m,setDefaultTest:f,evaluateOptions:g,setEvaluateOptions:v}=(0,j.o)(),[Z,b]=i.useState(""),[y,_]=i.useState(!0);i.useEffect(()=>{b(ea.default.dump({env:e,description:n,providers:c,prompts:p,tests:h,defaultTest:m,evaluateOptions:g}))},[e,n,c,p,h,m,g]);let C=e=>{t(e.env||{}),l(e.description||""),d(e.providers||[]),u(e.prompts||[]),x(e.tests||[]),f(e.defaultTest||{}),v(e.evaluateOptions||{})};return(0,a.jsxs)(o.Z,{mt:4,children:[(0,a.jsx)(s.Z,{variant:"h5",gutterBottom:!0,children:"Configuration"}),(0,a.jsxs)(s.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)(r.Z,{variant:"text",color:"primary",startIcon:y?(0,a.jsx)(R.Z,{}):(0,a.jsx)(ei.Z,{}),onClick:()=>{if(!y)try{let e=ea.default.load(Z,{json:!0});C(e)}catch(e){}_(!y)},children:y?"Edit YAML":"Save"}),(0,a.jsx)(et(),{autoCapitalize:"off",value:Z,onValueChange:e=>{y||b(e)},highlight:e=>(0,en.highlight)(e,en.languages.yaml),padding:10,style:{fontFamily:'"Fira code", "Fira Mono", monospace',fontSize:14},disabled:y,className:y?"":"glowing-border"})]})};n(7517);var eo=n(77580);function ec(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 ed=()=>{let[e,t]=(0,i.useState)(!1),{description:n,setDescription:f,providers:g,setProviders:v,prompts:b,setPrompts:y,testCases:_,setTestCases:C}=(0,j.o)();if((0,i.useEffect)(()=>{j.o.persist.rehydrate()},[]),eo.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)})(b);return(0,a.jsxs)(l.Z,{maxWidth:"lg",sx:{marginTop:"2rem"},children:[(0,a.jsxs)(c.Z,{direction:"row",spacing:2,justifyContent:"space-between",children:[(0,a.jsx)(s.Z,{variant:"h4",children:"Set up an evaluation"}),(0,a.jsxs)(c.Z,{direction:"row",spacing:2,children:[(0,a.jsx)(Z,{}),(0,a.jsx)(A,{}),(0,a.jsx)(r.Z,{variant:"outlined",color:"primary",onClick:()=>t(!0),children:"Reset"})]})]}),(0,a.jsx)(o.Z,{mt:4}),(0,a.jsx)(o.Z,{mt:2,children:(0,a.jsx)(m.SV,{FallbackComponent:ec,onReset:()=>{v([])},children:(0,a.jsxs)(c.Z,{direction:"column",spacing:2,justifyContent:"space-between",children:[(0,a.jsx)(s.Z,{variant:"h5",children:"Providers"}),(0,a.jsx)(Q,{providers:g,onChange:v})]})})}),(0,a.jsx)(o.Z,{mt:4}),(0,a.jsx)(m.SV,{FallbackComponent:ec,onReset:()=>{y([])},children:(0,a.jsx)(V,{})}),(0,a.jsx)(o.Z,{mt:6}),(0,a.jsx)(m.SV,{FallbackComponent:ec,onReset:()=>{C([])},children:(0,a.jsx)(J,{varsList:k})}),(0,a.jsx)(es,{}),(0,a.jsxs)(d.Z,{open:e,onClose:()=>t(!1),"aria-labelledby":"alert-dialog-title","aria-describedby":"alert-dialog-description",children:[(0,a.jsx)(x.Z,{id:"alert-dialog-title",children:"Confirm Reset"}),(0,a.jsx)(u.Z,{children:(0,a.jsx)(h.Z,{id:"alert-dialog-description",children:"Are you sure you want to reset all the fields? This action cannot be undone."})}),(0,a.jsxs)(p.Z,{children:[(0,a.jsx)(r.Z,{onClick:()=>t(!1),children:"Cancel"}),(0,a.jsx)(r.Z,{onClick:()=>{f(""),v([]),y([]),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:{},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}),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),e(n)},getTestSuite:()=>{let{description:e,testCases:n,providers:a,prompts:i,env:r}=t();return{env:r,description:e,providers:a,prompts:i,tests:n}}}),{name:"promptfoo",skipHydration:!0}))},94499:function(){},55096:function(){},7517:function(){},15320:function(e,t){"use strict";t.It=void 0,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,[540,640,215,620,770,304,339,995,378,374,235,873,106,258,470,730,744],function(){return e(e.s=76178)}),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- !function(){"use strict";var e,t,n,r,o,u,i,c,f,a={},d={};function l(e){var t=d[e];if(void 0!==t)return t.exports;var n=d[e]={exports:{}},r=!0;try{a[e].call(n.exports,n,n.exports,l),r=!1}finally{r&&delete d[e]}return n.exports}l.m=a,e=[],l.O=function(t,n,r,o){if(n){o=o||0;for(var u=e.length;u>0&&e[u-1][2]>o;u--)e[u]=e[u-1];e[u]=[n,r,o];return}for(var i=1/0,u=0;u<e.length;u++){for(var n=e[u][0],r=e[u][1],o=e[u][2],c=!0,f=0;f<n.length;f++)i>=o&&Object.keys(l.O).every(function(e){return l.O[e](n[f])})?n.splice(f--,1):(c=!1,o<i&&(i=o));if(c){e.splice(u--,1);var a=r();void 0!==a&&(t=a)}}return t},l.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(t,{a:t}),t},n=Object.getPrototypeOf?function(e){return Object.getPrototypeOf(e)}:function(e){return e.__proto__},l.t=function(e,r){if(1&r&&(e=this(e)),8&r||"object"==typeof e&&e&&(4&r&&e.__esModule||16&r&&"function"==typeof e.then))return e;var o=Object.create(null);l.r(o);var u={};t=t||[null,n({}),n([]),n(n)];for(var i=2&r&&e;"object"==typeof i&&!~t.indexOf(i);i=n(i))Object.getOwnPropertyNames(i).forEach(function(t){u[t]=function(){return e[t]}});return u.default=function(){return e},l.d(o,u),o},l.d=function(e,t){for(var n in t)l.o(t,n)&&!l.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},l.f={},l.e=function(e){return Promise.all(Object.keys(l.f).reduce(function(t,n){return l.f[n](e,t),t},[]))},l.u=function(e){return 631===e?"static/chunks/631-87fea556bbafe972.js":"static/chunks/"+e+"."+({407:"42b5daf65ab5dde9",887:"028187fb318c3e59"})[e]+".js"},l.miniCssF=function(e){return"static/css/"+({11:"451beaa5570cb9d3",185:"51a17e8edcdfdbb2",413:"16c1dd82fc87c9d7",420:"51f7d6933894a4f8",421:"e9f25719d0b14939",466:"48d388184a2f4ce3",931:"8119d8bd13a8adab"})[e]+".css"},l.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),l.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r={},o="_N_E:",l.l=function(e,t,n,u){if(r[e]){r[e].push(t);return}if(void 0!==n)for(var i,c,f=document.getElementsByTagName("script"),a=0;a<f.length;a++){var d=f[a];if(d.getAttribute("src")==e||d.getAttribute("data-webpack")==o+n){i=d;break}}i||(c=!0,(i=document.createElement("script")).charset="utf-8",i.timeout=120,l.nc&&i.setAttribute("nonce",l.nc),i.setAttribute("data-webpack",o+n),i.src=l.tu(e)),r[e]=[t];var s=function(t,n){i.onerror=i.onload=null,clearTimeout(p);var o=r[e];if(delete r[e],i.parentNode&&i.parentNode.removeChild(i),o&&o.forEach(function(e){return e(n)}),t)return t(n)},p=setTimeout(s.bind(null,void 0,{type:"timeout",target:i}),12e4);i.onerror=s.bind(null,i.onerror),i.onload=s.bind(null,i.onload),c&&document.head.appendChild(i)},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.tt=function(){return void 0===u&&(u={createScriptURL:function(e){return e}},"undefined"!=typeof trustedTypes&&trustedTypes.createPolicy&&(u=trustedTypes.createPolicy("nextjs#bundler",u))),u},l.tu=function(e){return l.tt().createScriptURL(e)},l.p="/_next/",i={272:0},l.f.j=function(e,t){var n=l.o(i,e)?i[e]:void 0;if(0!==n){if(n)t.push(n[2]);else if(272!=e){var r=new Promise(function(t,r){n=i[e]=[t,r]});t.push(n[2]=r);var o=l.p+l.u(e),u=Error();l.l(o,function(t){if(l.o(i,e)&&(0!==(n=i[e])&&(i[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;u.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",u.name="ChunkLoadError",u.type=r,u.request=o,n[1](u)}},"chunk-"+e,e)}else i[e]=0}},l.O.j=function(e){return 0===i[e]},c=function(e,t){var n,r,o=t[0],u=t[1],c=t[2],f=0;if(o.some(function(e){return 0!==i[e]})){for(n in u)l.o(u,n)&&(l.m[n]=u[n]);if(c)var a=c(l)}for(e&&e(t);f<o.length;f++)r=o[f],l.o(i,r)&&i[r]&&i[r][0](),i[r]=0;return l.O(a)},(f=self.webpackChunk_N_E=self.webpackChunk_N_E||[]).forEach(c.bind(null,0)),f.push=c.bind(null,f.push.bind(f))}();
@@ -1 +0,0 @@
1
- .prompt-var-highlight{background-color:var(--prompt-highlight-color);padding:.25rem;border-radius:4px}code[class*=language-],pre[class*=language-]{color:#000;background:none;text-shadow:0 1px #fff;font-family:Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace;font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;tab-size:4;-webkit-hyphens:none;hyphens:none}code[class*=language-] ::selection,code[class*=language-]::selection,pre[class*=language-] ::selection,pre[class*=language-]::selection{text-shadow:none;background:#b3d4fc}@media print{code[class*=language-],pre[class*=language-]{text-shadow:none}}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto}:not(pre)>code[class*=language-],pre[class*=language-]{background:#f5f2f0}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#708090}.token.punctuation{color:#999}.token.namespace{opacity:.7}.token.boolean,.token.constant,.token.deleted,.token.number,.token.property,.token.symbol,.token.tag{color:#905}.token.attr-name,.token.builtin,.token.char,.token.inserted,.token.selector,.token.string{color:#690}.language-css .token.string,.style .token.string,.token.entity,.token.operator,.token.url{color:#9a6e3a;background:hsla(0,0%,100%,.5)}.token.atrule,.token.attr-value,.token.keyword{color:#07a}.token.class-name,.token.function{color:#dd4a68}.token.important,.token.regex,.token.variable{color:#e90}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}.glowing-border{border:1px solid #5cb3ff;box-shadow:0 0 8px 2px #5cb3ff}.yaml-config{font-size:10px}
@@ -1 +0,0 @@
1
- .risk-card-container{padding-top:3rem;padding-bottom:3rem}.risk-card-title{font-weight:700}.risk-card-progress{margin-bottom:1rem}.risk-card-issues{color:red}.risk-card-list-item{padding:0}.risk-card-icon-passed{color:green;font-size:16px}.risk-card-icon-failed{color:red;font-size:16px}.card-critical{border-left:5px solid red}.card-critical,.card-high{box-shadow:0 4px 8px rgba(0,0,0,.1);transition:transform .2s}.card-high{border-left:5px solid #f90}.card-medium{border-left:5px solid #fc0}.card-low,.card-medium{box-shadow:0 4px 8px rgba(0,0,0,.1);transition:transform .2s}.card-low{border-left:5px solid #0c0}.card-critical:hover,.card-high:hover,.card-low:hover,.card-medium:hover{transform:translateY(-5px)}.pass-high{color:green}.pass-medium{color:#cb8503}.pass-low{color:red}.vuln-critical{color:red;font-weight:700}.vuln-high{color:red}.vuln-medium{color:#cb8503}.vuln-low{color:green}.report-header{margin-bottom:20px}.report-header strong{font-weight:500}.report-details{display:flex;flex-direction:row;gap:10px}.report-details strong{font-weight:500}