promptfoo 0.46.0 → 0.48.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 (100) hide show
  1. package/README.md +2 -0
  2. package/dist/drizzle/0000_lush_hellion.sql +36 -0
  3. package/dist/drizzle/0001_wide_calypso.sql +3 -0
  4. package/dist/drizzle/meta/0000_snapshot.json +244 -0
  5. package/dist/drizzle/meta/0001_snapshot.json +237 -0
  6. package/dist/drizzle/meta/_journal.json +20 -0
  7. package/dist/package.json +10 -3
  8. package/dist/src/__mocks__/database.d.ts +5 -0
  9. package/dist/src/__mocks__/database.d.ts.map +1 -0
  10. package/dist/src/__mocks__/database.js +27 -0
  11. package/dist/src/__mocks__/database.js.map +1 -0
  12. package/dist/src/assertions.d.ts.map +1 -1
  13. package/dist/src/assertions.js +51 -42
  14. package/dist/src/assertions.js.map +1 -1
  15. package/dist/src/commands/list.d.ts.map +1 -1
  16. package/dist/src/commands/list.js +4 -5
  17. package/dist/src/commands/list.js.map +1 -1
  18. package/dist/src/commands/show.d.ts +1 -1
  19. package/dist/src/commands/show.d.ts.map +1 -1
  20. package/dist/src/commands/show.js +7 -7
  21. package/dist/src/commands/show.js.map +1 -1
  22. package/dist/src/csv.d.ts +1 -1
  23. package/dist/src/csv.d.ts.map +1 -1
  24. package/dist/src/csv.js +5 -0
  25. package/dist/src/csv.js.map +1 -1
  26. package/dist/src/database.d.ts +238 -0
  27. package/dist/src/database.d.ts.map +1 -0
  28. package/dist/src/database.js +141 -0
  29. package/dist/src/database.js.map +1 -0
  30. package/dist/src/evaluator.d.ts.map +1 -1
  31. package/dist/src/evaluator.js +8 -6
  32. package/dist/src/evaluator.js.map +1 -1
  33. package/dist/src/index.d.ts.map +1 -1
  34. package/dist/src/index.js +2 -1
  35. package/dist/src/index.js.map +1 -1
  36. package/dist/src/main.js +6 -4
  37. package/dist/src/main.js.map +1 -1
  38. package/dist/src/migrate.d.ts +5 -0
  39. package/dist/src/migrate.d.ts.map +1 -0
  40. package/dist/src/migrate.js +50 -0
  41. package/dist/src/migrate.js.map +1 -0
  42. package/dist/src/prompts.d.ts.map +1 -1
  43. package/dist/src/prompts.js +3 -0
  44. package/dist/src/prompts.js.map +1 -1
  45. package/dist/src/providers/anthropic.d.ts.map +1 -1
  46. package/dist/src/providers/anthropic.js +37 -1
  47. package/dist/src/providers/anthropic.js.map +1 -1
  48. package/dist/src/providers/azureopenai.d.ts +16 -0
  49. package/dist/src/providers/azureopenai.d.ts.map +1 -1
  50. package/dist/src/providers/azureopenai.js +6 -2
  51. package/dist/src/providers/azureopenai.js.map +1 -1
  52. package/dist/src/providers/replicate.d.ts.map +1 -1
  53. package/dist/src/providers/replicate.js +16 -1
  54. package/dist/src/providers/replicate.js.map +1 -1
  55. package/dist/src/providers.d.ts.map +1 -1
  56. package/dist/src/providers.js +2 -1
  57. package/dist/src/providers.js.map +1 -1
  58. package/dist/src/python/wrapper.d.ts +9 -1
  59. package/dist/src/python/wrapper.d.ts.map +1 -1
  60. package/dist/src/python/wrapper.js +32 -4
  61. package/dist/src/python/wrapper.js.map +1 -1
  62. package/dist/src/types.d.ts +5 -6
  63. package/dist/src/types.d.ts.map +1 -1
  64. package/dist/src/util.d.ts +52 -19
  65. package/dist/src/util.d.ts.map +1 -1
  66. package/dist/src/util.js +378 -125
  67. package/dist/src/util.js.map +1 -1
  68. package/dist/src/web/nextui/404/index.html +1 -1
  69. package/dist/src/web/nextui/404.html +1 -1
  70. package/dist/src/web/nextui/_next/static/chunks/952-ede6b209625d42a2.js +1 -0
  71. package/dist/src/web/nextui/_next/static/chunks/app/datasets/page-ad55f89d622ef8e7.js +1 -0
  72. package/dist/src/web/nextui/_next/static/chunks/app/prompts/page-01ab4878803b7068.js +1 -0
  73. package/dist/src/web/nextui/_next/static/chunks/app/setup/page-9c163111247d8da5.js +1 -0
  74. package/dist/src/web/nextui/api/results +1 -1
  75. package/dist/src/web/nextui/auth/login/index.html +1 -1
  76. package/dist/src/web/nextui/auth/login/index.txt +3 -3
  77. package/dist/src/web/nextui/auth/signup/index.html +1 -1
  78. package/dist/src/web/nextui/auth/signup/index.txt +3 -3
  79. package/dist/src/web/nextui/datasets/index.html +1 -1
  80. package/dist/src/web/nextui/datasets/index.txt +3 -3
  81. package/dist/src/web/nextui/eval/index.html +1 -1
  82. package/dist/src/web/nextui/eval/index.txt +3 -3
  83. package/dist/src/web/nextui/index.html +1 -1
  84. package/dist/src/web/nextui/index.txt +2 -2
  85. package/dist/src/web/nextui/prompts/index.html +1 -1
  86. package/dist/src/web/nextui/prompts/index.txt +3 -3
  87. package/dist/src/web/nextui/setup/index.html +1 -1
  88. package/dist/src/web/nextui/setup/index.txt +3 -3
  89. package/dist/src/web/server.d.ts +1 -1
  90. package/dist/src/web/server.d.ts.map +1 -1
  91. package/dist/src/web/server.js +25 -43
  92. package/dist/src/web/server.js.map +1 -1
  93. package/package.json +10 -3
  94. package/dist/src/web/nextui/_next/static/chunks/952-1367984f076e3060.js +0 -1
  95. package/dist/src/web/nextui/_next/static/chunks/app/datasets/page-44ab188f3b846712.js +0 -1
  96. package/dist/src/web/nextui/_next/static/chunks/app/prompts/page-0bf3409d6a6bfa22.js +0 -1
  97. package/dist/src/web/nextui/_next/static/chunks/app/setup/page-83c7e62787113081.js +0 -1
  98. /package/dist/src/web/nextui/_next/static/{Np8tRhZUzimy-v_hu8F8W → 8yxA5JzS0wXTxJptFRKTo}/_buildManifest.js +0 -0
  99. /package/dist/src/web/nextui/_next/static/{Np8tRhZUzimy-v_hu8F8W → 8yxA5JzS0wXTxJptFRKTo}/_ssgManifest.js +0 -0
  100. /package/dist/src/web/nextui/_next/static/chunks/{82-ca0360e473d81167.js → 82-6e8c9ebc91ff932b.js} +0 -0
@@ -5,11 +5,11 @@
5
5
  5:HL["/_next/static/media/699512af39861afa-s.p.woff2",{"as":"font","type":"font/woff2"}]
6
6
  6:HL["/_next/static/media/934c4b7cb736f2a3-s.p.woff2",{"as":"font","type":"font/woff2"}]
7
7
  7:HL["/_next/static/css/51a17e8edcdfdbb2.css",{"as":"style"}]
8
- 0:["Np8tRhZUzimy-v_hu8F8W",[[["",{"children":["prompts",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],"$L8",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/51a17e8edcdfdbb2.css","precedence":"next"}]],"$L9"]]]]
9
- a:I{"id":2112,"chunks":["293:static/chunks/293-fa7b9b02f62ab5d8.js","548:static/chunks/548-ffb8dd99ad3940cb.js","82:static/chunks/82-ca0360e473d81167.js","886:static/chunks/886-ed0ff9e461fce55a.js","445:static/chunks/445-74742af8ab1894f2.js","185:static/chunks/app/layout-d634a41da738217d.js"],"name":"PageShell","async":false}
8
+ 0:["8yxA5JzS0wXTxJptFRKTo",[[["",{"children":["prompts",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],"$L8",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/51a17e8edcdfdbb2.css","precedence":"next"}]],"$L9"]]]]
9
+ a:I{"id":2112,"chunks":["293:static/chunks/293-fa7b9b02f62ab5d8.js","548:static/chunks/548-ffb8dd99ad3940cb.js","82:static/chunks/82-6e8c9ebc91ff932b.js","886:static/chunks/886-ed0ff9e461fce55a.js","445:static/chunks/445-74742af8ab1894f2.js","185:static/chunks/app/layout-d634a41da738217d.js"],"name":"PageShell","async":false}
10
10
  b:I{"id":7767,"chunks":["272:static/chunks/webpack-ff9953f1ad73867d.js","971:static/chunks/fd9d1056-a95b789c94c05ff6.js","596:static/chunks/596-f3a131b7c336dd5d.js"],"name":"default","async":false}
11
11
  c:I{"id":7920,"chunks":["272:static/chunks/webpack-ff9953f1ad73867d.js","971:static/chunks/fd9d1056-a95b789c94c05ff6.js","596:static/chunks/596-f3a131b7c336dd5d.js"],"name":"default","async":false}
12
- e:I{"id":176,"chunks":["293:static/chunks/293-fa7b9b02f62ab5d8.js","808:static/chunks/808-b64f39fb5aa81c36.js","420:static/chunks/420-c4133cd89d8c5e4b.js","21:static/chunks/21-b6c126c8ac7d9c5e.js","794:static/chunks/app/prompts/page-0bf3409d6a6bfa22.js"],"name":"","async":false}
12
+ e:I{"id":176,"chunks":["293:static/chunks/293-fa7b9b02f62ab5d8.js","808:static/chunks/808-b64f39fb5aa81c36.js","420:static/chunks/420-c4133cd89d8c5e4b.js","21:static/chunks/21-b6c126c8ac7d9c5e.js","794:static/chunks/app/prompts/page-01ab4878803b7068.js"],"name":"","async":false}
13
13
  8:[null,["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_c5054f","children":["$","$La",null,{"children":["$","$Lb",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"template":["$","$Lc",null,{}],"templateStyles":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":"$undefined","childProp":{"current":["$","$Lb",null,{"parallelRouterKey":"children","segmentPath":["children","prompts","children"],"error":"$undefined","errorStyles":"$undefined","loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"template":["$","$Lc",null,{}],"templateStyles":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","childProp":{"current":["$Ld",["$","div",null,{"children":["$","$Le",null,{}]}],null],"segment":"__PAGE__"},"styles":[]}],"segment":"prompts"},"styles":[]}]}]}]}],null]
14
14
  9:[["$","meta","0",{"charSet":"utf-8"}],["$","title","1",{"children":"promptfoo"}],["$","meta","2",{"name":"description","content":"LLM testing and evaluation"}],["$","meta","3",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","4",{"property":"og:image","content":"https://www.promptfoo.dev/img/thumbnail.png"}],["$","meta","5",{"name":"twitter:card","content":"summary"}],["$","meta","6",{"name":"twitter:image","content":"https://www.promptfoo.dev/img/thumbnail.png"}],["$","meta","7",{"name":"next-size-adjust"}]]
15
15
  d:null
@@ -24,4 +24,4 @@
24
24
  color: transparent !important;
25
25
  }
26
26
  }
27
- </style></div></div></div></div></div><script src="/_next/static/chunks/webpack-ff9953f1ad73867d.js" async=""></script><script src="/_next/static/chunks/fd9d1056-a95b789c94c05ff6.js" async=""></script><script src="/_next/static/chunks/596-f3a131b7c336dd5d.js" async=""></script><script src="/_next/static/chunks/main-app-581ccf0003955b21.js" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:HL[\"/_next/static/media/0e4fe491bf84089c-s.p.woff2\",{\"as\":\"font\",\"type\":\"font/woff2\"}]\n2:HL[\"/_next/static/media/3a04115668d8070d-s.p.woff2\",{\"as\":\"font\",\"type\":\"font/woff2\"}]\n3:HL[\"/_next/static/media/3a18fc8da1cdcd01-s.p.woff2\",{\"as\":\"font\",\"type\":\"font/woff2\"}]\n4:HL[\"/_next/static/media/627622453ef56b0d-s.p.woff2\",{\"as\":\"font\",\"type\":\"font/woff2\"}]\n5:HL[\"/_next/static/media/699512af39861afa-s.p.woff2\",{\"as\":\"font\",\"type\":\"font/woff2\"}]\n6:HL[\"/_next/static/media/934c4b7cb736f2a3-s.p.woff2\",{\"as\":\"font\","])</script><script>self.__next_f.push([1,"\"type\":\"font/woff2\"}]\n7:HL[\"/_next/static/css/51a17e8edcdfdbb2.css\",{\"as\":\"style\"}]\n0:\"$L8\"\n"])</script><script>self.__next_f.push([1,"9:HL[\"/_next/static/css/16c1dd82fc87c9d7.css\",{\"as\":\"style\"}]\n"])</script><script>self.__next_f.push([1,"a:I{\"id\":7948,\"chunks\":[\"272:static/chunks/webpack-ff9953f1ad73867d.js\",\"971:static/chunks/fd9d1056-a95b789c94c05ff6.js\",\"596:static/chunks/596-f3a131b7c336dd5d.js\"],\"name\":\"default\",\"async\":false}\nc:I{\"id\":6628,\"chunks\":[\"272:static/chunks/webpack-ff9953f1ad73867d.js\",\"971:static/chunks/fd9d1056-a95b789c94c05ff6.js\",\"596:static/chunks/596-f3a131b7c336dd5d.js\"],\"name\":\"\",\"async\":false}\nd:I{\"id\":2112,\"chunks\":[\"293:static/chunks/293-fa7b9b02f62ab5d8.js\",\"548:static/chunks/548-ffb8dd99ad3940cb.js\",\"82:static/"])</script><script>self.__next_f.push([1,"chunks/82-ca0360e473d81167.js\",\"886:static/chunks/886-ed0ff9e461fce55a.js\",\"445:static/chunks/445-74742af8ab1894f2.js\",\"185:static/chunks/app/layout-d634a41da738217d.js\"],\"name\":\"PageShell\",\"async\":false}\ne:I{\"id\":7767,\"chunks\":[\"272:static/chunks/webpack-ff9953f1ad73867d.js\",\"971:static/chunks/fd9d1056-a95b789c94c05ff6.js\",\"596:static/chunks/596-f3a131b7c336dd5d.js\"],\"name\":\"default\",\"async\":false}\nf:I{\"id\":7920,\"chunks\":[\"272:static/chunks/webpack-ff9953f1ad73867d.js\",\"971:static/chunks/fd9d1056-a95b789c9"])</script><script>self.__next_f.push([1,"4c05ff6.js\",\"596:static/chunks/596-f3a131b7c336dd5d.js\"],\"name\":\"default\",\"async\":false}\n11:I{\"id\":4839,\"chunks\":[\"272:static/chunks/webpack-ff9953f1ad73867d.js\",\"971:static/chunks/fd9d1056-a95b789c94c05ff6.js\",\"596:static/chunks/596-f3a131b7c336dd5d.js\"],\"name\":\"default\",\"async\":false}\n12:I{\"id\":2378,\"chunks\":[\"293:static/chunks/293-fa7b9b02f62ab5d8.js\",\"808:static/chunks/808-b64f39fb5aa81c36.js\",\"548:static/chunks/548-ffb8dd99ad3940cb.js\",\"420:static/chunks/420-c4133cd89d8c5e4b.js\",\"975:static/chunks/975-"])</script><script>self.__next_f.push([1,"41f6ad20b4031b30.js\",\"886:static/chunks/886-ed0ff9e461fce55a.js\",\"683:static/chunks/683-31836dfcc9c45e50.js\",\"339:static/chunks/339-501c32916b785ef1.js\",\"376:static/chunks/376-1c0d6e6983c73fe2.js\",\"413:static/chunks/app/setup/page-83c7e62787113081.js\"],\"name\":\"\",\"async\":false}\n"])</script><script>self.__next_f.push([1,"8:[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/51a17e8edcdfdbb2.css\",\"precedence\":\"next\"}]],[\"$\",\"$La\",null,{\"buildId\":\"Np8tRhZUzimy-v_hu8F8W\",\"assetPrefix\":\"\",\"initialCanonicalUrl\":\"/setup/\",\"initialTree\":[\"\",{\"children\":[\"setup\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],\"initialHead\":\"$Lb\",\"globalErrorComponent\":\"$c\",\"children\":[null,[\"$\",\"html\",null,{\"lang\":\"en\",\"children\":[\"$\",\"body\",null,{\"className\":\"__className_c5054f\",\"children\":[\"$\",\"$Ld\",null,{\"children\":[\"$\",\"$Le\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"loading\":\"$undefined\",\"loadingStyles\":\"$undefined\",\"hasLoading\":false,\"template\":[\"$\",\"$Lf\",null,{}],\"templateStyles\":\"$undefined\",\"notFound\":[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],\"notFoundStyles\":\"$undefined\",\"childProp\":{\"current\":[\"$\",\"$Le\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"setup\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"loading\":\"$undefined\",\"loadingStyles\":\"$undefined\",\"hasLoading\":false,\"template\":[\"$\",\"$Lf\",null,{}],\"templateStyles\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\",\"childProp\":{\"current\":[\"$L10\",[\"$\",\"$L11\",null,{\"propsForComponent\":{\"params\":{}},\"Component\":\"$12\"}],null],\"segment\":\"__PAGE__\"},\"styles\":[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/16c1dd82fc87c9d7.css\",\"precedence\":\"next\"}]]}],\"segment\":\"setup\"},\"styles\":[]}]}]}]}],null]}]]\n"])</script><script>self.__next_f.push([1,"b:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"title\",\"1\",{\"children\":\"promptfoo\"}],[\"$\",\"meta\",\"2\",{\"name\":\"description\",\"content\":\"LLM testing and evaluation\"}],[\"$\",\"meta\",\"3\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}],[\"$\",\"meta\",\"4\",{\"property\":\"og:image\",\"content\":\"https://www.promptfoo.dev/img/thumbnail.png\"}],[\"$\",\"meta\",\"5\",{\"name\":\"twitter:card\",\"content\":\"summary\"}],[\"$\",\"meta\",\"6\",{\"name\":\"twitter:image\",\"content\":\"https://www.promptfoo.dev/img/thumbnail.png\"}],[\"$\",\"meta\",\"7\",{\"name\":\"next-size-adjust\"}]]\n"])</script><script>self.__next_f.push([1,"10:null\n"])</script></body></html>
27
+ </style></div></div></div></div></div><script src="/_next/static/chunks/webpack-ff9953f1ad73867d.js" async=""></script><script src="/_next/static/chunks/fd9d1056-a95b789c94c05ff6.js" async=""></script><script src="/_next/static/chunks/596-f3a131b7c336dd5d.js" async=""></script><script src="/_next/static/chunks/main-app-581ccf0003955b21.js" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0])</script><script>self.__next_f.push([1,"1:HL[\"/_next/static/media/0e4fe491bf84089c-s.p.woff2\",{\"as\":\"font\",\"type\":\"font/woff2\"}]\n2:HL[\"/_next/static/media/3a04115668d8070d-s.p.woff2\",{\"as\":\"font\",\"type\":\"font/woff2\"}]\n3:HL[\"/_next/static/media/3a18fc8da1cdcd01-s.p.woff2\",{\"as\":\"font\",\"type\":\"font/woff2\"}]\n4:HL[\"/_next/static/media/627622453ef56b0d-s.p.woff2\",{\"as\":\"font\",\"type\":\"font/woff2\"}]\n5:HL[\"/_next/static/media/699512af39861afa-s.p.woff2\",{\"as\":\"font\",\"type\":\"font/woff2\"}]\n6:HL[\"/_next/static/media/934c4b7cb736f2a3-s.p.woff2\",{\"as\":\"font\","])</script><script>self.__next_f.push([1,"\"type\":\"font/woff2\"}]\n7:HL[\"/_next/static/css/51a17e8edcdfdbb2.css\",{\"as\":\"style\"}]\n0:\"$L8\"\n"])</script><script>self.__next_f.push([1,"9:HL[\"/_next/static/css/16c1dd82fc87c9d7.css\",{\"as\":\"style\"}]\n"])</script><script>self.__next_f.push([1,"a:I{\"id\":7948,\"chunks\":[\"272:static/chunks/webpack-ff9953f1ad73867d.js\",\"971:static/chunks/fd9d1056-a95b789c94c05ff6.js\",\"596:static/chunks/596-f3a131b7c336dd5d.js\"],\"name\":\"default\",\"async\":false}\nc:I{\"id\":6628,\"chunks\":[\"272:static/chunks/webpack-ff9953f1ad73867d.js\",\"971:static/chunks/fd9d1056-a95b789c94c05ff6.js\",\"596:static/chunks/596-f3a131b7c336dd5d.js\"],\"name\":\"\",\"async\":false}\nd:I{\"id\":2112,\"chunks\":[\"293:static/chunks/293-fa7b9b02f62ab5d8.js\",\"548:static/chunks/548-ffb8dd99ad3940cb.js\",\"82:static/"])</script><script>self.__next_f.push([1,"chunks/82-6e8c9ebc91ff932b.js\",\"886:static/chunks/886-ed0ff9e461fce55a.js\",\"445:static/chunks/445-74742af8ab1894f2.js\",\"185:static/chunks/app/layout-d634a41da738217d.js\"],\"name\":\"PageShell\",\"async\":false}\ne:I{\"id\":7767,\"chunks\":[\"272:static/chunks/webpack-ff9953f1ad73867d.js\",\"971:static/chunks/fd9d1056-a95b789c94c05ff6.js\",\"596:static/chunks/596-f3a131b7c336dd5d.js\"],\"name\":\"default\",\"async\":false}\nf:I{\"id\":7920,\"chunks\":[\"272:static/chunks/webpack-ff9953f1ad73867d.js\",\"971:static/chunks/fd9d1056-a95b789c9"])</script><script>self.__next_f.push([1,"4c05ff6.js\",\"596:static/chunks/596-f3a131b7c336dd5d.js\"],\"name\":\"default\",\"async\":false}\n11:I{\"id\":4839,\"chunks\":[\"272:static/chunks/webpack-ff9953f1ad73867d.js\",\"971:static/chunks/fd9d1056-a95b789c94c05ff6.js\",\"596:static/chunks/596-f3a131b7c336dd5d.js\"],\"name\":\"default\",\"async\":false}\n12:I{\"id\":2378,\"chunks\":[\"293:static/chunks/293-fa7b9b02f62ab5d8.js\",\"808:static/chunks/808-b64f39fb5aa81c36.js\",\"548:static/chunks/548-ffb8dd99ad3940cb.js\",\"420:static/chunks/420-c4133cd89d8c5e4b.js\",\"975:static/chunks/975-"])</script><script>self.__next_f.push([1,"41f6ad20b4031b30.js\",\"886:static/chunks/886-ed0ff9e461fce55a.js\",\"683:static/chunks/683-31836dfcc9c45e50.js\",\"339:static/chunks/339-501c32916b785ef1.js\",\"376:static/chunks/376-1c0d6e6983c73fe2.js\",\"413:static/chunks/app/setup/page-9c163111247d8da5.js\"],\"name\":\"\",\"async\":false}\n"])</script><script>self.__next_f.push([1,"8:[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/51a17e8edcdfdbb2.css\",\"precedence\":\"next\"}]],[\"$\",\"$La\",null,{\"buildId\":\"8yxA5JzS0wXTxJptFRKTo\",\"assetPrefix\":\"\",\"initialCanonicalUrl\":\"/setup/\",\"initialTree\":[\"\",{\"children\":[\"setup\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],\"initialHead\":\"$Lb\",\"globalErrorComponent\":\"$c\",\"children\":[null,[\"$\",\"html\",null,{\"lang\":\"en\",\"children\":[\"$\",\"body\",null,{\"className\":\"__className_c5054f\",\"children\":[\"$\",\"$Ld\",null,{\"children\":[\"$\",\"$Le\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"loading\":\"$undefined\",\"loadingStyles\":\"$undefined\",\"hasLoading\":false,\"template\":[\"$\",\"$Lf\",null,{}],\"templateStyles\":\"$undefined\",\"notFound\":[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],\"notFoundStyles\":\"$undefined\",\"childProp\":{\"current\":[\"$\",\"$Le\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"setup\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"loading\":\"$undefined\",\"loadingStyles\":\"$undefined\",\"hasLoading\":false,\"template\":[\"$\",\"$Lf\",null,{}],\"templateStyles\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\",\"childProp\":{\"current\":[\"$L10\",[\"$\",\"$L11\",null,{\"propsForComponent\":{\"params\":{}},\"Component\":\"$12\"}],null],\"segment\":\"__PAGE__\"},\"styles\":[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/16c1dd82fc87c9d7.css\",\"precedence\":\"next\"}]]}],\"segment\":\"setup\"},\"styles\":[]}]}]}]}],null]}]]\n"])</script><script>self.__next_f.push([1,"b:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"title\",\"1\",{\"children\":\"promptfoo\"}],[\"$\",\"meta\",\"2\",{\"name\":\"description\",\"content\":\"LLM testing and evaluation\"}],[\"$\",\"meta\",\"3\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}],[\"$\",\"meta\",\"4\",{\"property\":\"og:image\",\"content\":\"https://www.promptfoo.dev/img/thumbnail.png\"}],[\"$\",\"meta\",\"5\",{\"name\":\"twitter:card\",\"content\":\"summary\"}],[\"$\",\"meta\",\"6\",{\"name\":\"twitter:image\",\"content\":\"https://www.promptfoo.dev/img/thumbnail.png\"}],[\"$\",\"meta\",\"7\",{\"name\":\"next-size-adjust\"}]]\n"])</script><script>self.__next_f.push([1,"10:null\n"])</script></body></html>
@@ -5,13 +5,13 @@
5
5
  5:HL["/_next/static/media/699512af39861afa-s.p.woff2",{"as":"font","type":"font/woff2"}]
6
6
  6:HL["/_next/static/media/934c4b7cb736f2a3-s.p.woff2",{"as":"font","type":"font/woff2"}]
7
7
  7:HL["/_next/static/css/51a17e8edcdfdbb2.css",{"as":"style"}]
8
- 0:["Np8tRhZUzimy-v_hu8F8W",[[["",{"children":["setup",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],"$L8",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/51a17e8edcdfdbb2.css","precedence":"next"}]],"$L9"]]]]
8
+ 0:["8yxA5JzS0wXTxJptFRKTo",[[["",{"children":["setup",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],"$L8",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/51a17e8edcdfdbb2.css","precedence":"next"}]],"$L9"]]]]
9
9
  a:HL["/_next/static/css/16c1dd82fc87c9d7.css",{"as":"style"}]
10
- b:I{"id":2112,"chunks":["293:static/chunks/293-fa7b9b02f62ab5d8.js","548:static/chunks/548-ffb8dd99ad3940cb.js","82:static/chunks/82-ca0360e473d81167.js","886:static/chunks/886-ed0ff9e461fce55a.js","445:static/chunks/445-74742af8ab1894f2.js","185:static/chunks/app/layout-d634a41da738217d.js"],"name":"PageShell","async":false}
10
+ b:I{"id":2112,"chunks":["293:static/chunks/293-fa7b9b02f62ab5d8.js","548:static/chunks/548-ffb8dd99ad3940cb.js","82:static/chunks/82-6e8c9ebc91ff932b.js","886:static/chunks/886-ed0ff9e461fce55a.js","445:static/chunks/445-74742af8ab1894f2.js","185:static/chunks/app/layout-d634a41da738217d.js"],"name":"PageShell","async":false}
11
11
  c:I{"id":7767,"chunks":["272:static/chunks/webpack-ff9953f1ad73867d.js","971:static/chunks/fd9d1056-a95b789c94c05ff6.js","596:static/chunks/596-f3a131b7c336dd5d.js"],"name":"default","async":false}
12
12
  d:I{"id":7920,"chunks":["272:static/chunks/webpack-ff9953f1ad73867d.js","971:static/chunks/fd9d1056-a95b789c94c05ff6.js","596:static/chunks/596-f3a131b7c336dd5d.js"],"name":"default","async":false}
13
13
  f:I{"id":4839,"chunks":["272:static/chunks/webpack-ff9953f1ad73867d.js","971:static/chunks/fd9d1056-a95b789c94c05ff6.js","596:static/chunks/596-f3a131b7c336dd5d.js"],"name":"default","async":false}
14
- 10:I{"id":2378,"chunks":["293:static/chunks/293-fa7b9b02f62ab5d8.js","808:static/chunks/808-b64f39fb5aa81c36.js","548:static/chunks/548-ffb8dd99ad3940cb.js","420:static/chunks/420-c4133cd89d8c5e4b.js","975:static/chunks/975-41f6ad20b4031b30.js","886:static/chunks/886-ed0ff9e461fce55a.js","683:static/chunks/683-31836dfcc9c45e50.js","339:static/chunks/339-501c32916b785ef1.js","376:static/chunks/376-1c0d6e6983c73fe2.js","413:static/chunks/app/setup/page-83c7e62787113081.js"],"name":"","async":false}
14
+ 10:I{"id":2378,"chunks":["293:static/chunks/293-fa7b9b02f62ab5d8.js","808:static/chunks/808-b64f39fb5aa81c36.js","548:static/chunks/548-ffb8dd99ad3940cb.js","420:static/chunks/420-c4133cd89d8c5e4b.js","975:static/chunks/975-41f6ad20b4031b30.js","886:static/chunks/886-ed0ff9e461fce55a.js","683:static/chunks/683-31836dfcc9c45e50.js","339:static/chunks/339-501c32916b785ef1.js","376:static/chunks/376-1c0d6e6983c73fe2.js","413:static/chunks/app/setup/page-9c163111247d8da5.js"],"name":"","async":false}
15
15
  8:[null,["$","html",null,{"lang":"en","children":["$","body",null,{"className":"__className_c5054f","children":["$","$Lb",null,{"children":["$","$Lc",null,{"parallelRouterKey":"children","segmentPath":["children"],"error":"$undefined","errorStyles":"$undefined","loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"template":["$","$Ld",null,{}],"templateStyles":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":"$undefined","childProp":{"current":["$","$Lc",null,{"parallelRouterKey":"children","segmentPath":["children","setup","children"],"error":"$undefined","errorStyles":"$undefined","loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"template":["$","$Ld",null,{}],"templateStyles":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","childProp":{"current":["$Le",["$","$Lf",null,{"propsForComponent":{"params":{}},"Component":"$10"}],null],"segment":"__PAGE__"},"styles":[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/16c1dd82fc87c9d7.css","precedence":"next"}]]}],"segment":"setup"},"styles":[]}]}]}]}],null]
16
16
  9:[["$","meta","0",{"charSet":"utf-8"}],["$","title","1",{"children":"promptfoo"}],["$","meta","2",{"name":"description","content":"LLM testing and evaluation"}],["$","meta","3",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","4",{"property":"og:image","content":"https://www.promptfoo.dev/img/thumbnail.png"}],["$","meta","5",{"name":"twitter:card","content":"summary"}],["$","meta","6",{"name":"twitter:image","content":"https://www.promptfoo.dev/img/thumbnail.png"}],["$","meta","7",{"name":"next-size-adjust"}]]
17
17
  e:null
@@ -1,2 +1,2 @@
1
- export declare function startServer(port?: number, apiBaseUrl?: string, skipConfirmation?: boolean): void;
1
+ export declare function startServer(port?: number, apiBaseUrl?: string, skipConfirmation?: boolean): Promise<void>;
2
2
  //# sourceMappingURL=server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/web/server.ts"],"names":[],"mappings":"AA2CA,wBAAgB,WAAW,CAAC,IAAI,SAAQ,EAAE,UAAU,SAAK,EAAE,gBAAgB,UAAQ,QAgNlF"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/web/server.ts"],"names":[],"mappings":"AA2CA,wBAAsB,WAAW,CAAC,IAAI,SAAQ,EAAE,UAAU,SAAK,EAAE,gBAAgB,UAAQ,iBA0LxF"}
@@ -21,11 +21,12 @@ const logger_1 = __importDefault(require("../logger"));
21
21
  const esm_1 = require("../esm");
22
22
  const util_1 = require("../util");
23
23
  const testCases_1 = require("../testCases");
24
+ const database_1 = require("../database");
24
25
  // Running jobs
25
26
  const evalJobs = new Map();
26
27
  // Prompts cache
27
28
  let allPrompts = null;
28
- function startServer(port = 15500, apiBaseUrl = '', skipConfirmation = false) {
29
+ async function startServer(port = 15500, apiBaseUrl = '', skipConfirmation = false) {
29
30
  const app = (0, express_1.default)();
30
31
  const staticDir = node_path_1.default.join((0, esm_1.getDirectory)(), 'web', 'nextui');
31
32
  app.use((0, cors_1.default)());
@@ -38,36 +39,25 @@ function startServer(port = 15500, apiBaseUrl = '', skipConfirmation = false) {
38
39
  origin: '*',
39
40
  },
40
41
  });
41
- const latestJsonPath = (0, util_1.getLatestResultsPath)();
42
- const readLatestJson = () => {
43
- const data = fs_1.default.readFileSync(latestJsonPath, 'utf8');
44
- return JSON.parse(data);
45
- };
46
- io.on('connection', (socket) => {
47
- // Send the initial table data when a client connects
48
- socket.emit('init', readLatestJson());
49
- // Watch for changes to latest.json and emit the update event
50
- const watcher = (0, debounce_1.default)((curr, prev) => {
51
- if (curr.mtime !== prev.mtime) {
52
- socket.emit('update', readLatestJson());
53
- allPrompts = null;
54
- }
55
- }, 250);
56
- fs_1.default.watchFile(latestJsonPath, watcher);
57
- // Stop watching the file when the socket connection is closed
58
- socket.on('disconnect', () => {
59
- fs_1.default.unwatchFile(latestJsonPath, watcher);
60
- });
42
+ await (0, util_1.migrateResultsFromFileSystemToDatabase)();
43
+ const watchFilePath = (0, database_1.getDbSignalPath)();
44
+ const watcher = (0, debounce_1.default)(async (curr, prev) => {
45
+ if (curr.mtime !== prev.mtime) {
46
+ io.emit('update', await (0, util_1.readLatestResults)());
47
+ allPrompts = null;
48
+ }
49
+ }, 250);
50
+ fs_1.default.watchFile(watchFilePath, watcher);
51
+ io.on('connection', async (socket) => {
52
+ socket.emit('init', await (0, util_1.readLatestResults)());
61
53
  });
62
54
  app.get('/api/results', (req, res) => {
63
55
  const previousResults = (0, util_1.listPreviousResults)();
64
- previousResults.reverse();
65
56
  res.json({
66
- data: previousResults.map((fileMeta) => {
67
- const dateString = (0, util_1.filenameToDate)(fileMeta.fileName);
57
+ data: previousResults.map((meta) => {
68
58
  return {
69
- id: fileMeta.fileName,
70
- label: fileMeta.description ? `${fileMeta.description} (${dateString})` : dateString,
59
+ id: meta.evalId,
60
+ label: meta.description ? `${meta.description} (${meta.evalId})` : meta.evalId,
71
61
  };
72
62
  }),
73
63
  });
@@ -128,35 +118,28 @@ function startServer(port = 15500, apiBaseUrl = '', skipConfirmation = false) {
128
118
  res.status(500).json({ error: 'Failed to update eval table' });
129
119
  }
130
120
  });
131
- app.get('/api/results/:filename', (req, res) => {
132
- const filename = req.params.filename;
133
- const safeFilename = node_path_1.default.basename(filename);
134
- if (safeFilename !== filename ||
135
- !(0, util_1.listPreviousResultFilenames)()
136
- .includes(safeFilename)) {
137
- res.status(400).send('Invalid filename');
138
- return;
139
- }
140
- const file = (0, util_1.readResult)(safeFilename);
121
+ app.get('/api/results/:id', async (req, res) => {
122
+ const { id } = req.params;
123
+ const file = await (0, util_1.readResult)(id);
141
124
  if (!file) {
142
125
  res.status(404).send('Result not found');
143
126
  return;
144
127
  }
145
128
  res.json({ data: file.result });
146
129
  });
147
- app.get('/api/prompts', (req, res) => {
130
+ app.get('/api/prompts', async (req, res) => {
148
131
  if (allPrompts == null) {
149
- allPrompts = (0, util_1.getPrompts)();
132
+ allPrompts = await (0, util_1.getPrompts)();
150
133
  }
151
134
  res.json({ data: allPrompts });
152
135
  });
153
- app.get('/api/prompts/:sha256hash', (req, res) => {
136
+ app.get('/api/prompts/:sha256hash', async (req, res) => {
154
137
  const sha256hash = req.params.sha256hash;
155
- const prompts = (0, util_1.getPromptsForTestCasesHash)(sha256hash);
138
+ const prompts = await (0, util_1.getPromptsForTestCasesHash)(sha256hash);
156
139
  res.json({ data: prompts });
157
140
  });
158
- app.get('/api/datasets', (req, res) => {
159
- res.json({ data: (0, util_1.getTestCases)() });
141
+ app.get('/api/datasets', async (req, res) => {
142
+ res.json({ data: await (0, util_1.getTestCases)() });
160
143
  });
161
144
  app.get('/api/config', (req, res) => {
162
145
  res.json({
@@ -202,7 +185,6 @@ function startServer(port = 15500, apiBaseUrl = '', skipConfirmation = false) {
202
185
  openUrl();
203
186
  }
204
187
  rl.close();
205
- logger_1.default.info('Press Ctrl+C to stop the server');
206
188
  });
207
189
  }
208
190
  });
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/web/server.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA+B;AAC/B,0DAA6B;AAC7B,kEAAqC;AACrC,0DAA6B;AAC7B,oEAAuC;AACvC,+BAAoC;AAEpC,wDAAgC;AAChC,sDAA8B;AAC9B,gDAAwB;AACxB,8DAAsC;AACtC,oDAA4B;AAC5B,yCAAqD;AACrD,qDAOkB;AAElB,uDAA+B;AAC/B,gCAAsC;AACtC,kCAUiB;AACjB,4CAAuD;AAEvD,eAAe;AACf,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAe,CAAC;AAExC,gBAAgB;AAChB,IAAI,UAAU,GAAgC,IAAI,CAAC;AAEnD,SAAgB,WAAW,CAAC,IAAI,GAAG,KAAK,EAAE,UAAU,GAAG,EAAE,EAAE,gBAAgB,GAAG,KAAK;IACjF,MAAM,GAAG,GAAG,IAAA,iBAAO,GAAE,CAAC;IAEtB,MAAM,SAAS,GAAG,mBAAI,CAAC,IAAI,CAAC,IAAA,kBAAY,GAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;IAE7D,GAAG,CAAC,GAAG,CAAC,IAAA,cAAI,GAAE,CAAC,CAAC;IAChB,GAAG,CAAC,GAAG,CAAC,IAAA,qBAAW,GAAE,CAAC,CAAC;IACvB,GAAG,CAAC,GAAG,CAAC,iBAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IAC1C,GAAG,CAAC,GAAG,CAAC,iBAAO,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAEhE,MAAM,UAAU,GAAG,mBA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I,CAAC,iCAAiC,CAAC,CAAC;gBAC/C,MAAM,IAAA,gBAAM,EAAC,GAAG,CAAC,CAAC;aACnB;YAAC,OAAO,GAAG,EAAE;gBACZ,gBAAM,CAAC,KAAK,CAAC,2BAA2B,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;aACxD;QACH,CAAC,CAAC;QAEF,IAAI,gBAAgB,EAAE;YACpB,OAAO,EAAE,CAAC;SACX;aAAM;YACL,MAAM,EAAE,GAAG,uBAAQ,CAAC,eAAe,CAAC;gBAClC,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,MAAM,EAAE,OAAO,CAAC,MAAM;aACvB,CAAC,CAAC;YACH,EAAE,CAAC,QAAQ,CAAC,8BAA8B,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;gBAC3D,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;oBACxC,OAAO,EAAE,CAAC;iBACX;gBACD,EAAE,CAAC,KAAK,EAAE,CAAC;YACb,CAAC,CAAC,CAAC;SACJ;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AA1LD,kCA0LC"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "promptfoo",
3
3
  "description": "LLM eval & testing toolkit",
4
4
  "author": "Ian Webster",
5
- "version": "0.46.0",
5
+ "version": "0.48.0",
6
6
  "license": "MIT",
7
7
  "type": "commonjs",
8
8
  "repository": "promptfoo/promptfoo",
@@ -32,11 +32,14 @@
32
32
  "build:clean": "rm -rf dist",
33
33
  "build:nextui": "cd src/web/nextui && npm run build && { [ -z \"$NEXT_PUBLIC_PROMPTFOO_BUILD_STANDALONE_SERVER\" ] && cp -r out/ ../../../dist/src/web/nextui; } || true",
34
34
  "build:watch": "tsc --watch",
35
- "build": "tsc && cp src/*.html dist/src && cp src/python/wrapper.py dist/src/python && npm run build:nextui && chmod +x dist/src/main.js",
35
+ "build": "tsc && cp src/*.html dist/src && cp src/python/wrapper.py dist/src/python && cp -r drizzle/ dist/ && npm run build:nextui && chmod +x dist/src/main.js",
36
36
  "prepare": "npm run install:nextui && npm run build:clean && npm run build",
37
37
  "test": "jest",
38
38
  "test:watch": "jest --watch",
39
- "format": "prettier -w ."
39
+ "format": "prettier -w .",
40
+ "db:migrate": "npx tsx src/migrate.ts",
41
+ "db:generate": "npx drizzle-kit generate:sqlite",
42
+ "audit:fix": "npm audit fix && cd src/web/nextui && npm audit fix && cd ../../site && npm audit fix"
40
43
  },
41
44
  "peerDependencies": {
42
45
  "@aws-sdk/client-bedrock-runtime": "^3.458.0",
@@ -46,6 +49,7 @@
46
49
  "@aws-sdk/client-bedrock-runtime": "^3.458.0",
47
50
  "@azure/identity": "^4.0.0",
48
51
  "@types/async": "^3.2.20",
52
+ "@types/better-sqlite3": "^7.6.8",
49
53
  "@types/cache-manager": "^4.0.2",
50
54
  "@types/cache-manager-fs-hash": "^0.0.1",
51
55
  "@types/cli-progress": "^3.11.0",
@@ -62,6 +66,7 @@
62
66
  "@types/semver": "^7.5.0",
63
67
  "@types/uuid": "^9.0.2",
64
68
  "babel-jest": "^29.5.0",
69
+ "drizzle-kit": "^0.20.13",
65
70
  "jest": "^29.5.0",
66
71
  "jest-watch-typeahead": "^2.2.2",
67
72
  "next": "^13.4.13",
@@ -76,6 +81,7 @@
76
81
  "ajv": "^8.12.0",
77
82
  "ajv-formats": "^2.1.1",
78
83
  "async": "^3.2.4",
84
+ "better-sqlite3": "^9.3.0",
79
85
  "cache-manager": "^4.1.0",
80
86
  "cache-manager-fs-hash": "^1.0.0",
81
87
  "chalk": "^4.1.2",
@@ -88,6 +94,7 @@
88
94
  "csv-parse": "^5.3.8",
89
95
  "csv-stringify": "^6.3.2",
90
96
  "debounce": "^1.2.1",
97
+ "drizzle-orm": "^0.29.3",
91
98
  "express": "^4.18.2",
92
99
  "fastest-levenshtein": "^1.0.16",
93
100
  "glob": "^10.2.6",
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[952],{2810:function(e,t,s){"use strict";let n;async function l(){if(!n){let e=await fetch("/api/config"),t=await e.json();n=t.apiBaseUrl}return n}s.d(t,{b:function(){return l}})},9952:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return eA}});var n=s(7437),l=s(2265),r=s(2130),i=s(6882),a=s(3388),o=s(4033),c=s(3082),d=s(8440),u=s(6507),p=s(5551),h=s(7760),m=s(3391),x=s(4081),j=s(3226),g=s(819),f=s(8212),v=s(5507),b=s(923),y=s(654),Z=s(3295),C=s(2467),k=s(3457),w=s(1975),S=s(8276),N=s(9605),R=s(9190),E=s(2053),P=s(6704),O=s(9394),F=s(1797),T=s(6337),I=s(1101),L=s(9872),M=s(2653),D=s(3533),A=s(4740),U=s(4660);let _=(0,U.Ue)(e=>({filePath:null,setFilePath:t=>e(()=>({filePath:t})),table:null,setTable:t=>e(()=>({table:t})),config:null,setConfig:t=>e(()=>({config:t})),maxTextLength:250,setMaxTextLength:t=>e(()=>({maxTextLength:t})),wordBreak:"break-word",setWordBreak:t=>e(()=>({wordBreak:t})),showInferenceDetails:!0,setShowInferenceDetails:t=>e(()=>({showInferenceDetails:t})),renderMarkdown:!1,setRenderMarkdown:t=>e(()=>({renderMarkdown:t})),prettifyJson:!1,setPrettifyJson:t=>e(()=>({prettifyJson:t}))})),W=["#fd7f6f","#7eb0d5","#b2e061","#bd7ebe","#ffb55a","#ffee65","#beb9db","#fdcce5","#8bd3c7"];function V(e){let{table:t}=e,s=(0,l.useRef)(null),r=(0,l.useRef)(null);return(0,l.useEffect)(()=>{if(!s.current)return;r.current&&r.current.destroy();let e=t.body.flatMap(e=>e.outputs.map(e=>e.score)),n=Math.min(...e),l=(Math.ceil(Math.max(...e))-Math.floor(n))/10,i=Array.from({length:11},(e,t)=>parseFloat((Math.floor(n)+t*l).toFixed(2))),a=t.head.prompts.map((e,s)=>{let n=t.body.flatMap(e=>e.outputs[s].score),r=i.map(e=>n.filter(t=>t>=e&&t<e+l).length);return{label:"Prompt ".concat(s+1),data:r,backgroundColor:W[s%W.length]}});r.current=new P.kL(s.current,{type:"bar",data:{labels:i,datasets:a},options:{animation:!1,plugins:{title:{display:!0,text:"Score Distribution"},legend:{display:!1},tooltip:{callbacks:{title:function(e){let t=e[0].datasetIndex;return"Prompt ".concat(t+1)},label:function(e){let t=e.dataIndex,s=i[t],n=i[t+1];return n?"".concat(s," <= score < ").concat(n):"".concat(s," <= score")}}}}}})},[t]),(0,n.jsx)("canvas",{ref:s,style:{maxHeight:"300px"}})}function z(e){let{table:t}=e,s=(0,l.useRef)(null),r=(0,l.useRef)(null);return(0,l.useEffect)(()=>{if(!s.current)return;r.current&&r.current.destroy();let e=t.head.prompts.map((e,s)=>{let n=t.body.flatMap(e=>e.outputs[s]),l=n.filter(e=>e.pass).length,r=l/n.length*100;return{label:"Prompt ".concat(s+1),data:[r],backgroundColor:W[s%W.length]}});r.current=new P.kL(s.current,{type:"bar",data:{labels:["Pass Rate (%)"],datasets:e},options:{animation:!1,plugins:{title:{display:!0,text:"Pass rate"},legend:{display:!0}}}})},[t]),(0,n.jsx)("canvas",{ref:s,style:{maxHeight:"300px"}})}function B(e){let{table:t}=e,s=(0,l.useRef)(null),r=(0,l.useRef)(null),[i,a]=(0,l.useState)(0),[o,c]=(0,l.useState)(1),[d,u]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{if(!s.current)return;r.current&&r.current.destroy();let e=t.body.flatMap(e=>e.outputs.map(e=>e.score)),n=Math.min(...e),l=Math.max(...e),a=t.body.map(e=>{let t=e.outputs[i].score,s=e.outputs[o].score;return{x:t,y:s,backgroundColor:s>t?"green":s<t?"red":"gray"}});r.current=new P.kL(s.current,{type:"scatter",data:{datasets:[{data:a,backgroundColor:a.map(e=>e.backgroundColor)},{type:"line",data:[{x:n,y:n},{x:l,y:l}],borderColor:"gray",borderWidth:1,borderDash:[5,5],pointRadius:0}]},options:{animation:!1,plugins:{legend:{display:!1},tooltip:{callbacks:{label:function(e){let s=t.body[e.dataIndex],n=s.outputs[0].text,l=s.outputs[1].text;return n.length>30&&(n=n.substring(0,30)+"..."),l.length>30&&(l=l.substring(0,30)+"..."),"Output 1: ".concat(n,"\nOutput 2: ").concat(l)}}}},scales:{x:{title:{display:!0,text:"Prompt ".concat(i+1," Score")}},y:{title:{display:!0,text:"Prompt ".concat(o+1," Score")}}}}})},[t,i,o]),(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(O.Z,{open:d,onClose:()=>u(!1),children:[(0,n.jsx)(F.Z,{children:"Compare prompt outputs"}),(0,n.jsxs)(T.Z,{children:[(0,n.jsx)(x.Z,{sx:{m:1,minWidth:120},children:(0,n.jsx)(y.Z,{value:i,onChange:e=>a(Number(e.target.value)),children:t.head.prompts.map((e,t)=>(0,n.jsxs)(v.Z,{value:t,children:["Prompt ",t+1]},t))})}),(0,n.jsx)(x.Z,{sx:{m:1,minWidth:120},children:(0,n.jsx)(y.Z,{value:o,onChange:e=>c(Number(e.target.value)),children:t.head.prompts.map((e,t)=>(0,n.jsxs)(v.Z,{value:t,children:["Prompt ",t+1]},t))})})]})]}),(0,n.jsx)("canvas",{ref:s,style:{maxHeight:"300px",cursor:"pointer"},onClick:()=>u(!0)})]})}function J(e){let{columnVisibility:t}=e,s=(0,I.Z)();P.kL.defaults.color="dark"===s.palette.mode?"#aaa":"#666";let[r,i]=(0,l.useState)(!0),{table:a}=_();if(!a||!r||a.head.prompts.length<2)return null;let o=a.body.flatMap(e=>e.outputs.map(e=>e.score));return 1===new Set(o).size?null:(0,n.jsx)(A.SV,{fallback:null,children:(0,n.jsxs)(L.Z,{style:{position:"relative",padding:s.spacing(3)},children:[(0,n.jsx)(M.Z,{style:{position:"absolute",right:0,top:0},onClick:()=>i(!1),children:(0,n.jsx)(D.Z,{})}),(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[(0,n.jsx)("div",{style:{width:"33%"},children:(0,n.jsx)(z,{table:a})}),(0,n.jsx)("div",{style:{width:"33%"},children:(0,n.jsx)(V,{table:a})}),(0,n.jsx)("div",{style:{width:"33%"},children:(0,n.jsx)(B,{table:a})})]})]})})}P.kL.register(P.vn,P.ST,P.ho,P.uw,P.f$,P.ZL,P.jn,P.od,P.u,P.wL);var H=s(9116);s(5777);var G=s(3425),X=s(7660),q=s(3216),Y=s(182),$=s(5391),K=s(1396),Q=s.n(K);s(8715);var ee=e=>{let{lookup:t}=e;return t&&Object.keys(t).length?(0,n.jsx)("div",{className:"custom-metric-container",children:Object.entries(t).map(e=>{let[t,s]=e;return t&&s?(0,n.jsxs)("span",{children:[t,": ",s.toFixed(2)]},t):null})}):null},et=s(2834),es=s(5446),en=s(9329),el=s(4719),er=s(3701),ei=s(9279),ea=s(666),eo=s(5795),ec=s(6988),ed=s(4147);function eu(e){let{gradingResults:t}=e;return t?(0,n.jsxs)(u.Z,{mt:2,children:[(0,n.jsx)(j.Z,{variant:"subtitle1",children:"Assertions"}),(0,n.jsx)(eo.Z,{children:(0,n.jsxs)(er.Z,{children:[(0,n.jsx)(ec.Z,{children:(0,n.jsxs)(ed.Z,{children:[(0,n.jsx)(ea.Z,{style:{fontWeight:"bold"},children:"Pass"}),(0,n.jsx)(ea.Z,{style:{fontWeight:"bold"},children:"Score"}),(0,n.jsx)(ea.Z,{style:{fontWeight:"bold"},children:"Type"}),(0,n.jsx)(ea.Z,{style:{fontWeight:"bold"},children:"Value"}),(0,n.jsx)(ea.Z,{style:{fontWeight:"bold"},children:"Reason"})]})}),(0,n.jsx)(ei.Z,{children:t.map((e,t)=>{var s,l;return(0,n.jsxs)(ed.Z,{children:[(0,n.jsx)(ea.Z,{children:e.pass?"✅":"❌"}),(0,n.jsx)(ea.Z,{children:e.score.toFixed(2)}),(0,n.jsx)(ea.Z,{children:(null===(s=e.assertion)||void 0===s?void 0:s.type)||""}),(0,n.jsx)(ea.Z,{style:{whiteSpace:"pre-wrap"},children:(null===(l=e.assertion)||void 0===l?void 0:l.value)?String(e.assertion.value):"-"}),(0,n.jsx)(ea.Z,{style:{whiteSpace:"pre-wrap"},children:e.reason})]},t)})})]})})]}):null}function ep(e){let{open:t,onClose:s,prompt:r,provider:i,output:a,gradingResults:o}=e,[c,d]=(0,l.useState)(!1);(0,l.useEffect)(()=>{d(!1)},[r]);let h=async e=>{await navigator.clipboard.writeText(e),d(!0)};return(0,n.jsxs)(O.Z,{open:t,onClose:s,fullWidth:!0,maxWidth:"lg",children:[(0,n.jsxs)(F.Z,{children:["Details",i&&": ".concat(i)]}),(0,n.jsxs)(T.Z,{children:[(0,n.jsxs)(u.Z,{mb:2,children:[(0,n.jsx)(j.Z,{variant:"subtitle1",style:{marginBottom:"1rem"},children:"Prompt"}),(0,n.jsx)(es.u,{readOnly:!0,value:r,style:{width:"100%",padding:"0.75rem"},maxRows:20}),(0,n.jsx)(M.Z,{onClick:()=>h(r),style:{position:"absolute",right:"10px",top:"10px"},children:c?(0,n.jsx)(el.Z,{}):(0,n.jsx)(en.Z,{})})]}),a&&(0,n.jsxs)(u.Z,{my:2,children:[(0,n.jsx)(j.Z,{variant:"subtitle1",style:{marginBottom:"1rem",marginTop:"1rem"},children:"Output"}),(0,n.jsx)(es.u,{readOnly:!0,maxRows:20,value:a,style:{width:"100%",padding:"0.75rem"}})]}),(0,n.jsx)(eu,{gradingResults:o})]}),(0,n.jsx)(et.Z,{children:(0,n.jsx)(p.Z,{onClick:s,children:"Close"})})]})}var eh=s(9396),em=s(4173),ex=function(){let e=(0,I.Z)(),[t,s]=l.useState(!1),r=()=>{s(!1)};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{style:{textAlign:"center",marginTop:20,marginBottom:40},children:(0,n.jsx)(p.Z,{variant:"text",color:"primary",startIcon:(0,n.jsx)(eh.Z,{}),onClick:()=>{s(!0)},children:"Generate test cases"})}),(0,n.jsxs)(O.Z,{open:t,onClose:r,children:[(0,n.jsx)(F.Z,{children:"Run on Command Line"}),(0,n.jsx)(T.Z,{children:(0,n.jsxs)(em.Z,{children:[(0,n.jsx)("p",{children:"This feature is in beta. UI coming soon."}),(0,n.jsxs)("p",{children:["Run"," ",(0,n.jsx)(u.Z,{component:"code",sx:{backgroundColor:"dark"===e.palette.mode?"#424242":"#f0f0f0",padding:"2px 4px",borderRadius:"4px"},children:"promptfoo generate dataset"}),"to generate test cases on the command line."]})]})}),(0,n.jsx)(et.Z,{children:(0,n.jsx)(p.Z,{onClick:r,color:"primary",children:"Close"})})]})]})},ej=s(2810);function eg(e){return null===e||0===e||1===e?"":"(".concat(e.toFixed(2),")")}function ef(e){return"string"==typeof e||"number"==typeof e?e.toString().length:Array.isArray(e)?e.reduce((e,t)=>e+ef(t),0):l.isValidElement(e)&&e.props.children?l.Children.toArray(e.props.children).reduce((e,t)=>e+ef(t),0):0}function ev(e){let t,{text:s,maxLength:r}=e,[i,a]=l.useState(!0),o=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if("string"==typeof e||"number"==typeof e){let s=e.toString();return s.slice(0,r-t)}if(Array.isArray(e)){let s=[],n=t;for(let t of e){let e=ef(t);if(n+e>r){s.push(o(t,n));break}s.push(t),n+=e}return s}if(l.isValidElement(e)&&e.props.children){let s=ef(e.props.children);if(s>r-t)return l.cloneElement(e,{...e.props,children:o(e.props.children,t)})}return e};t=l.isValidElement(s)||"string"==typeof s?s:JSON.stringify(s);let c=i?o(t):t,d=ef(t)>r;return(0,n.jsxs)("div",{style:{cursor:d?"pointer":"normal"},onClick:()=>{a(!i)},children:[c,i&&ef(t)>r&&(0,n.jsx)("span",{children:"..."})]})}function eb(e){var t,s,r,i,a,o;let c,d,u,p,h,{output:m,maxTextLength:x,rowIndex:j,promptIndex:g,onRating:f,firstOutput:v,filterMode:b,searchText:y,showStats:Z}=e,{renderMarkdown:C,prettifyJson:k}=_(),[w,N]=l.useState(!1),[R,E]=l.useState(!1),P=()=>E(!R),O="string"==typeof m.text?m.text:JSON.stringify(m.text),F=[];if(O.startsWith("[IMAGE]")){let e=O.slice(7).trim();c=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("img",{loading:"lazy",src:e,alt:m.prompt,onClick:P}),R&&(0,n.jsx)("div",{className:"lightbox",onClick:P,children:(0,n.jsx)("img",{src:e,alt:m.prompt})})]})}else!m.pass&&O.includes("---")?O=(F=O.split("---")).slice(1).join("---"):F=[O];if("different"===b&&v){let e,t="string"==typeof v.text?v.text:JSON.stringify(v.text);t.includes("---")&&(t=t.split("---").slice(1).join("---"));try{JSON.parse(t),JSON.parse(O),e=(0,H.CT)(t,O)}catch(s){e=t.includes(". ")&&O.includes(". ")?(0,H.SY)(t,O):(0,H.NV)(t,O)}c=(0,n.jsx)(n.Fragment,{children:e.map((e,t)=>e.added?(0,n.jsx)("ins",{children:e.value},t):e.removed?(0,n.jsx)("del",{children:e.value},t):(0,n.jsx)("span",{children:e.value},t))})}if(y){let e;let t=RegExp(y,"gi"),s=[];for(;null!==(e=t.exec(O));)s.push({start:e.index,end:t.lastIndex}),t.lastIndex;c=(0,n.jsx)(n.Fragment,{children:s.length>0?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{children:O.substring(0,s[0].start)},"text-before"),s.map((e,t)=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"search-highlight",children:O.substring(e.start,e.end)},"match-"+t),(0,n.jsx)("span",{children:O.substring(e.end,s[t+1]?s[t+1].start:O.length)},"text-after-"+t)]}))]}):(0,n.jsx)("span",{children:O},"no-match")})}else if(C)c=(0,n.jsx)(G.U,{children:O});else if(k)try{c=(0,n.jsx)("pre",{children:JSON.stringify(JSON.parse(O),null,2)})}catch(e){}let T=e=>{var t;f(j,g,e,void 0,null===(t=m.gradingResult)||void 0===t?void 0:t.comment)},I=()=>{var e;let t=prompt("Comment:",(null===(e=m.gradingResult)||void 0===e?void 0:e.comment)||"");null!=t&&f(j,g,void 0,void 0,t)};if(null===(t=m.tokenUsage)||void 0===t?void 0:t.completion){u=(0,n.jsxs)("span",{children:[Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(m.latencyMs)," ms"]});let e=m.tokenUsage.completion/(m.latencyMs/1e3);p=(0,n.jsx)("span",{children:Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(e)})}m.cost&&(h=(0,n.jsxs)("span",{children:["$",m.cost.toPrecision(2)]})),(null===(s=m.tokenUsage)||void 0===s?void 0:s.cached)?d=(0,n.jsxs)("span",{children:[Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(m.tokenUsage.cached)," ","(cached)"]}):(null===(r=m.tokenUsage)||void 0===r?void 0:r.total)&&(d=(0,n.jsx)("span",{children:Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(m.tokenUsage.total)}));let L=(null===(i=m.gradingResult)||void 0===i?void 0:i.comment)?(0,n.jsx)("div",{className:"comment",onClick:I,children:m.gradingResult.comment}):null,M=Z?(0,n.jsxs)("div",{className:"cell-detail",children:[d&&(0,n.jsxs)("div",{className:"stat-item",children:[(0,n.jsx)("strong",{children:"Tokens:"})," ",d]}),u&&(0,n.jsxs)("div",{className:"stat-item",children:[(0,n.jsx)("strong",{children:"Latency:"})," ",u]}),p&&(0,n.jsxs)("div",{className:"stat-item",children:[(0,n.jsx)("strong",{children:"Tokens/Sec:"})," ",p]}),h&&(0,n.jsxs)("div",{className:"stat-item",children:[(0,n.jsx)("strong",{children:"Cost:"})," ",h]})]}):null,D=(0,n.jsxs)("div",{className:"cell-actions",children:[m.prompt&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"action",onClick:()=>{N(!0)},children:(0,n.jsx)(S.Z,{title:"View ouput and test details",children:(0,n.jsx)("span",{children:"\uD83D\uDD0E"})})}),(0,n.jsx)(ep,{open:w,onClose:()=>{N(!1)},prompt:m.prompt,provider:m.provider,gradingResults:null===(a=m.gradingResult)||void 0===a?void 0:a.componentResults,output:O})]}),(0,n.jsx)("span",{className:"action",onClick:()=>T(!0),children:(0,n.jsx)(S.Z,{title:"Mark test passed (score 1.0)",children:(0,n.jsx)("span",{children:"\uD83D\uDC4D"})})}),(0,n.jsx)("span",{className:"action",onClick:()=>T(!1),children:(0,n.jsx)(S.Z,{title:"Mark test failed (score 0.0)",children:(0,n.jsx)("span",{children:"\uD83D\uDC4E"})})}),(0,n.jsx)("span",{className:"action",onClick:()=>{let e=prompt("Set test score (0.0 - 1.0):",String(m.score));if(null!==e){let s=parseFloat(e);if(!isNaN(s)&&s>=0&&s<=1){var t;f(j,g,void 0,s,null===(t=m.gradingResult)||void 0===t?void 0:t.comment)}else alert("Invalid score. Please enter a value between 0.0 and 1.0.")}},children:(0,n.jsx)(S.Z,{title:"Set test score",children:(0,n.jsx)("span",{children:"\uD83D\uDD22"})})}),(0,n.jsx)("span",{className:"action",onClick:I,children:(0,n.jsx)(S.Z,{title:"Edit comment",children:(0,n.jsx)("span",{children:"✏️"})})})]});return(0,n.jsxs)("div",{className:"cell",children:[m.pass?(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)("div",{className:"status pass",children:[(0,n.jsxs)("div",{className:"pill",children:["PASS",(0,n.jsx)("span",{className:"score",children:eg(m.score)})]}),(0,n.jsx)(ee,{lookup:m.namedScores})]})}):(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)("div",{className:"status fail",children:[(0,n.jsxs)("div",{className:"pill",children:["FAIL",m.score>0?" ":"",(0,n.jsx)("span",{className:"score",children:eg(m.score)})]}),(0,n.jsx)(ee,{lookup:m.namedScores}),(0,n.jsx)("span",{className:"fail-reason",children:null===(o=F[0])||void 0===o?void 0:o.trim().split("\n").map((e,t)=>(0,n.jsxs)(l.Fragment,{children:[e,(0,n.jsx)("br",{})]},t))})]})}),(0,n.jsx)(ev,{text:c||O,maxLength:x}),L,M,D]})}function ey(e){let{text:t,maxLength:s,expandedText:r,resourceId:i,className:a}=e,[o,c]=l.useState(!1);return(0,n.jsxs)("div",{className:"".concat(a||""),children:[(0,n.jsx)(ev,{text:t,maxLength:s}),r&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(S.Z,{title:"View prompt",children:(0,n.jsx)("span",{className:"action",onClick:()=>{c(!0)},children:"\uD83D\uDD0E"})}),(0,n.jsx)(ep,{open:o,onClose:()=>{c(!1)},prompt:r}),i&&(0,n.jsx)(S.Z,{title:"View other evals and datasets for this prompt",children:(0,n.jsx)("span",{className:"action",children:(0,n.jsx)(Q(),{href:"/prompts/?id=".concat(i),target:"_blank",children:(0,n.jsx)($.Z,{fontSize:"small"})})})})]})]})}function eZ(e){let{maxTextLength:t,columnVisibility:s,wordBreak:i,filterMode:a,failureFilter:o,searchText:c,showStats:d,onFailureFilterToggle:u}=e,{filePath:p,table:m,setTable:x}=_();(0,r.Z)(m,"Table should be defined");let{head:j,body:g}=m,f=j.prompts.map((e,t)=>g.reduce((e,s)=>e+(s.outputs[t].pass?1:0),0)),v=j.prompts.map((e,t)=>g.reduce((e,s)=>{var n,l;return e+((null===(l=s.outputs[t].gradingResult)||void 0===l?void 0:null===(n=l.componentResults)||void 0===n?void 0:n.length)||0)},0)),b=j.prompts.map((e,t)=>g.reduce((e,s)=>{var n;let l=null===(n=s.outputs[t].gradingResult)||void 0===n?void 0:n.componentResults;return e+(l?l.filter(e=>e.pass).length:0)},0)),y=async(e,t,s,n,l)=>{let r=[...g],i={...r[e]},a=[...i.outputs],o=null!=s?s:a[t].pass,c=void 0===n?s?1:0:n||0;a[t].pass=o,a[t].score=c;let d={...a[t].gradingResult||{},pass:o,score:c,reason:"Manual result (overrides all other grading results)",comment:l,assertion:null};a[t].gradingResult=d,i.outputs=a,r[e]=i;let u={head:j,body:r};x(u);try{let e=await fetch("".concat(await (0,ej.b)(),"/api/eval/").concat(p),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({table:u})});if(!e.ok)throw Error("Network response was not ok")}catch(e){console.error("Failed to update table:",e)}},Z=f.reduce((e,t,s,n)=>t>n[e]?s:e,0),C=f[Z],k=(0,X.Cl)(),w=[];j.vars.length>0&&w.push(k.group({id:"vars",header:()=>(0,n.jsx)("span",{className:"font-bold",children:"Variables"}),columns:j.vars.map((e,s)=>k.accessor(e=>e.vars[s],{id:"Variable ".concat(s+1),header:()=>(0,n.jsx)(ey,{text:e,maxLength:t,className:"font-bold"}),cell:e=>(0,n.jsx)(ev,{text:e.getValue(),maxLength:t}),size:50}))})),w.push(k.group({id:"prompts",header:()=>(0,n.jsx)("span",{className:"font-bold",children:"Outputs"}),columns:j.prompts.map((e,s)=>k.accessor(e=>(function(e){if("string"==typeof e){let t=e.startsWith("[PASS]"),s=e;return e.startsWith("[PASS]")?s=s.slice(6):e.startsWith("[FAIL]")&&(s=s.slice(6)),{text:s,pass:t,score:t?1:0}}return e})(e.outputs[s]),{id:"Prompt ".concat(s+1),header:()=>{var l,r,i,c,p,m,x,y;let Z=f[s]&&g.length?(f[s]/g.length*100).toFixed(2):"0.00",k=f[s]===C&&0!==C,w="Prompt ".concat(s+1),S=o[w]||!1,N=d?(0,n.jsxs)("div",{className:"prompt-detail",children:[v[s]?(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"Asserts:"})," ",b[s],"/",v[s]," passed"]}):null,(null===(l=e.metrics)||void 0===l?void 0:l.totalLatencyMs)?(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"Avg Latency:"})," ",Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(e.metrics.totalLatencyMs/g.length)," ","ms"]}):null,(null===(i=e.metrics)||void 0===i?void 0:null===(r=i.tokenUsage)||void 0===r?void 0:r.total)?(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"Avg Tokens:"})," ",Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(e.metrics.tokenUsage.total/g.length)]}):null,(null===(c=e.metrics)||void 0===c?void 0:c.totalLatencyMs)&&(null===(m=e.metrics)||void 0===m?void 0:null===(p=m.tokenUsage)||void 0===p?void 0:p.completion)?(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"Tokens/Sec:"})," ",Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(e.metrics.tokenUsage.completion/(e.metrics.totalLatencyMs/1e3))]}):null,(null===(x=e.metrics)||void 0===x?void 0:x.cost)?(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"Cost:"})," $",e.metrics.cost.toPrecision(2)]}):null]}):null,R=j.prompts.every(e=>e.provider===j.prompts[0].provider),E=e.provider?e.provider.split(":"):[],P=E.length>1?(0,n.jsxs)(n.Fragment,{children:[E[0],":",(0,n.jsx)("strong",{children:E.slice(1).join(":")})]}):(0,n.jsx)("strong",{children:e.provider});return(0,n.jsxs)("div",{className:"output-header",children:[(0,n.jsxs)("div",{className:"pills",children:[!R&&e.provider?(0,n.jsx)("div",{className:"provider",children:P}):null,(0,n.jsx)("div",{className:"summary",children:(0,n.jsxs)("div",{className:"highlight ".concat(k?"success":""),children:[(0,n.jsxs)("strong",{children:[Z,"% passing"]})," (",f[s],"/",g.length," cases)"]})}),(null===(y=e.metrics)||void 0===y?void 0:y.namedScores)&&Object.keys(e.metrics.namedScores).length>0?(0,n.jsx)(ee,{lookup:e.metrics.namedScores}):null]}),(0,n.jsx)(ey,{className:"prompt-container",text:e.display,expandedText:e.raw,maxLength:t,resourceId:e.id}),N,"failures"===a&&(0,n.jsx)(Y.Z,{sx:{"& .MuiFormControlLabel-label":{fontSize:"0.75rem"}},control:(0,n.jsx)(h.Z,{checked:S,onChange:e=>u(w,e.target.checked)}),label:"Show failures"})]})},cell:e=>(0,n.jsx)(eb,{output:e.getValue(),maxTextLength:t,rowIndex:e.row.index,promptIndex:s,onRating:y,firstOutput:R[e.row.index].outputs[0],filterMode:a,searchText:c,showStats:d})}))}));let S=g.some(e=>e.description);S&&w.splice(0,0,{accessorFn:e=>e.description||"",id:"description",header:()=>(0,n.jsx)("span",{className:"font-bold",children:"Description"}),cell:e=>(0,n.jsx)(ev,{text:String(e.getValue()),maxLength:t}),size:50});let N=Object.keys(s).length>0,R=l.useMemo(()=>{let e=RegExp(c,"i");return g.filter(t=>{let n="failures"===a?t.outputs.some((e,t)=>{let n="Prompt ".concat(t+1);return o[n]&&!e.pass&&(!N||s[n])}):"different"!==a||!t.outputs.every(e=>e.text===t.outputs[0].text),l=!c||t.outputs.some(t=>{var s;let n="".concat(t.text," ").concat(Object.keys(t.namedScores)," ").concat(null===(s=t.gradingResult)||void 0===s?void 0:s.reason);return e.test(n)});return n&&l})},[g,o,a,c,s,N]),E=(0,q.b7)({data:R,columns:w,columnResizeMode:"onChange",getCoreRowModel:(0,X.sC)(),state:{columnVisibility:s}});return(0,n.jsxs)("div",{children:[(0,n.jsxs)("table",{className:"results-table firefox-fix ".concat(t<=25?"compact":""),style:{wordBreak:i},children:[(0,n.jsx)("thead",{children:E.getHeaderGroups().map(e=>(0,n.jsx)("tr",{className:"header",children:e.headers.map(e=>(0,n.jsxs)("th",{colSpan:e.colSpan,style:{width:e.getSize()},children:[e.isPlaceholder?null:(0,q.ie)(e.column.columnDef.header,e.getContext()),(0,n.jsx)("div",{onMouseDown:e.getResizeHandler(),onTouchStart:e.getResizeHandler(),className:"resizer ".concat(e.column.getIsResizing()?"isResizing":"")})]},e.id))},e.id))}),(0,n.jsx)("tbody",{children:E.getRowModel().rows.map((e,t)=>{let s=!1;return(0,n.jsx)("tr",{children:e.getVisibleCells().map(e=>{let l=e.column.id.startsWith("Variable")||"description"===e.column.id,r=!l&&!s;return r&&(s=!0),(0,n.jsx)("td",{style:{width:e.column.getSize()},className:"".concat(l?"variable":""," ").concat(0!==t||l?"":"first-prompt-row"," ").concat(r?"first-prompt-col":""),children:(0,q.ie)(e.column.columnDef.cell,e.getContext())},e.id)})},e.id)})})]}),(0,n.jsx)(ex,{})]})}s(2604);var eC=s(2481),ek=s(7175);function ew(e){let{open:t,onClose:r}=e,{config:i}=_(),a=l.useRef(null),[o,c]=l.useState(!1),[d,h]=l.useState("");l.useEffect(()=>{t&&(async()=>{let{default:e}=await s.e(339).then(s.bind(s,8339));h(e.dump(i))})()},[t,i]);let m=()=>{c(!1),r()};return(0,n.jsxs)(O.Z,{open:t,onClose:m,"aria-labelledby":"config-dialog-title",maxWidth:"md",fullWidth:!0,children:[(0,n.jsx)(F.Z,{id:"config-dialog-title",children:(0,n.jsxs)(u.Z,{display:"flex",justifyContent:"space-between",alignItems:"center",children:[(0,n.jsx)(j.Z,{variant:"h6",style:{flexGrow:1},children:"Config"}),(0,n.jsxs)(u.Z,{children:[(0,n.jsx)(S.Z,{title:"Copy to clipboard",children:(0,n.jsx)(M.Z,{onClick:()=>{a.current&&(a.current.select(),document.execCommand("copy"),c(!0))},children:o?(0,n.jsx)(el.Z,{}):(0,n.jsx)(ek.Z,{})})}),(0,n.jsx)(S.Z,{title:"Download .yaml",children:(0,n.jsx)(M.Z,{onClick:()=>{let e=new Blob([d],{type:"text/yaml;charset=utf-8"}),t=URL.createObjectURL(e),s=document.createElement("a");s.href=t,s.download="config.yaml",document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(t)},children:(0,n.jsx)(eC.Z,{})})})]})]})}),(0,n.jsx)(T.Z,{children:(0,n.jsx)(j.Z,{variant:"body1",component:"div",children:(0,n.jsx)("textarea",{ref:a,readOnly:!0,value:d,style:{width:"100%",minHeight:"400px",fontFamily:"monospace",border:"1px solid #ccc"}})})}),(0,n.jsx)(et.Z,{children:(0,n.jsx)(p.Z,{onClick:m,color:"primary",children:"Close"})})]})}var eS=e=>{let{open:t,onClose:s,shareUrl:r}=e,i=(0,l.useRef)(null),[a,o]=(0,l.useState)(!1),c=()=>{s(),o(!1)};return(0,n.jsxs)(O.Z,{open:t,onClose:c,PaperProps:{style:{minWidth:"min(660px, 100%)"}},children:[(0,n.jsx)(F.Z,{children:"Your eval is ready to share"}),(0,n.jsxs)(T.Z,{children:[(0,n.jsx)(w.Z,{inputRef:i,value:r,fullWidth:!0,InputProps:{readOnly:!0,endAdornment:(0,n.jsx)(M.Z,{onClick:()=>{i.current&&(i.current.select(),document.execCommand("copy"),o(!0))},children:a?(0,n.jsx)(el.Z,{}):(0,n.jsx)(ek.Z,{})})}}),(0,n.jsx)(em.Z,{sx:{fontSize:"0.75rem"},children:"Shared URLs are deleted after 2 weeks."})]}),(0,n.jsx)(et.Z,{children:(0,n.jsx)(p.Z,{onClick:c,color:"primary",children:"Close"})})]})},eN=s(33),eR=e=>{let{open:t,onClose:s}=e,{maxTextLength:l,setMaxTextLength:r,wordBreak:i,setWordBreak:a,showInferenceDetails:o,setShowInferenceDetails:c,renderMarkdown:d,setRenderMarkdown:m,prettifyJson:x,setPrettifyJson:g}=_();return(0,n.jsxs)(O.Z,{open:t,onClose:s,fullWidth:!0,maxWidth:"sm",children:[(0,n.jsx)(F.Z,{children:"Table View Settings"}),(0,n.jsxs)(T.Z,{children:[(0,n.jsx)(u.Z,{children:(0,n.jsx)(S.Z,{title:"Forcing line breaks makes it easier to adjust column widths to your liking",children:(0,n.jsx)(Y.Z,{control:(0,n.jsx)(h.Z,{checked:"break-all"===i,onChange:e=>a(e.target.checked?"break-all":"break-word")}),label:"Force line breaks"})})}),(0,n.jsx)(u.Z,{children:(0,n.jsx)(Y.Z,{control:(0,n.jsx)(h.Z,{checked:d,onChange:e=>m(e.target.checked)}),label:"Render model outputs as Markdown"})}),(0,n.jsx)(u.Z,{children:(0,n.jsx)(Y.Z,{control:(0,n.jsx)(h.Z,{checked:x,onChange:e=>g(e.target.checked)}),label:"Prettify JSON outputs"})}),(0,n.jsx)(u.Z,{children:(0,n.jsx)(S.Z,{title:"Show detailed inference statistics such as latency, tokens used, cost, etc.",children:(0,n.jsx)(Y.Z,{control:(0,n.jsx)(h.Z,{checked:o,onChange:e=>c(e.target.checked)}),label:"Show inference details"})})}),(0,n.jsxs)(u.Z,{maxWidth:"sm",children:[(0,n.jsxs)(j.Z,{mt:2,children:["Max text length: ",l]}),(0,n.jsx)(eN.ZP,{min:25,max:1e3,value:l,onChange:(e,t)=>r(t)})]})]}),(0,n.jsx)(et.Z,{children:(0,n.jsx)(p.Z,{onClick:s,children:"Close"})})]})},eE=s(1938),eP=s(7580);let eO=eP.env.NEXT_PUBLIC_PROMPTFOO_REMOTE_API_BASE_URL||eP.env.PROMPTFOO_REMOTE_API_BASE_URL||"https://api.promptfoo.dev",eF=eP.env.NEXT_PUBLIC_PROMPTFOO_REMOTE_APP_BASE_URL||eP.env.PROMPTFOO_REMOTE_APP_BASE_URL||"https://app.promptfoo.dev";s(6911);let eT=(0,R.Z)(k.Z)(e=>{let{theme:t}=e;return{maxWidth:"100%",flexWrap:"wrap",[t.breakpoints.down("sm")]:{flexDirection:"column"}}});function eI(e){let{recentEvals:t,onRecentEvalSelected:s,defaultEvalId:a}=e,c=(0,o.useRouter)(),{table:k,config:R,setConfig:P,maxTextLength:O,wordBreak:F,showInferenceDetails:T,filePath:I}=_(),{setStateFromConfig:L}=(0,eE.o)(),[M,D]=l.useState({}),[A,U]=l.useState([]),[W,V]=l.useState(""),[z]=(0,E.Nr)(W,1e3),[B,H]=l.useState({}),[G,X]=l.useState("all"),[q,Y]=l.useState(!1),[$,K]=l.useState(""),[Q,ee]=l.useState(!1),et=async()=>{ee(!0);try{let e=await fetch("".concat(eO,"/api/eval"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:{version:2,createdAt:new Date().toISOString(),results:{table:k},config:R}})}),{id:t}=await e.json(),s="".concat(eF,"/eval/").concat(t);K(s),Y(!0)}catch(e){alert("Sorry, something went wrong.")}finally{ee(!1)}},[es,en]=l.useState(!1),[el,er]=l.useState(!1);(0,r.Z)(k,"Table data must be loaded before rendering ResultsView");let{head:ei}=k,ea=async()=>{(0,r.Z)(R,"Config must be loaded before clicking its description");let e=window.prompt("Enter new description:",R.description);if(null!==e&&e!==R.description){let t={...R,description:e};try{let e=await fetch("".concat(await (0,ej.b)(),"/api/eval/").concat(I),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({config:t})});if(!e.ok)throw Error("Network response was not ok");P(t)}catch(e){console.error("Failed to update table:",e)}}},eo=[...ei.vars.map((e,t)=>({value:"Variable ".concat(t+1),label:"Var ".concat(t+1,": ").concat(ei.vars[t].length>100?ei.vars[t].slice(0,97)+"...":ei.vars[t]),group:"Variables"})),...ei.prompts.map((e,t)=>({value:"Prompt ".concat(t+1),label:"Prompt ".concat(t+1,": ").concat(ei.prompts[t].display.length>100?ei.prompts[t].display.slice(0,97)+"...":ei.prompts[t].display),group:"Prompts"}))];return l.useEffect(()=>{U(eo.map(e=>e.value))},[ei]),(0,n.jsxs)("div",{style:{marginLeft:"1rem",marginRight:"1rem"},children:[(null==R?void 0:R.description)&&(0,n.jsx)(u.Z,{mb:2,sx:{display:"flex",alignItems:"center"},children:(0,n.jsxs)(j.Z,{variant:"h5",sx:{flexGrow:1},children:[(0,n.jsx)("span",{className:"description",onClick:ea,children:R.description})," ",(0,n.jsx)("span",{className:"description-filepath",children:I})]})}),(0,n.jsx)(u.Z,{py:"md",children:(0,n.jsxs)(eT,{direction:"row",spacing:4,alignItems:"center",children:[(0,n.jsx)(u.Z,{children:t&&t.length>0&&(0,n.jsx)(x.Z,{sx:{m:1,minWidth:200},size:"small",children:(0,n.jsx)(d.Z,{size:"small",options:t,renderOption:(e,t)=>(0,l.createElement)("li",{...e,key:t.id},t.label),style:{width:350},renderInput:e=>(0,n.jsx)(w.Z,{...e,label:"Eval run",variant:"outlined"}),defaultValue:t.find(e=>e.id===a)||t[0],onChange:(e,t)=>{t&&t.id&&s(t.id)},disableClearable:!0})})}),(0,n.jsx)(u.Z,{children:(0,n.jsxs)(x.Z,{sx:{m:1,minWidth:200,maxWidth:350},size:"small",children:[(0,n.jsx)(g.Z,{id:"visible-columns-label",children:"Columns"}),(0,n.jsx)(y.Z,{labelId:"visible-columns-label",id:"visible-columns",multiple:!0,value:A,onChange:e=>{let{target:{value:t}}=e;U("string"==typeof t?t.split(","):t);let s=[...ei.vars.map((e,t)=>"Variable ".concat(t+1)),...ei.prompts.map((e,t)=>"Prompt ".concat(t+1))],n={};s.forEach(e=>{n[e]=("string"==typeof t?t.split(","):t).includes(e)}),D(n)},input:(0,n.jsx)(b.Z,{label:"Visible columns"}),renderValue:e=>e.join(", "),children:eo.map(e=>(0,n.jsxs)(v.Z,{dense:!0,value:e.value,children:[(0,n.jsx)(h.Z,{checked:A.indexOf(e.value)>-1}),(0,n.jsx)(f.Z,{primary:e.label})]},e.value))})]})}),(0,n.jsx)(u.Z,{children:(0,n.jsxs)(x.Z,{sx:{minWidth:180},size:"small",children:[(0,n.jsx)(g.Z,{id:"failure-filter-mode-label",children:"Display"}),(0,n.jsxs)(y.Z,{labelId:"filter-mode-label",id:"filter-mode",value:G,onChange:e=>{let t=e.target.value;X(t);let s={};ei.prompts.forEach((e,n)=>{s["Prompt ".concat(n+1)]="failures"===t}),H(s)},label:"Filter",children:[(0,n.jsx)(v.Z,{value:"all",children:"Show all results"}),(0,n.jsx)(v.Z,{value:"failures",children:"Show failures only"}),(0,n.jsx)(v.Z,{value:"different",children:"Show different only"})]})]})}),(0,n.jsx)(u.Z,{children:(0,n.jsx)(w.Z,{sx:{minWidth:180},size:"small",label:"Search",placeholder:"Text or regex",value:W,onChange:e=>{V(e.target.value)}})}),(0,n.jsx)(u.Z,{flexGrow:1}),(0,n.jsx)(u.Z,{display:"flex",justifyContent:"flex-end",children:(0,n.jsxs)(eT,{direction:"row",spacing:2,children:[(0,n.jsx)(S.Z,{title:"Edit table view settings",children:(0,n.jsx)(p.Z,{color:"primary",onClick:()=>er(!0),startIcon:(0,n.jsx)(Z.Z,{}),children:"Table Settings"})}),R&&(0,n.jsx)(S.Z,{title:"View the configuration that defines this eval",children:(0,n.jsx)(p.Z,{color:"primary",onClick:()=>en(!0),startIcon:(0,n.jsx)(N.Z,{}),children:"View YAML"})}),R&&(0,n.jsx)(S.Z,{title:"Edit eval",children:(0,n.jsx)(p.Z,{color:"primary",onClick:()=>{L(R),c.push("/setup/")},startIcon:(0,n.jsx)(m.Z,{}),children:"Edit Eval"})}),(null==R?void 0:R.sharing)&&(0,n.jsx)(S.Z,{title:"Generate a unique URL that others can access",children:(0,n.jsx)(p.Z,{color:"primary",onClick:et,disabled:Q,startIcon:Q?(0,n.jsx)(i.Z,{size:16}):(0,n.jsx)(C.Z,{}),children:"Share"})})]})})]})}),(0,n.jsx)(J,{columnVisibility:M}),(0,n.jsx)(eZ,{maxTextLength:O,columnVisibility:M,wordBreak:F,showStats:T,filterMode:G,failureFilter:B,searchText:z,onFailureFilterToggle:(e,t)=>{H(s=>({...s,[e]:t}))}}),(0,n.jsx)(ew,{open:es,onClose:()=>en(!1)}),(0,n.jsx)(eS,{open:q,onClose:()=>Y(!1),shareUrl:$}),(0,n.jsx)(eR,{open:el,onClose:()=>er(!1)})]})}var eL=s(279);async function eM(){let e=(0,c.createClientComponentClient)(),{data:{user:t}}=await e.auth.getUser();(0,r.Z)(t,"User not logged in");let{data:s,error:n}=await e.from("EvaluationResult").select("id, createdAt").eq("user_id",t.id).order("createdAt",{ascending:!1}).limit(100);return s||[]}async function eD(e){let t=(0,c.createClientComponentClient)(),{data:s,error:n}=await t.from("EvaluationResult").select("*").eq("id",e).single();return s}function eA(e){var t;let{fetchId:s,preloadedData:c,recentEvals:d,defaultEvalId:u}=e,p=(0,o.useRouter)(),{table:h,setTable:m,setConfig:x,setFilePath:j}=_(),[g,f]=l.useState(!1),[v,b]=l.useState(!1),[y,Z]=l.useState(d||[]),C=async()=>{let e=await fetch("".concat(await (0,ej.b)(),"/api/results"),{cache:"no-store"}),t=await e.json();return Z(t.data),t.data},k=l.useCallback(async e=>{let t=await fetch("".concat(await (0,ej.b)(),"/api/results/").concat(e),{cache:"no-store"}),s=await t.json();m(s.data.results.table),x(s.data.config),j(e)},[m,x,j]),w=async e=>{eL.Ox?(f(!1),p.push("/eval/remote:".concat(encodeURIComponent(e)))):(k(e),p.push("/eval/?file=".concat(encodeURIComponent(e))))},[S,N]=l.useState(u||(null===(t=y[0])||void 0===t?void 0:t.id)),R=(0,o.useSearchParams)(),E=R?R.get("file"):null;return(l.useEffect(()=>{if(E){let e=async()=>{await k(E),f(!0),N(E),C()};e()}else if(c){var e;m(null===(e=c.data.results)||void 0===e?void 0:e.table),x(c.data.config),f(!0)}else if(s){let e=async()=>{var e;let t="".concat(eO,"/api/eval/").concat(s);console.log("Fetching eval from remote server",t);let n=await fetch(t);if(!n.ok){b(!0);return}let l=await n.json();m(null===(e=l.data.results)||void 0===e?void 0:e.table),x(l.data.config),f(!0)};e()}else if(eL.T8)(0,ej.b)().then(e=>{let t=(0,a.io)(e);return t.on("init",e=>{console.log("Initialized socket connection",e),f(!0),m(e.results.table),x(e.config),C().then(e=>{var t,s;N(null===(t=e[0])||void 0===t?void 0:t.id),j(null===(s=e[0])||void 0===s?void 0:s.id)})}),t.on("update",e=>{console.log("Received data update",e),m(e.results.table),x(e.config),C().then(e=>{var t;N(null===(t=e[0])||void 0===t?void 0:t.id)})}),()=>{t.disconnect()}});else if(eL.Ox)eM().then(e=>{Z(e.map(e=>({id:e.id,label:e.createdAt}))),e.length>0&&eD(e[0].id).then(t=>{(0,r.Z)(t,"Eval not found");let s=t.results,n=t.config;N(e[0].id),m(s.table),x(n),f(!0)})});else{let e=async()=>{let e=await C();if(!(e.length>0))return(0,n.jsx)("div",{className:"notice",children:"No evals yet. Share some evals to this server and they will appear here."});{let t=await (0,ej.b)(),s=e[0].id,n=await fetch("".concat(t,"/api/results/").concat(s)),l=await n.json();m(l.data.results.table),x(l.data.config),f(!0),N(s),j(s)}};e()}},[s,m,x,j,k,c,N,E]),v)?(0,n.jsx)("div",{className:"notice",children:"404 Eval not found"}):g&&h?(0,n.jsx)(eI,{defaultEvalId:S,recentEvals:y,onRecentEvalSelected:w}):(0,n.jsxs)("div",{className:"notice",children:[(0,n.jsx)("div",{children:(0,n.jsx)(i.Z,{size:22})}),(0,n.jsx)("div",{children:"Loading eval data"})]})}s(5038)},279:function(e,t,s){"use strict";s.d(t,{Ox:function(){return r},T8:function(){return l},eA:function(){return i}});var n=s(7580);let l=!n.env.NEXT_PUBLIC_PROMPTFOO_BUILD_STANDALONE_SERVER,r=!!n.env.NEXT_PUBLIC_PROMPTFOO_USE_SUPABASE,i=""},1938:function(e,t,s){"use strict";s.d(t,{o:function(){return r}});var n=s(4660),l=s(4810);let r=(0,n.Ue)()((0,l.tJ)((e,t)=>({env:{},testCases:[],description:"",providers:[],prompts:[],setEnv:t=>e({env:t}),setTestCases:t=>e({testCases:t}),setDescription:t=>e({description:t}),setProviders:t=>e({providers:t}),setPrompts:t=>e({prompts:t}),setStateFromConfig:t=>{let s={};t.description&&(s.description=t.description||""),t.tests&&(s.testCases=t.tests),t.providers&&(s.providers=t.providers),t.prompts&&("string"==typeof t.prompts?s.prompts=[t.prompts]:Array.isArray(t.prompts)?s.prompts=t.prompts.filter(e=>!e.endsWith(".txt")&&!e.endsWith(".json")&&!e.endsWith(".yaml")):console.warn("Invalid prompts config",t.prompts)),e(s)},getTestSuite:()=>{let{description:e,testCases:s,providers:n,prompts:l,env:r}=t();return{env:r,description:e,providers:n,prompts:l,tests:s}}}),{name:"promptfoo",skipHydration:!0}))},8715:function(){},5038:function(){},2604:function(){},6911:function(){},5777:function(){}}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[958],{4303:function(e,t,s){Promise.resolve().then(s.bind(s,4260))},2810:function(e,t,s){"use strict";let i;async function l(){if(!i){let e=await fetch("/api/config"),t=await e.json();i=t.apiBaseUrl}return i}s.d(t,{b:function(){return l}})},4260:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return E}});var i=s(7437),l=s(2265),n=s(1396),r=s.n(n),c=s(6507),a=s(2492),d=s(3701),o=s(9279),h=s(666),u=s(6988),v=s(4147),x=s(5781),j=s(8276),p=s(4033),Z=s(8339),m=s(5551),f=s(9394),w=s(2834),C=s(6337),y=s(1797),g=s(3226),I=s(5446);function k(e){var t,s,n,c,x;let{openDialog:j,handleClose:p,testCase:k}=e,[S,E]=(0,l.useState)(1);return(0,i.jsxs)(f.Z,{open:j,onClose:p,fullWidth:!0,maxWidth:"lg",children:[(0,i.jsxs)(y.Z,{children:["Dataset ",k.id.slice(0,6)]}),(0,i.jsxs)(C.Z,{children:[(0,i.jsx)(g.Z,{variant:"h6",style:{marginTop:"1rem"},children:"Test cases"}),(0,i.jsx)(I.u,{readOnly:!0,value:k&&Z.default.dump(k.testCases),style:{width:"100%",padding:"0.75rem"},maxRows:15}),(0,i.jsx)(g.Z,{variant:"h6",style:{marginTop:"1rem"},children:"Used in..."}),(0,i.jsxs)(d.Z,{children:[(0,i.jsx)(u.Z,{children:(0,i.jsxs)(v.Z,{children:[(0,i.jsx)(h.Z,{children:"Eval ID"}),(0,i.jsx)(h.Z,{children:"Prompt 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)(h.Z,{children:"Prompt"})]})}),(0,i.jsx)(o.Z,{children:null==k?void 0:null===(t=k.prompts)||void 0===t?void 0:t.slice((S-1)*10,10*S).sort((e,t)=>t.evalId.localeCompare(e.evalId)).map((e,t)=>{var s,l,a,d,o,u,j,p;return(0,i.jsxs)(v.Z,{hover:!0,children:[(0,i.jsx)(h.Z,{children:(0,i.jsx)(r(),{href:"/eval/?file=".concat(e.evalFilepath),children:e.evalId.slice(0,6)})}),(0,i.jsx)(h.Z,{style:{minWidth:"8em"},children:(0,i.jsx)(r(),{href:"/prompts/?id=".concat(e.id),children:e.id.slice(0,6)})}),(0,i.jsx)(h.Z,{children:null!==(n=null===(s=e.prompt.metrics)||void 0===s?void 0:s.score.toFixed(2))&&void 0!==n?n:"-"}),(0,i.jsx)(h.Z,{children:(null===(l=e.prompt.metrics)||void 0===l?void 0:l.testPassCount)!==void 0&&(null===(a=e.prompt.metrics)||void 0===a?void 0:a.testFailCount)!==void 0?((null===(d=e.prompt.metrics)||void 0===d?void 0:d.testPassCount)/((null===(o=e.prompt.metrics)||void 0===o?void 0:o.testPassCount)+(null===(u=e.prompt.metrics)||void 0===u?void 0:u.testFailCount))*100).toFixed(2)+"%":"-"}),(0,i.jsx)(h.Z,{children:null!==(c=null===(j=e.prompt.metrics)||void 0===j?void 0:j.testPassCount)&&void 0!==c?c:"-"}),(0,i.jsx)(h.Z,{children:null!==(x=null===(p=e.prompt.metrics)||void 0===p?void 0:p.testFailCount)&&void 0!==x?x:"-"}),(0,i.jsx)(h.Z,{children:e.prompt.raw.length>250?e.prompt.raw.slice(0,250)+"...":e.prompt.raw})]},t)})})]}),Math.ceil(((null==k?void 0:null===(s=k.prompts)||void 0===s?void 0:s.length)||0)/10)>1&&(0,i.jsx)(a.Z,{count:Math.ceil(k.prompts.length/10),page:S,onChange:(e,t)=>{E(t)}})]}),(0,i.jsx)(w.Z,{children:(0,i.jsx)(m.Z,{onClick:p,children:"Close"})})]})}var S=s(2810);function E(){let e=(0,p.useSearchParams)(),[t,s]=(0,l.useState)([]),[n,Z]=(0,l.useState)("date"),[m,f]=(0,l.useState)("desc"),[w,C]=(0,l.useState)(1),[y,g]=(0,l.useState)(10),[I,E]=(0,l.useState)(!1),[P,D]=(0,l.useState)(0),F=e=>{let t=n===e&&"asc"===m?"desc":"asc";Z(e),f(t)};(0,l.useEffect)(()=>{(async()=>{fetch("".concat(await (0,S.b)(),"/api/datasets")).then(e=>e.json()).then(e=>{let t=[...e.data].sort((e,t)=>null===n?0:"asc"===m?e[n]>t[n]?1:-1:e[n]<t[n]?1:-1);s(t)})})()},[n,m,w,y]),(0,l.useEffect)(()=>{let s=null==e?void 0:e.get("id");if(s){let e=t.findIndex(e=>e.id.startsWith(s));-1!==e&&b(e)}},[t,e]);let b=e=>{D(e),E(!0)};return(0,i.jsxs)(c.Z,{paddingX:2,children:[(0,i.jsxs)(d.Z,{children:[(0,i.jsx)(u.Z,{children:(0,i.jsxs)(v.Z,{children:[(0,i.jsx)(h.Z,{style:{width:"10%"},children:"ID"}),(0,i.jsx)(h.Z,{style:{width:"20%"},children:(0,i.jsx)(x.Z,{active:"raw"===n,direction:"raw"===n?m:"asc",onClick:()=>F("raw"),children:"Info"})}),(0,i.jsx)(h.Z,{style:{width:"20%"},children:"Variables"}),(0,i.jsx)(h.Z,{style:{width:"10%"},children:(0,i.jsx)(x.Z,{active:"count"===n,direction:"count"===n?m:"asc",onClick:()=>F("count"),children:"Total # evals"})}),(0,i.jsx)(h.Z,{style:{width:"20%"},children:(0,i.jsx)(j.Z,{title:"The date of the most recent eval for this set of test cases",children:(0,i.jsx)(x.Z,{active:"date"===n,direction:"date"===n?m:"asc",onClick:()=>F("date"),children:"Most recent eval date"})})}),(0,i.jsx)(h.Z,{style:{width:"20%"},children:(0,i.jsx)(j.Z,{title:"The ID of the most recent eval for this set of test cases",children:(0,i.jsx)(x.Z,{active:"evalId"===n,direction:"evalId"===n?m:"asc",onClick:()=>F("evalId"),children:"Most recent eval ID"})})})]})}),(0,i.jsx)(o.Z,{children:t.slice((w-1)*y,w*y).map((e,t)=>(0,i.jsxs)(v.Z,{hover:!0,onClick:()=>b(t),style:{cursor:"pointer"},children:[(0,i.jsx)(h.Z,{children:e.id.slice(0,6)}),(0,i.jsxs)(h.Z,{style:{width:"20%",whiteSpace:"pre-wrap"},children:[e.testCases.length," test cases"]}),(0,i.jsx)(h.Z,{style:{width:"20%",whiteSpace:"pre-wrap"},children:(()=>{if(!Array.isArray(e.testCases)||"string"==typeof e.testCases[0])return"";let t=(e.testCases||[]).flatMap(e=>Object.keys(e.vars||{})),s=Array.from(new Set(t));return s.length>0?s.join(", "):"None"})()}),(0,i.jsx)(h.Z,{style:{width:"10%"},children:e.count}),(0,i.jsx)(h.Z,{style:{width:"20%"},children:e.recentEvalDate||"Unknown"}),(0,i.jsx)(h.Z,{style:{width:"20%"},children:e.recentEvalId?(0,i.jsx)(r(),{href:"/eval?file=".concat(e.recentEvalFilepath),children:e.recentEvalId.slice(0,6)}):"Unknown"})]},t))})]}),Math.ceil(t.length/y)>1&&(0,i.jsx)(a.Z,{count:Math.ceil(t.length/y),page:w,onChange:(e,t)=>C(t)}),t[P]&&(0,i.jsx)(k,{openDialog:I,handleClose:()=>{E(!1)},testCase:t[P]})]})}}},function(e){e.O(0,[293,808,420,339,21,971,596,744],function(){return e(e.s=4303)}),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[794],{8050:function(e,t,i){Promise.resolve().then(i.bind(i,176))},2810:function(e,t,i){"use strict";let s;async function n(){if(!s){let e=await fetch("/api/config"),t=await e.json();s=t.apiBaseUrl}return s}i.d(t,{b:function(){return n}})},176:function(e,t,i){"use strict";i.r(t),i.d(t,{default:function(){return P}});var s=i(7437),n=i(2265),l=i(1396),c=i.n(l),r=i(6507),d=i(2492),a=i(3701),o=i(9279),h=i(666),u=i(6988),x=i(4147),j=i(5781),Z=i(8276),p=i(4033),v=i(2810),f=i(9394),m=i(2834),w=i(6337),y=i(1797),C=i(5446),g=i(3226),k=i(5551),E=e=>{var t;let{openDialog:i,handleClose:n,selectedPrompt:l}=e;return(0,s.jsxs)(f.Z,{open:i,onClose:n,fullWidth:!0,maxWidth:"lg",children:[(0,s.jsxs)(y.Z,{children:["Prompt ",l.id.slice(0,6)]}),(0,s.jsxs)(w.Z,{children:[(0,s.jsx)(g.Z,{variant:"h6",style:{marginTop:"1rem"},children:"Prompt"}),(0,s.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,s.jsx)(g.Z,{variant:"h6",style:{marginTop:"1rem"},children:"Used in..."}),(0,s.jsxs)(a.Z,{children:[(0,s.jsx)(u.Z,{children:(0,s.jsxs)(x.Z,{children:[(0,s.jsx)(h.Z,{children:"Eval ID"}),(0,s.jsx)(h.Z,{children:"Dataset ID"}),(0,s.jsx)(h.Z,{children:"Raw score"}),(0,s.jsx)(h.Z,{children:"Pass rate"}),(0,s.jsx)(h.Z,{children:"Pass count"}),(0,s.jsx)(h.Z,{children:"Fail count"})]})}),(0,s.jsx)(o.Z,{children:null==l?void 0:l.evals.sort((e,t)=>t.id.localeCompare(e.id)).map(e=>{var t,i,n,l,r,d;let a=null!==(l=null===(t=e.metrics)||void 0===t?void 0:t.testPassCount)&&void 0!==l?l:0,o=null!==(r=null===(i=e.metrics)||void 0===i?void 0:i.testFailCount)&&void 0!==r?r:0,u=a+o>0?(a/(a+o)*100).toFixed(2)+"%":"-";return(0,s.jsxs)(x.Z,{children:[(0,s.jsx)(h.Z,{children:(0,s.jsx)(c(),{href:"/eval/?file=".concat(e.filePath),children:e.id.slice(0,6)})}),(0,s.jsx)(h.Z,{children:(0,s.jsx)(c(),{href:"/datasets/?id=".concat(e.datasetId),children:e.datasetId.slice(0,6)})}),(0,s.jsx)(h.Z,{children:null!==(d=null===(n=e.metrics)||void 0===n?void 0:n.score.toFixed(2))&&void 0!==d?d:"-"}),(0,s.jsx)(h.Z,{children:u}),(0,s.jsx)(h.Z,{children:a}),(0,s.jsx)(h.Z,{children:o})]},"eval-".concat(e.id))})})]})]}),(0,s.jsx)(m.Z,{children:(0,s.jsx)(k.Z,{onClick:n,children:"Close"})})]})};function P(){let e=(0,p.useSearchParams)(),[t,i]=(0,n.useState)([]),[l,f]=(0,n.useState)("date"),[m,w]=(0,n.useState)("desc"),[y,C]=(0,n.useState)(1),[g,k]=(0,n.useState)(10),[P,S]=(0,n.useState)(!1),[D,I]=(0,n.useState)(0),_=e=>{let t=l===e&&"asc"===m?"desc":"asc";f(e),w(t)};(0,n.useEffect)(()=>{(async()=>{fetch("".concat(await (0,v.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);i(t)})})()},[l,m]),(0,n.useEffect)(()=>{let i=null==e?void 0:e.get("id");if(i){let e=t.findIndex(e=>e.id.startsWith(i));-1!==e&&b(e)}},[t,e]);let b=e=>{S(!0),I(e)};return(0,s.jsxs)(r.Z,{paddingX:2,children:[(0,s.jsxs)(a.Z,{children:[(0,s.jsx)(u.Z,{children:(0,s.jsxs)(x.Z,{children:[(0,s.jsx)(h.Z,{style:{width:"10%"},children:"ID"}),(0,s.jsx)(h.Z,{style:{width:"60%"},children:(0,s.jsx)(j.Z,{active:"raw"===l,direction:"raw"===l?m:"asc",onClick:()=>_("raw"),children:"Prompt"})}),(0,s.jsx)(h.Z,{style:{width:"20%"},children:(0,s.jsx)(Z.Z,{title:"The date of the most recent eval for this prompt",children:(0,s.jsx)(j.Z,{active:"date"===l,direction:"date"===l?m:"asc",onClick:()=>_("date"),children:"Most recent eval"})})}),(0,s.jsx)(h.Z,{style:{width:"10%"},children:(0,s.jsx)(j.Z,{active:"count"===l,direction:"count"===l?m:"asc",onClick:()=>_("count"),children:"# Evals"})})]})}),(0,s.jsx)(o.Z,{children:t.slice((y-1)*g,y*g).map((e,t)=>(0,s.jsxs)(x.Z,{hover:!0,children:[(0,s.jsx)(h.Z,{style:{width:"10%"},children:e.id.slice(0,6)}),(0,s.jsx)(h.Z,{style:{width:"60%",whiteSpace:"pre-wrap",cursor:"pointer"},onClick:()=>b(t),children:e.prompt.raw.length>500?e.prompt.raw.slice(0,500)+"...":e.prompt.raw}),(0,s.jsx)(h.Z,{style:{width:"20%"},children:e.recentEvalDate?(0,s.jsx)(c(),{href:"/eval?file=".concat(e.recentEvalId),children:e.recentEvalDate}):"Unknown"}),(0,s.jsx)(h.Z,{style:{width:"10%"},children:e.count})]},t))})]}),Math.ceil(t.length/g)>1&&(0,s.jsx)(d.Z,{count:Math.ceil(t.length/g),page:y,onChange:(e,t)=>C(t)}),t[D]&&(0,s.jsx)(E,{openDialog:P,handleClose:()=>{S(!1)},selectedPrompt:t[D]})]})}}},function(e){e.O(0,[293,808,420,21,971,596,744],function(){return e(e.s=8050)}),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[413],{3515:function(e,t,n){Promise.resolve().then(n.bind(n,2378))},2378:function(e,t,n){"use strict";n.r(t),n.d(t,{default:function(){return ed}});var a=n(7437),r=n(2265),i=n(5551),l=n(8938),s=n(3226),o=n(6507),c=n(3457),d=n(9394),p=n(2834),u=n(6337),h=n(4173),x=n(1797),m=n(4740),f=n(4033),j=n(6882),g=n(1938),v=n(279),Z=()=>{let e=(0,f.useRouter)(),{env:t,description:n,providers:l,prompts:s,testCases:o}=(0,g.o)(),[c,d]=(0,r.useState)(!1),[p,u]=(0,r.useState)(0),h=async()=>{d(!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})});if(!a.ok)throw Error("HTTP error! status: ".concat(a.status));let r=await a.json(),i=setInterval(async()=>{let t=await fetch("".concat(v.eA,"/api/eval/job/").concat(r.id,"/"));if(!t.ok)throw clearInterval(i),Error("HTTP error! status: ".concat(t.status));let n=await t.json();if("complete"===n.status)clearInterval(i),d(!1),v.Ox?e.push("/eval/remote:".concat(encodeURIComponent(r.id))):e.push("/eval");else if("failed"===n.status)throw clearInterval(i),d(!1),Error("Job failed");else{let e=0===n.total?0:Math.round(n.progress/n.total*100);u(e)}},1e3)}catch(e){console.error(e),d(!1),alert("An error occurred: ".concat(e.message))}};return(0,a.jsx)(i.Z,{variant:"contained",color:"primary",onClick:h,disabled:c,children:c?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(j.Z,{size:24,sx:{marginRight:2}}),p.toFixed(0),"% complete"]}):"Run Evaluation"})},b=n(2057),y=n(8768),C=n(5873),_=n(1975),k=n(3295),A=()=>{let{env:e,setEnv:t}=(0,g.o)(),[n,l]=(0,r.useState)(!1),[s,o]=(0,r.useState)(e),c=()=>{l(!1)};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(i.Z,{variant:"outlined",startIcon:(0,a.jsx)(k.Z,{}),onClick:()=>{l(!0)},children:"API keys"}),(0,a.jsxs)(d.Z,{open:n,onClose:c,fullWidth:!0,maxWidth:"md",children:[(0,a.jsx)(x.Z,{children:"Provider settings"}),(0,a.jsxs)(u.Z,{children:[(0,a.jsxs)(b.Z,{defaultExpanded:!0,children:[(0,a.jsx)(C.Z,{children:"OpenAI"}),(0,a.jsxs)(y.Z,{children:[(0,a.jsx)(_.Z,{label:"OpenAI API key",fullWidth:!0,margin:"normal",value:s.OPENAI_API_KEY,onChange:e=>o({...s,OPENAI_API_KEY:e.target.value})}),(0,a.jsx)(_.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)(_.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)(C.Z,{children:"Azure"}),(0,a.jsx)(y.Z,{children:(0,a.jsx)(_.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)(C.Z,{children:"Amazon Bedrock"}),(0,a.jsx)(y.Z,{children:(0,a.jsx)(_.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)(C.Z,{children:"Anthropic"}),(0,a.jsx)(y.Z,{children:(0,a.jsx)(_.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)(C.Z,{children:"Google Vertex AI"}),(0,a.jsx)(y.Z,{children:(0,a.jsx)(_.Z,{label:"Vertex API Key",fullWidth:!0,margin:"normal",value:s.VERTEX_API_KEY,onChange:e=>o({...s,VERTEX_API_KEY:e.target.value})})}),(0,a.jsx)(y.Z,{children:(0,a.jsx)(_.Z,{label:"Vertex Project ID",fullWidth:!0,margin:"normal",value:s.VERTEX_PROJECT_ID,onChange:e=>o({...s,VERTEX_PROJECT_ID:e.target.value})})}),(0,a.jsx)(y.Z,{children:(0,a.jsx)(_.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)(C.Z,{children:"Replicate"}),(0,a.jsx)(y.Z,{children:(0,a.jsx)(_.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)(i.Z,{onClick:c,color:"primary",children:"Cancel"}),(0,a.jsx)(i.Z,{onClick:()=>{t(s),c()},color:"primary",variant:"contained",children:"Save"})]})]})]})},E=n(2653),I=n(3701),P=n(9279),S=n(666),O=n(5795),w=n(4147),T=n(8276),R=n(3391),W=n(6446),N=n(1280),z=n(9329),V=e=>{let{open:t,prompt:n,index:l,onAdd:s,onCancel:o}=e,[c,h]=r.useState(n),m=r.useRef(null);r.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)(_.Z,{value:c,onChange:e=>h(e.target.value),fullWidth:!0,margin:"normal",multiline:!0,placeholder:"The quick brown {{animal1}} jumps over the lazy {{animal2}}.",helperText:"Tip: use the {{varname}} syntax to add variables to your prompt.",inputRef:m})}),(0,a.jsxs)(p.Z,{children:[(0,a.jsx)(i.Z,{onClick:f.bind(null,!0),color:"primary",variant:"contained",disabled:!c.length,children:"Add"}),(0,a.jsx)(i.Z,{onClick:f.bind(null,!1),color:"primary",variant:"contained",disabled:!c.length,children:"Add Another"}),(0,a.jsx)(i.Z,{onClick:o,color:"secondary",children:"Cancel"})]})]})};n(2280);var F=()=>{let[e,t]=(0,r.useState)(!1),[n,l]=(0,r.useState)(null),{prompts:o,setPrompts:d}=(0,g.o)(),p=(0,r.useRef)(null);(0,r.useEffect)(()=>{null!==n&&n>0&&p.current&&p.current.focus()},[n]);let u=e=>{l(e),t(!0)},h=(e,t)=>{e.stopPropagation();let n=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)(T.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)(i.Z,{color:"primary",onClick:()=>{t(!0)},variant:"contained",children:"Add Prompt"})]})]}),(0,a.jsx)(O.Z,{children:(0,a.jsx)(I.Z,{children:(0,a.jsx)(P.Z,{children:0===o.length?(0,a.jsx)(w.Z,{children:(0,a.jsx)(S.Z,{colSpan:2,align:"center",children:"No prompts added yet."})}):o.map((e,t)=>(0,a.jsxs)(w.Z,{sx:{"&:hover":{backgroundColor:"rgba(0, 0, 0, 0.04)",cursor:"pointer"}},onClick:()=>u(t),children:[(0,a.jsx)(S.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)=>/{{\w+}}/g.test(e)?(0,a.jsx)("span",{className:"prompt-var-highlight",children:e},t):e)]})}),(0,a.jsxs)(S.Z,{align:"right",sx:{minWidth:150},children:[(0,a.jsx)(E.Z,{onClick:()=>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)(V,{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(6988),U=e=>{let{onAdd:t,varsList:n,initialValues:i}=e,[l,d]=r.useState(i||{});return(0,r.useEffect)(()=>{let e={};n.forEach(t=>{e[t]=(null==i?void 0:i[t])||""}),d(e)},[n,i]),(0,a.jsxs)(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)(_.Z,{placeholder:e,label:e,value:l[e],fullWidth:!0,onChange:n=>{let a=n.target.value,r={...l,[e]:a};d(r),t(r)}})},n))}):(0,a.jsxs)(s.Z,{variant:"subtitle1",gutterBottom:!0,children:["Add variables to your prompt using the ","{{varname}}"," syntax."]})]})},B=n(8440);let K=["equals","contains","icontains","contains-all","contains-any","starts-with","regex","is-json","contains-json","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"];var Y=e=>{let{onAdd:t,initialValues:n}=e,[l,d]=(0,r.useState)(n||[]),p=e=>{let n=l.filter((t,n)=>n!==e);d(n),t(n)};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(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)(B.Z,{value:e.type,options:K,sx:{minWidth:200},onChange:(e,a)=>{let r=l.map((e,t)=>t===n?{...e,type:a}:e);d(r),t(r)},renderInput:e=>(0,a.jsx)(_.Z,{...e,label:"Type"})}),(0,a.jsx)(_.Z,{label:"Value",value:e.value,fullWidth:!0,onChange:e=>{let a=e.target.value,r=l.map((e,t)=>t===n?{...e,value:a}:e);d(r),t(r)}}),(0,a.jsx)(E.Z,{onClick:()=>p(n),size:"small",children:(0,a.jsx)(W.Z,{})})]},n))})}),(0,a.jsx)(i.Z,{color:"primary",onClick:()=>{let e=[...l,{type:"equals",value:""}];d(e),t(e)},children:"Add Assert"})]})},q=e=>{let{open:t,onAdd:n,varsList:l,initialValues:s,onCancel:c}=e,[h,m]=(0,r.useState)((null==s?void 0:s.description)||""),[f,j]=(0,r.useState)((null==s?void 0:s.vars)||{}),[g,v]=(0,r.useState)((null==s?void 0:s.assert)||[]),[Z,b]=(0,r.useState)(0);r.useEffect(()=>{s?(m(s.description||""),j(s.vars||{}),v(s.assert||[])):(m(""),j({}),v([]))},[s]);let y=e=>{n({description:h,vars:f,assert:g},e),e&&c(),m(""),j({}),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=>j(e),varsList:l,initialValues:null==s?void 0:s.vars}),(0,a.jsx)(Y,{onAdd:e=>v(e),initialValues:(null==s?void 0:s.assert)||[]},Z)]})}),(0,a.jsxs)(p.Z,{children:[(0,a.jsx)(i.Z,{onClick:y.bind(void 0,!0),color:"primary",variant:"contained",children:s?"Update Test Case":"Add Test Case"}),!s&&(0,a.jsx)(i.Z,{onClick:y.bind(void 0,!1),color:"primary",variant:"contained",children:"Add Another"}),(0,a.jsx)(i.Z,{onClick:c,color:"secondary",children:"Cancel"})]})]})},D=n(5320),J=e=>{let{varsList:t}=e,{testCases:l,setTestCases:o}=(0,g.o)(),[d,p]=r.useState(null),[u,h]=r.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)(T.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 r=null===(a=e.target)||void 0===a?void 0:null===(t=a.result)||void 0===t?void 0:t.toString();if(r){let{parse:e}=await Promise.all([n.e(631),n.e(922)]).then(n.bind(n,8922)),t=e(r,{columns:!0});o([...l,...t.map(e=>(0,D.It)(e))])}},e.readAsText(a)}},style:{display:"none"}})]})})}),(0,a.jsx)(i.Z,{color:"primary",onClick:()=>h(!0),variant:"contained",children:"Add Test Case"})]})]}),(0,a.jsx)(O.Z,{children:(0,a.jsxs)(I.Z,{children:[(0,a.jsx)(L.Z,{children:(0,a.jsxs)(w.Z,{children:[(0,a.jsx)(S.Z,{children:"Description"}),(0,a.jsx)(S.Z,{children:"Assertions"}),(0,a.jsx)(S.Z,{children:"Variables"}),(0,a.jsx)(S.Z,{align:"right"})]})}),(0,a.jsx)(P.Z,{children:0===l.length?(0,a.jsx)(w.Z,{children:(0,a.jsx)(S.Z,{colSpan:4,align:"center",children:"No test cases added yet."})}):l.map((e,t)=>{var n;return(0,a.jsxs)(w.Z,{sx:{"&:hover":{backgroundColor:"rgba(0, 0, 0, 0.04)",cursor:"pointer"}},onClick:()=>{p(t),h(!0)},children:[(0,a.jsx)(S.Z,{children:(0,a.jsx)(s.Z,{variant:"body2",children:e.description||"Test Case #".concat(t+1)})}),(0,a.jsxs)(S.Z,{children:[(null===(n=e.assert)||void 0===n?void 0:n.length)||0," assertions"]}),(0,a.jsx)(S.Z,{children:Object.entries(e.vars||{}).map(e=>{let[t,n]=e;return t+"="+n}).join(", ")}),(0,a.jsxs)(S.Z,{align:"right",sx:{minWidth:150},children:[(0,a.jsx)(E.Z,{onClick:()=>{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)(q,{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(7827),G=e=>{let{onChange:t,...n}=e,[i,l]=r.useState(""),[s,o]=r.useState(!1);return(0,a.jsx)(_.Z,{...n,error:s,helperText:s?"Invalid JSON":"",value:i,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]=r.useState(l);return r.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)(_.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)(i.Z,{onClick:s,children:"Cancel"}),(0,a.jsx)(i.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(["anthropic:claude-1","anthropic:claude-1-100k","anthropic:claude-instant-1","anthropic:claude-instant-1-100k"].map(e=>({id:e,config:{max_tokens_to_sample:256,temperature:.5}}))).concat(["bedrock:anthropic.claude-instant-v1","bedrock:anthropic.claude-v1","bedrock:anthropic.claude-v2"].map(e=>({id:e,config:{max_tokens_to_sample:256,temperature:.5}}))).concat(["openai:gpt-3.5-turbo","openai:gpt-3.5-turbo-0301","openai:gpt-3.5-turbo-0613","openai:gpt-3.5-turbo-16k","openai:gpt-3.5-turbo-16k-0613","openai:gpt-4","openai:gpt-4-0314","openai:gpt-4-0613","openai:gpt-4-32k","openai:gpt-4-32k-0314"].map(e=>({id:e,config:{organization:"",temperature:.5,max_tokens:1024,top_p:1,frequency_penalty:0,presence_penalty:0,function_call:void 0,functions:void 0,stop:void 0}}))).concat(["azureopenai:gpt-3.5-turbo","azureopenai:gpt-3.5-turbo-0301","azureopenai:gpt-3.5-turbo-0613","azureopenai:gpt-3.5-turbo-16k","azureopenai:gpt-3.5-turbo-16k-0613","azureopenai:gpt-4","azureopenai:gpt-4-0314","azureopenai:gpt-4-0613","azureopenai:gpt-4-32k","azureopenai:gpt-4-32k-0314"].map(e=>({id:e,config:{temperature:.5,max_tokens:1024,top_p:1,frequency_penalty:0,presence_penalty:0,function_call:void 0,functions:void 0,stop:void 0}}))).concat(["vertex:chat-bison@001","vertex:chat-bison","vertex:chat-bison-32k","vertex:chat-bison-32k@001"].map(e=>({id:e,config:{context:void 0,examples:void 0,temperature:0,maxOutputTokens:1024,topP:.95,topK:40,safetySettings:void 0,stopSequence:void 0}}))).sort((e,t)=>e.id.localeCompare(t.id)),$={anthropic:"Anthropic",bedrock:"Amazon Web Services",azureopenai:"Azure",openai:"OpenAI",replicate:"Replicate"};var Q=e=>{let{providers:t,onChange:n}=e,[i,l]=r.useState(null),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)(B.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[1]:"Unknown provider"},renderTags:(e,t)=>e.map((e,n)=>{let a=s(e),i=c(e,n);return(0,r.createElement)(X.Z,{variant:"outlined",label:a,...t({index:n}),key:i,onClick:()=>d(e)})}),renderInput:e=>(0,a.jsx)(_.Z,{...e,variant:"outlined",placeholder:"Select LLM providers",helperText:t.length>0?"Click a provider to configure its settings.":null})}),i&&i.id&&(0,a.jsx)(H,{open:!!i,providerId:i.id,config:i.config,onClose:()=>l(null),onSave:e=>{if(i){let a=t.map(t=>t.id===i.id?{...t,config:e}:t);n(a),l(null)}}})]})},ee=n(2666),et=n.n(ee),en=n(4759);n(5341),n(7555);var ea=n(8339),er=n(9963),ei=n(1396),el=n.n(ei);n(695);var es=()=>{let{env:e,setEnv:t,description:n,setDescription:l,providers:c,setProviders:d,prompts:p,setPrompts:u,testCases:h,setTestCases:x}=(0,g.o)(),[m,f]=r.useState(""),[j,v]=r.useState(!0);r.useEffect(()=>{f(ea.default.dump({env:e,description:n,providers:c,prompts:p,tests:h}))},[e,n,c,p,h]);let Z=e=>{t(e.env||{}),l(e.description||""),d(e.providers||[]),u(e.prompts||[]),x(e.tests||[])};return(0,a.jsxs)(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)(i.Z,{variant:"text",color:"primary",startIcon:j?(0,a.jsx)(R.Z,{}):(0,a.jsx)(er.Z,{}),onClick:()=>{if(!j)try{let e=ea.default.load(m,{json:!0});Z(e)}catch(e){}v(!j)},children:j?"Edit YAML":"Save"}),(0,a.jsx)(et(),{autoCapitalize:"off",value:m,onValueChange:e=>{j||f(e)},highlight:e=>(0,en.highlight)(e,en.languages.yaml),padding:10,style:{fontFamily:'"Fira code", "Fira Mono", monospace',fontSize:14},disabled:j,className:j?"":"glowing-border"})]})};n(284);var eo=n(7580);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,r.useState)(!1),{description:n,setDescription:f,providers:j,setProviders:v,prompts:b,setPrompts:y,testCases:C,setTestCases:_}=(0,g.o)();if((0,r.useEffect)(()=>{g.o.persist.rehydrate()},[]),eo.env.NEXT_PUBLIC_NO_BROWSING)return null;let k=(e=>{let t=/{{(\w+)}}/g,n=new Set;return e.forEach(e=>{let a;for(;null!==(a=t.exec(e));)n.add(a[1])}),Array.from(n)})(b);return(0,a.jsxs)(l.Z,{maxWidth:"lg",sx:{marginTop:"2rem"},children:[(0,a.jsxs)(c.Z,{direction:"row",spacing:2,justifyContent:"space-between",children:[(0,a.jsx)(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)(i.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:j,onChange:v})]})})}),(0,a.jsx)(o.Z,{mt:4}),(0,a.jsx)(m.SV,{FallbackComponent:ec,onReset:()=>{y([])},children:(0,a.jsx)(F,{})}),(0,a.jsx)(o.Z,{mt:6}),(0,a.jsx)(m.SV,{FallbackComponent:ec,onReset:()=>{_([])},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)(i.Z,{onClick:()=>t(!1),children:"Cancel"}),(0,a.jsx)(i.Z,{onClick:()=>{f(""),v([]),y([]),_([]),t(!1)},autoFocus:!0,children:"Reset"})]})]})]})}},279:function(e,t,n){"use strict";n.d(t,{Ox:function(){return i},T8:function(){return r},eA:function(){return l}});var a=n(7580);let r=!a.env.NEXT_PUBLIC_PROMPTFOO_BUILD_STANDALONE_SERVER,i=!!a.env.NEXT_PUBLIC_PROMPTFOO_USE_SUPABASE,l=""},1938:function(e,t,n){"use strict";n.d(t,{o:function(){return i}});var a=n(4660),r=n(4810);let i=(0,a.Ue)()((0,r.tJ)((e,t)=>({env:{},testCases:[],description:"",providers:[],prompts:[],setEnv:t=>e({env:t}),setTestCases:t=>e({testCases:t}),setDescription:t=>e({description:t}),setProviders:t=>e({providers:t}),setPrompts:t=>e({prompts:t}),setStateFromConfig:t=>{let n={};t.description&&(n.description=t.description||""),t.tests&&(n.testCases=t.tests),t.providers&&(n.providers=t.providers),t.prompts&&("string"==typeof t.prompts?n.prompts=[t.prompts]:Array.isArray(t.prompts)?n.prompts=t.prompts.filter(e=>!e.endsWith(".txt")&&!e.endsWith(".json")&&!e.endsWith(".yaml")):console.warn("Invalid prompts config",t.prompts)),e(n)},getTestSuite:()=>{let{description:e,testCases:n,providers:a,prompts:r,env:i}=t();return{env:i,description:e,providers:a,prompts:r,tests:n}}}),{name:"promptfoo",skipHydration:!0}))},2280:function(){},695:function(){},284:function(){},5320:function(e,t){"use strict";t.It=void 0,t.It=function(e){let t={},n=[],a={};for(let[r,i]of Object.entries(e))r.startsWith("__expected")?""!==i.trim()&&n.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);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);return{type:"python",value:t}}let t=e.match(/^(not-)?(equals|contains-any|contains-all|icontains-any|icontains-all|contains-json|is-json|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+)?)\))?(?::(.*))?$/);if(t){let[e,n,a,r,i]=t,l=n?`not-${a}`:a,s=parseFloat(r);return"contains-any"===a||"contains-all"===a||"icontains-any"===a||"icontains-all"===a?{type:l,value:i.split(",").map(e=>e.trim())}:"contains-json"===a||"is-json"===a?{type:l}:"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:i,threshold:s||("similar"===a?.8:.75)}:{type:l,value:i}}return{type:"equals",value:e}}(i)):"__prefix"===r?a.prefix=i:"__suffix"===r?a.suffix=i:t[r]=i;return{vars:t,assert:n,options:a}}}},function(e){e.O(0,[293,808,548,420,975,886,683,339,376,971,596,744],function(){return e(e.s=3515)}),_N_E=e.O()}]);