@arizeai/phoenix-client 6.10.1 → 6.11.1

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 (214) hide show
  1. package/README.md +62 -0
  2. package/dist/esm/__generated__/api/v1.d.ts +254 -2
  3. package/dist/esm/__generated__/api/v1.d.ts.map +1 -1
  4. package/dist/esm/jest/index.d.ts +5 -0
  5. package/dist/esm/jest/index.d.ts.map +1 -0
  6. package/dist/esm/jest/index.js +49 -0
  7. package/dist/esm/jest/index.js.map +1 -0
  8. package/dist/esm/jest/reporter.d.ts +13 -0
  9. package/dist/esm/jest/reporter.d.ts.map +1 -0
  10. package/dist/esm/jest/reporter.js +19 -0
  11. package/dist/esm/jest/reporter.js.map +1 -0
  12. package/dist/esm/prompts/sdks/toAI.d.ts +2 -2
  13. package/dist/esm/prompts/sdks/toAI.d.ts.map +1 -1
  14. package/dist/esm/prompts/sdks/toAI.js.map +1 -1
  15. package/dist/esm/prompts/sdks/toAnthropic.d.ts +2 -2
  16. package/dist/esm/prompts/sdks/toAnthropic.d.ts.map +1 -1
  17. package/dist/esm/prompts/sdks/toAnthropic.js.map +1 -1
  18. package/dist/esm/prompts/sdks/toOpenAI.d.ts +2 -2
  19. package/dist/esm/prompts/sdks/toOpenAI.d.ts.map +1 -1
  20. package/dist/esm/prompts/sdks/toOpenAI.js.map +1 -1
  21. package/dist/esm/prompts/sdks/toSDK.d.ts +8 -8
  22. package/dist/esm/prompts/sdks/toSDK.d.ts.map +1 -1
  23. package/dist/esm/prompts/sdks/toSDK.js.map +1 -1
  24. package/dist/esm/prompts/sdks/types.d.ts +2 -2
  25. package/dist/esm/prompts/sdks/types.d.ts.map +1 -1
  26. package/dist/esm/schemas/llm/anthropic/converters.d.ts +8 -8
  27. package/dist/esm/schemas/llm/anthropic/messagePartSchemas.d.ts +4 -4
  28. package/dist/esm/schemas/llm/anthropic/messageSchemas.d.ts +6 -6
  29. package/dist/esm/schemas/llm/constants.d.ts +3 -3
  30. package/dist/esm/schemas/llm/converters.d.ts +12 -12
  31. package/dist/esm/schemas/llm/openai/converters.d.ts +3 -3
  32. package/dist/esm/schemas/llm/schemas.d.ts +2 -2
  33. package/dist/esm/testing/acceptance.d.ts +20 -0
  34. package/dist/esm/testing/acceptance.d.ts.map +1 -0
  35. package/dist/esm/testing/acceptance.js +129 -0
  36. package/dist/esm/testing/acceptance.js.map +1 -0
  37. package/dist/esm/testing/define-api.d.ts +157 -0
  38. package/dist/esm/testing/define-api.d.ts.map +1 -0
  39. package/dist/esm/testing/define-api.js +78 -0
  40. package/dist/esm/testing/define-api.js.map +1 -0
  41. package/dist/esm/testing/helpers.d.ts +55 -0
  42. package/dist/esm/testing/helpers.d.ts.map +1 -0
  43. package/dist/esm/testing/helpers.js +179 -0
  44. package/dist/esm/testing/helpers.js.map +1 -0
  45. package/dist/esm/testing/phoenix-test-tracking.d.ts +68 -0
  46. package/dist/esm/testing/phoenix-test-tracking.d.ts.map +1 -0
  47. package/dist/esm/testing/phoenix-test-tracking.js +521 -0
  48. package/dist/esm/testing/phoenix-test-tracking.js.map +1 -0
  49. package/dist/esm/testing/report-artifacts.d.ts +45 -0
  50. package/dist/esm/testing/report-artifacts.d.ts.map +1 -0
  51. package/dist/esm/testing/report-artifacts.js +218 -0
  52. package/dist/esm/testing/report-artifacts.js.map +1 -0
  53. package/dist/esm/testing/report-run.d.ts +22 -0
  54. package/dist/esm/testing/report-run.d.ts.map +1 -0
  55. package/dist/esm/testing/report-run.js +41 -0
  56. package/dist/esm/testing/report-run.js.map +1 -0
  57. package/dist/esm/testing/reporter-format.d.ts +83 -0
  58. package/dist/esm/testing/reporter-format.d.ts.map +1 -0
  59. package/dist/esm/testing/reporter-format.js +852 -0
  60. package/dist/esm/testing/reporter-format.js.map +1 -0
  61. package/dist/esm/testing/runner.d.ts +31 -0
  62. package/dist/esm/testing/runner.d.ts.map +1 -0
  63. package/dist/esm/testing/runner.js +238 -0
  64. package/dist/esm/testing/runner.js.map +1 -0
  65. package/dist/esm/testing/state.d.ts +138 -0
  66. package/dist/esm/testing/state.d.ts.map +1 -0
  67. package/dist/esm/testing/state.js +31 -0
  68. package/dist/esm/testing/state.js.map +1 -0
  69. package/dist/esm/testing/types.d.ts +319 -0
  70. package/dist/esm/testing/types.d.ts.map +1 -0
  71. package/dist/esm/testing/types.js +9 -0
  72. package/dist/esm/testing/types.js.map +1 -0
  73. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  74. package/dist/esm/utils/channel.d.ts +7 -7
  75. package/dist/esm/utils/channel.d.ts.map +1 -1
  76. package/dist/esm/utils/channel.js +1 -1
  77. package/dist/esm/utils/channel.js.map +1 -1
  78. package/dist/esm/utils/formatPromptMessages.d.ts.map +1 -1
  79. package/dist/esm/utils/getPromptBySelector.d.ts.map +1 -1
  80. package/dist/esm/utils/promisifyResult.d.ts +1 -1
  81. package/dist/esm/utils/promisifyResult.d.ts.map +1 -1
  82. package/dist/esm/utils/promisifyResult.js.map +1 -1
  83. package/dist/esm/utils/schemaMatches.d.ts +5 -5
  84. package/dist/esm/utils/schemaMatches.d.ts.map +1 -1
  85. package/dist/esm/utils/schemaMatches.js.map +1 -1
  86. package/dist/esm/vitest/index.d.ts +5 -0
  87. package/dist/esm/vitest/index.d.ts.map +1 -0
  88. package/dist/esm/vitest/index.js +15 -0
  89. package/dist/esm/vitest/index.js.map +1 -0
  90. package/dist/esm/vitest/reporter.d.ts +19 -0
  91. package/dist/esm/vitest/reporter.d.ts.map +1 -0
  92. package/dist/esm/vitest/reporter.js +27 -0
  93. package/dist/esm/vitest/reporter.js.map +1 -0
  94. package/dist/src/__generated__/api/v1.d.ts +254 -2
  95. package/dist/src/__generated__/api/v1.d.ts.map +1 -1
  96. package/dist/src/jest/index.d.ts +5 -0
  97. package/dist/src/jest/index.d.ts.map +1 -0
  98. package/dist/src/jest/index.js +58 -0
  99. package/dist/src/jest/index.js.map +1 -0
  100. package/dist/src/jest/reporter.d.ts +13 -0
  101. package/dist/src/jest/reporter.d.ts.map +1 -0
  102. package/dist/src/jest/reporter.js +23 -0
  103. package/dist/src/jest/reporter.js.map +1 -0
  104. package/dist/src/prompts/sdks/toAI.d.ts +2 -2
  105. package/dist/src/prompts/sdks/toAI.d.ts.map +1 -1
  106. package/dist/src/prompts/sdks/toAI.js.map +1 -1
  107. package/dist/src/prompts/sdks/toAnthropic.d.ts +2 -2
  108. package/dist/src/prompts/sdks/toAnthropic.d.ts.map +1 -1
  109. package/dist/src/prompts/sdks/toAnthropic.js.map +1 -1
  110. package/dist/src/prompts/sdks/toOpenAI.d.ts +2 -2
  111. package/dist/src/prompts/sdks/toOpenAI.d.ts.map +1 -1
  112. package/dist/src/prompts/sdks/toOpenAI.js.map +1 -1
  113. package/dist/src/prompts/sdks/toSDK.d.ts +8 -8
  114. package/dist/src/prompts/sdks/toSDK.d.ts.map +1 -1
  115. package/dist/src/prompts/sdks/toSDK.js.map +1 -1
  116. package/dist/src/prompts/sdks/types.d.ts +2 -2
  117. package/dist/src/prompts/sdks/types.d.ts.map +1 -1
  118. package/dist/src/schemas/llm/anthropic/converters.d.ts +8 -8
  119. package/dist/src/schemas/llm/anthropic/messagePartSchemas.d.ts +4 -4
  120. package/dist/src/schemas/llm/anthropic/messageSchemas.d.ts +6 -6
  121. package/dist/src/schemas/llm/constants.d.ts +3 -3
  122. package/dist/src/schemas/llm/converters.d.ts +12 -12
  123. package/dist/src/schemas/llm/openai/converters.d.ts +3 -3
  124. package/dist/src/schemas/llm/schemas.d.ts +2 -2
  125. package/dist/src/testing/acceptance.d.ts +20 -0
  126. package/dist/src/testing/acceptance.d.ts.map +1 -0
  127. package/dist/src/testing/acceptance.js +114 -0
  128. package/dist/src/testing/acceptance.js.map +1 -0
  129. package/dist/src/testing/define-api.d.ts +157 -0
  130. package/dist/src/testing/define-api.d.ts.map +1 -0
  131. package/dist/src/testing/define-api.js +81 -0
  132. package/dist/src/testing/define-api.js.map +1 -0
  133. package/dist/src/testing/helpers.d.ts +55 -0
  134. package/dist/src/testing/helpers.d.ts.map +1 -0
  135. package/dist/src/testing/helpers.js +182 -0
  136. package/dist/src/testing/helpers.js.map +1 -0
  137. package/dist/src/testing/phoenix-test-tracking.d.ts +68 -0
  138. package/dist/src/testing/phoenix-test-tracking.d.ts.map +1 -0
  139. package/dist/src/testing/phoenix-test-tracking.js +530 -0
  140. package/dist/src/testing/phoenix-test-tracking.js.map +1 -0
  141. package/dist/src/testing/report-artifacts.d.ts +45 -0
  142. package/dist/src/testing/report-artifacts.d.ts.map +1 -0
  143. package/dist/src/testing/report-artifacts.js +225 -0
  144. package/dist/src/testing/report-artifacts.js.map +1 -0
  145. package/dist/src/testing/report-run.d.ts +22 -0
  146. package/dist/src/testing/report-run.d.ts.map +1 -0
  147. package/dist/src/testing/report-run.js +47 -0
  148. package/dist/src/testing/report-run.js.map +1 -0
  149. package/dist/src/testing/reporter-format.d.ts +83 -0
  150. package/dist/src/testing/reporter-format.d.ts.map +1 -0
  151. package/dist/src/testing/reporter-format.js +870 -0
  152. package/dist/src/testing/reporter-format.js.map +1 -0
  153. package/dist/src/testing/runner.d.ts +31 -0
  154. package/dist/src/testing/runner.d.ts.map +1 -0
  155. package/dist/src/testing/runner.js +258 -0
  156. package/dist/src/testing/runner.js.map +1 -0
  157. package/dist/src/testing/state.d.ts +138 -0
  158. package/dist/src/testing/state.d.ts.map +1 -0
  159. package/dist/src/testing/state.js +38 -0
  160. package/dist/src/testing/state.js.map +1 -0
  161. package/dist/src/testing/types.d.ts +319 -0
  162. package/dist/src/testing/types.d.ts.map +1 -0
  163. package/dist/src/testing/types.js +13 -0
  164. package/dist/src/testing/types.js.map +1 -0
  165. package/dist/src/utils/channel.d.ts +7 -7
  166. package/dist/src/utils/channel.d.ts.map +1 -1
  167. package/dist/src/utils/channel.js +1 -1
  168. package/dist/src/utils/channel.js.map +1 -1
  169. package/dist/src/utils/formatPromptMessages.d.ts.map +1 -1
  170. package/dist/src/utils/getPromptBySelector.d.ts.map +1 -1
  171. package/dist/src/utils/promisifyResult.d.ts +1 -1
  172. package/dist/src/utils/promisifyResult.d.ts.map +1 -1
  173. package/dist/src/utils/promisifyResult.js.map +1 -1
  174. package/dist/src/utils/schemaMatches.d.ts +5 -5
  175. package/dist/src/utils/schemaMatches.d.ts.map +1 -1
  176. package/dist/src/utils/schemaMatches.js.map +1 -1
  177. package/dist/src/vitest/index.d.ts +5 -0
  178. package/dist/src/vitest/index.d.ts.map +1 -0
  179. package/dist/src/vitest/index.js +23 -0
  180. package/dist/src/vitest/index.js.map +1 -0
  181. package/dist/src/vitest/reporter.d.ts +19 -0
  182. package/dist/src/vitest/reporter.d.ts.map +1 -0
  183. package/dist/src/vitest/reporter.js +34 -0
  184. package/dist/src/vitest/reporter.js.map +1 -0
  185. package/dist/tsconfig.tsbuildinfo +1 -1
  186. package/docs/ci-evals-annotations.mdx +190 -0
  187. package/docs/ci-evals-jest.mdx +78 -0
  188. package/docs/ci-evals-vitest.mdx +240 -0
  189. package/docs/ci-evals.mdx +263 -0
  190. package/docs/overview.mdx +9 -1
  191. package/package.json +49 -17
  192. package/src/__generated__/api/v1.ts +254 -2
  193. package/src/jest/index.ts +124 -0
  194. package/src/jest/reporter.ts +22 -0
  195. package/src/prompts/sdks/toAI.ts +4 -3
  196. package/src/prompts/sdks/toAnthropic.ts +4 -3
  197. package/src/prompts/sdks/toOpenAI.ts +4 -3
  198. package/src/prompts/sdks/toSDK.ts +16 -11
  199. package/src/prompts/sdks/types.ts +2 -2
  200. package/src/testing/acceptance.ts +190 -0
  201. package/src/testing/define-api.ts +279 -0
  202. package/src/testing/helpers.ts +251 -0
  203. package/src/testing/phoenix-test-tracking.ts +637 -0
  204. package/src/testing/report-artifacts.ts +272 -0
  205. package/src/testing/report-run.ts +44 -0
  206. package/src/testing/reporter-format.ts +1072 -0
  207. package/src/testing/runner.ts +350 -0
  208. package/src/testing/state.ts +165 -0
  209. package/src/testing/types.ts +366 -0
  210. package/src/utils/channel.ts +17 -15
  211. package/src/utils/promisifyResult.ts +6 -4
  212. package/src/utils/schemaMatches.ts +12 -10
  213. package/src/vitest/index.ts +57 -0
  214. package/src/vitest/reporter.ts +32 -0
@@ -381,7 +381,7 @@ export declare const safelyConvertMessageToProvider: <TargetProviderSDK extends
381
381
  type: "image";
382
382
  source: {
383
383
  data: string;
384
- media_type: "image/jpeg" | "image/png" | "image/gif" | "image/webp";
384
+ media_type: "image/gif" | "image/jpeg" | "image/png" | "image/webp";
385
385
  type: "base64";
386
386
  };
387
387
  } | {
@@ -394,7 +394,7 @@ export declare const safelyConvertMessageToProvider: <TargetProviderSDK extends
394
394
  type: "image";
395
395
  source: {
396
396
  data: string;
397
- media_type: "image/jpeg" | "image/png" | "image/gif" | "image/webp";
397
+ media_type: "image/gif" | "image/jpeg" | "image/png" | "image/webp";
398
398
  type: "base64";
399
399
  };
400
400
  })[];
@@ -476,7 +476,7 @@ export declare const safelyConvertMessageToProvider: <TargetProviderSDK extends
476
476
  type: "image";
477
477
  source: {
478
478
  data: string;
479
- media_type: "image/jpeg" | "image/png" | "image/gif" | "image/webp";
479
+ media_type: "image/gif" | "image/jpeg" | "image/png" | "image/webp";
480
480
  type: "base64";
481
481
  };
482
482
  text?: undefined;
@@ -1384,7 +1384,7 @@ export declare const safelyConvertToolCallToProvider: <TargetProviderSDK extends
1384
1384
  type: "image";
1385
1385
  source: {
1386
1386
  data: string;
1387
- media_type: "image/jpeg" | "image/png" | "image/gif" | "image/webp";
1387
+ media_type: "image/gif" | "image/jpeg" | "image/png" | "image/webp";
1388
1388
  type: "base64";
1389
1389
  };
1390
1390
  } | {
@@ -1397,7 +1397,7 @@ export declare const safelyConvertToolCallToProvider: <TargetProviderSDK extends
1397
1397
  type: "image";
1398
1398
  source: {
1399
1399
  data: string;
1400
- media_type: "image/jpeg" | "image/png" | "image/gif" | "image/webp";
1400
+ media_type: "image/gif" | "image/jpeg" | "image/png" | "image/webp";
1401
1401
  type: "base64";
1402
1402
  };
1403
1403
  })[];
@@ -1479,7 +1479,7 @@ export declare const safelyConvertToolCallToProvider: <TargetProviderSDK extends
1479
1479
  type: "image";
1480
1480
  source: {
1481
1481
  data: string;
1482
- media_type: "image/jpeg" | "image/png" | "image/gif" | "image/webp";
1482
+ media_type: "image/gif" | "image/jpeg" | "image/png" | "image/webp";
1483
1483
  type: "base64";
1484
1484
  };
1485
1485
  text?: undefined;
@@ -2387,7 +2387,7 @@ export declare const safelyConvertToolDefinitionToProvider: <TargetProviderSDK e
2387
2387
  type: "image";
2388
2388
  source: {
2389
2389
  data: string;
2390
- media_type: "image/jpeg" | "image/png" | "image/gif" | "image/webp";
2390
+ media_type: "image/gif" | "image/jpeg" | "image/png" | "image/webp";
2391
2391
  type: "base64";
2392
2392
  };
2393
2393
  } | {
@@ -2400,7 +2400,7 @@ export declare const safelyConvertToolDefinitionToProvider: <TargetProviderSDK e
2400
2400
  type: "image";
2401
2401
  source: {
2402
2402
  data: string;
2403
- media_type: "image/jpeg" | "image/png" | "image/gif" | "image/webp";
2403
+ media_type: "image/gif" | "image/jpeg" | "image/png" | "image/webp";
2404
2404
  type: "base64";
2405
2405
  };
2406
2406
  })[];
@@ -2482,7 +2482,7 @@ export declare const safelyConvertToolDefinitionToProvider: <TargetProviderSDK e
2482
2482
  type: "image";
2483
2483
  source: {
2484
2484
  data: string;
2485
- media_type: "image/jpeg" | "image/png" | "image/gif" | "image/webp";
2485
+ media_type: "image/gif" | "image/jpeg" | "image/png" | "image/webp";
2486
2486
  type: "base64";
2487
2487
  };
2488
2488
  text?: undefined;
@@ -3390,7 +3390,7 @@ export declare const safelyConvertToolChoiceToProvider: <TargetProviderSDK exten
3390
3390
  type: "image";
3391
3391
  source: {
3392
3392
  data: string;
3393
- media_type: "image/jpeg" | "image/png" | "image/gif" | "image/webp";
3393
+ media_type: "image/gif" | "image/jpeg" | "image/png" | "image/webp";
3394
3394
  type: "base64";
3395
3395
  };
3396
3396
  } | {
@@ -3403,7 +3403,7 @@ export declare const safelyConvertToolChoiceToProvider: <TargetProviderSDK exten
3403
3403
  type: "image";
3404
3404
  source: {
3405
3405
  data: string;
3406
- media_type: "image/jpeg" | "image/png" | "image/gif" | "image/webp";
3406
+ media_type: "image/gif" | "image/jpeg" | "image/png" | "image/webp";
3407
3407
  type: "base64";
3408
3408
  };
3409
3409
  })[];
@@ -3485,7 +3485,7 @@ export declare const safelyConvertToolChoiceToProvider: <TargetProviderSDK exten
3485
3485
  type: "image";
3486
3486
  source: {
3487
3487
  data: string;
3488
- media_type: "image/jpeg" | "image/png" | "image/gif" | "image/webp";
3488
+ media_type: "image/gif" | "image/jpeg" | "image/png" | "image/webp";
3489
3489
  type: "base64";
3490
3490
  };
3491
3491
  text?: undefined;
@@ -14,7 +14,7 @@ export declare const openAIChatPartToAnthropic: import("zod").ZodPipe<import("zo
14
14
  type: "image";
15
15
  source: {
16
16
  data: string;
17
- media_type: "image/jpeg" | "image/png" | "image/gif" | "image/webp";
17
+ media_type: "image/gif" | "image/jpeg" | "image/png" | "image/webp";
18
18
  type: "base64";
19
19
  };
20
20
  text?: undefined;
@@ -98,7 +98,7 @@ export declare const openAIMessageToAnthropic: import("zod").ZodPipe<import("zod
98
98
  type: "image";
99
99
  source: {
100
100
  data: string;
101
- media_type: "image/jpeg" | "image/png" | "image/gif" | "image/webp";
101
+ media_type: "image/gif" | "image/jpeg" | "image/png" | "image/webp";
102
102
  type: "base64";
103
103
  };
104
104
  } | {
@@ -111,7 +111,7 @@ export declare const openAIMessageToAnthropic: import("zod").ZodPipe<import("zod
111
111
  type: "image";
112
112
  source: {
113
113
  data: string;
114
- media_type: "image/jpeg" | "image/png" | "image/gif" | "image/webp";
114
+ media_type: "image/gif" | "image/jpeg" | "image/png" | "image/webp";
115
115
  type: "base64";
116
116
  };
117
117
  })[];
@@ -68,9 +68,9 @@ export declare const llmProviderMessageSchema: z.ZodUnion<readonly [z.ZodDiscrim
68
68
  source: z.ZodObject<{
69
69
  data: z.ZodString;
70
70
  media_type: z.ZodEnum<{
71
+ "image/gif": "image/gif";
71
72
  "image/jpeg": "image/jpeg";
72
73
  "image/png": "image/png";
73
- "image/gif": "image/gif";
74
74
  "image/webp": "image/webp";
75
75
  }>;
76
76
  type: z.ZodLiteral<"base64">;
@@ -91,9 +91,9 @@ export declare const llmProviderMessageSchema: z.ZodUnion<readonly [z.ZodDiscrim
91
91
  source: z.ZodObject<{
92
92
  data: z.ZodString;
93
93
  media_type: z.ZodEnum<{
94
+ "image/gif": "image/gif";
94
95
  "image/jpeg": "image/jpeg";
95
96
  "image/png": "image/png";
96
- "image/gif": "image/gif";
97
97
  "image/webp": "image/webp";
98
98
  }>;
99
99
  type: z.ZodLiteral<"base64">;
@@ -0,0 +1,20 @@
1
+ import type { TestResult } from "./state";
2
+ import type { AcceptanceCriterion, AcceptanceResult } from "./types";
3
+ /**
4
+ * Evaluate all configured aggregate acceptance rules against completed runs.
5
+ * @param params - Evaluation parameters.
6
+ * @param params.criteria - Aggregate rules configured on the suite.
7
+ * @param params.results - Completed test results in the suite.
8
+ */
9
+ export declare function evaluateAcceptanceCriteria({ criteria, results, }: {
10
+ criteria: readonly AcceptanceCriterion[] | undefined;
11
+ results: readonly TestResult[];
12
+ }): AcceptanceResult[];
13
+ /**
14
+ * Build one error containing every failed aggregate criterion.
15
+ * @param results - Computed acceptance results.
16
+ */
17
+ export declare function createAcceptanceFailureError(results: readonly AcceptanceResult[]): Error | undefined;
18
+ /** Format an acceptance result for reporters and thrown errors. */
19
+ export declare function formatAcceptanceResult(result: AcceptanceResult): string;
20
+ //# sourceMappingURL=acceptance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acceptance.d.ts","sourceRoot":"","sources":["../../../src/testing/acceptance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAGjB,MAAM,SAAS,CAAC;AAEjB;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,EACzC,QAAQ,EACR,OAAO,GACR,EAAE;IACD,QAAQ,EAAE,SAAS,mBAAmB,EAAE,GAAG,SAAS,CAAC;IACrD,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;CAChC,GAAG,gBAAgB,EAAE,CAOrB;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,SAAS,gBAAgB,EAAE,GACnC,KAAK,GAAG,SAAS,CAWnB;AAED,mEAAmE;AACnE,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAavE"}
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.evaluateAcceptanceCriteria = evaluateAcceptanceCriteria;
4
+ exports.createAcceptanceFailureError = createAcceptanceFailureError;
5
+ exports.formatAcceptanceResult = formatAcceptanceResult;
6
+ /**
7
+ * Evaluate all configured aggregate acceptance rules against completed runs.
8
+ * @param params - Evaluation parameters.
9
+ * @param params.criteria - Aggregate rules configured on the suite.
10
+ * @param params.results - Completed test results in the suite.
11
+ */
12
+ function evaluateAcceptanceCriteria({ criteria, results, }) {
13
+ if (!criteria || criteria.length === 0) {
14
+ return [];
15
+ }
16
+ return criteria.map((criterion) => evaluateAcceptanceCriterion({ criterion, results }));
17
+ }
18
+ /**
19
+ * Build one error containing every failed aggregate criterion.
20
+ * @param results - Computed acceptance results.
21
+ */
22
+ function createAcceptanceFailureError(results) {
23
+ const failedResults = results.filter((result) => !result.passed);
24
+ if (failedResults.length === 0) {
25
+ return undefined;
26
+ }
27
+ return new Error([
28
+ "Acceptance criteria failed:",
29
+ ...failedResults.map((result) => ` ${formatAcceptanceResult(result)}`),
30
+ ].join("\n"));
31
+ }
32
+ /** Format an acceptance result for reporters and thrown errors. */
33
+ function formatAcceptanceResult(result) {
34
+ var _a;
35
+ const status = result.passed ? "PASS" : "FAIL";
36
+ const value = result.value === null ? "n/a" : result.value.toFixed(3);
37
+ const sampleLabel = result.sampleCount === 1 ? "sample" : "samples";
38
+ let requirement;
39
+ if (result.metric === "average") {
40
+ const cmp = ((_a = result.direction) !== null && _a !== void 0 ? _a : "maximize") === "minimize" ? "<=" : ">=";
41
+ requirement = `mean ${cmp} ${result.threshold.toFixed(3)}`;
42
+ }
43
+ else {
44
+ requirement = `pass rate >= ${result.minPassRate.toFixed(3)}`;
45
+ }
46
+ const reason = result.failureReason ? ` - ${result.failureReason}` : "";
47
+ return `${status} ${result.annotationName} ${result.metric} ${value} (need ${requirement}; ${result.sampleCount} ${sampleLabel})${reason}`;
48
+ }
49
+ function evaluateAcceptanceCriterion({ criterion, results, }) {
50
+ var _a;
51
+ const annotations = collectAnnotations({ criterion, results });
52
+ if (criterion.metric === "average") {
53
+ // Only numeric / boolean scores can be averaged.
54
+ const scores = annotations
55
+ .map((annotation) => annotation.score)
56
+ .filter(isValidScore);
57
+ if (scores.length === 0) {
58
+ return Object.assign(Object.assign({}, criterion), { value: null, sampleCount: 0, passed: false, failureReason: "no numeric or boolean scores found" });
59
+ }
60
+ const direction = (_a = criterion.direction) !== null && _a !== void 0 ? _a : "maximize";
61
+ const value = calculateAverage(scores);
62
+ return Object.assign(Object.assign({}, criterion), { value, sampleCount: scores.length, passed: meetsBar(value, criterion.threshold, direction) });
63
+ }
64
+ // passRate: each run passes when `passFn` returns true for its annotation;
65
+ // the suite passes when the fraction of passing runs is at least
66
+ // `minPassRate`. The reported value is that fraction.
67
+ if (annotations.length === 0) {
68
+ return Object.assign(Object.assign({}, criterion), { value: null, sampleCount: 0, passed: false, failureReason: "no matching annotations found" });
69
+ }
70
+ const passed = annotations.filter((annotation) => criterion.passFn(annotation)).length;
71
+ const value = passed / annotations.length;
72
+ return Object.assign(Object.assign({}, criterion), { value, sampleCount: annotations.length, passed: value >= criterion.minPassRate });
73
+ }
74
+ /** Whether `value` clears `bar` in the given optimization direction. */
75
+ function meetsBar(value, bar, direction) {
76
+ return direction === "minimize" ? value <= bar : value >= bar;
77
+ }
78
+ /**
79
+ * The last annotation matching `annotationName` from each non-skipped run that
80
+ * logged it. One entry per run; runs that never logged the annotation are
81
+ * omitted.
82
+ */
83
+ function collectAnnotations({ criterion, results, }) {
84
+ return results
85
+ .filter((result) => result.status !== "skipped")
86
+ .map((result) => findLastAnnotation({
87
+ annotations: result.annotations,
88
+ annotationName: criterion.annotationName,
89
+ }))
90
+ .filter((annotation) => annotation !== undefined);
91
+ }
92
+ function findLastAnnotation({ annotations, annotationName, }) {
93
+ for (let annotationIndex = annotations.length - 1; annotationIndex >= 0; annotationIndex--) {
94
+ const annotation = annotations[annotationIndex];
95
+ if ((annotation === null || annotation === void 0 ? void 0 : annotation.name) === annotationName) {
96
+ return annotation;
97
+ }
98
+ }
99
+ return undefined;
100
+ }
101
+ function isValidScore(score) {
102
+ return (typeof score === "boolean" ||
103
+ (typeof score === "number" && Number.isFinite(score)));
104
+ }
105
+ function calculateAverage(scores) {
106
+ const total = scores
107
+ .map(scoreToNumber)
108
+ .reduce((sum, score) => sum + score, 0);
109
+ return total / scores.length;
110
+ }
111
+ function scoreToNumber(score) {
112
+ return typeof score === "boolean" ? (score ? 1 : 0) : score;
113
+ }
114
+ //# sourceMappingURL=acceptance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acceptance.js","sourceRoot":"","sources":["../../../src/testing/acceptance.ts"],"names":[],"mappings":";;AAcA,gEAaC;AAMD,oEAaC;AAGD,wDAaC;AAtDD;;;;;GAKG;AACH,SAAgB,0BAA0B,CAAC,EACzC,QAAQ,EACR,OAAO,GAIR;IACC,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvC,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAChC,2BAA2B,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CACpD,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAgB,4BAA4B,CAC1C,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,EACjB,CAAC;QACD,MAAM,UAAU,GAAG,WAAW,CAAC,eAAe,CAAC,CAAC;QAChD,IAAI,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,IAAI,MAAK,cAAc,EAAE,CAAC;YACxC,OAAO,UAAU,CAAC;QACpB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,YAAY,CAAC,KAA0B;IAC9C,OAAO,CACL,OAAO,KAAK,KAAK,SAAS;QAC1B,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CACtD,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,MAAqC;IAC7D,MAAM,KAAK,GAAG,MAAM;SACjB,GAAG,CAAC,aAAa,CAAC;SAClB,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC;IAC1C,OAAO,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;AAC/B,CAAC;AAED,SAAS,aAAa,CAAC,KAAuB;IAC5C,OAAO,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC9D,CAAC"}
@@ -0,0 +1,157 @@
1
+ import { type RunnerHooks } from "./runner";
2
+ import { type KVMap, type SuiteConfig, type TestEachRow, type TestFn, type TestParams } from "./types";
3
+ /**
4
+ * Declare Phoenix eval test suites.
5
+ *
6
+ * Drop-in replacement for the test runner's own `describe`. The suite name
7
+ * doubles as the dataset and experiment name on the Phoenix server, and the
8
+ * optional {@link SuiteConfig} controls dataset naming, repetitions, dry-run
9
+ * mode, and CI acceptance criteria.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import * as px from "@arizeai/phoenix-client/vitest";
14
+ *
15
+ * px.describe("generate sql demo", () => {
16
+ * px.test("offtopic input", { input: { question: "hi" } }, async ({ input }) => {
17
+ * // ...
18
+ * });
19
+ * }, { metadata: { model: "gpt-4o-mini" } });
20
+ * ```
21
+ */
22
+ export interface PhoenixDescribe {
23
+ /**
24
+ * Declare a Phoenix eval test suite.
25
+ *
26
+ * @param name - Suite name; doubles as the dataset / experiment name on Phoenix.
27
+ * @param fn - Suite body that declares its `test` / `it` cases.
28
+ * @param config - Optional suite-level config (dataset name, repetitions, dry-run, acceptance criteria).
29
+ */
30
+ (name: string, fn: () => void, config?: SuiteConfig): void;
31
+ /**
32
+ * Run only this suite, skipping all sibling suites
33
+ * (matches the runner's `describe.only`).
34
+ *
35
+ * @param name - Suite name; doubles as the dataset / experiment name on Phoenix.
36
+ * @param fn - Suite body that declares its `test` / `it` cases.
37
+ * @param config - Optional suite-level config.
38
+ */
39
+ only(name: string, fn: () => void, config?: SuiteConfig): void;
40
+ /**
41
+ * Skip this suite entirely (matches the runner's `describe.skip`). No dataset
42
+ * or experiment is created on Phoenix.
43
+ *
44
+ * @param name - Suite name; doubles as the dataset / experiment name on Phoenix.
45
+ * @param fn - Suite body (not executed).
46
+ * @param config - Optional suite-level config.
47
+ */
48
+ skip(name: string, fn: () => void, config?: SuiteConfig): void;
49
+ }
50
+ /**
51
+ * The test body returned by {@link PhoenixTest.each} after a table is bound.
52
+ *
53
+ * @param name - Test name, or a template (`%i` / `%s` / `%j`), or a function
54
+ * that derives the name from the row and its index.
55
+ * @param fn - The test handler, run once per row in the bound table.
56
+ * @param timeout - Optional per-test timeout in milliseconds.
57
+ */
58
+ export type PhoenixTestEach<Input extends KVMap = KVMap, Expected extends KVMap = KVMap> = (name: string | ((row: TestEachRow<Input, Expected>, index: number) => string), fn: TestFn<Input, Expected>, timeout?: number) => void;
59
+ /**
60
+ * Declare a single Phoenix eval test case.
61
+ *
62
+ * Drop-in replacement for the test runner's own `test` / `it`. The `params`
63
+ * argument carries the `input` and the reference output (`expected` /
64
+ * `reference` / `output`) that become the dataset example; whatever the handler
65
+ * returns (or passes to `logOutput()`) is recorded as the experiment run's
66
+ * output and made available to evaluators.
67
+ *
68
+ * `it` is the canonical alias for `test`; the two are identical.
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * px.test(
73
+ * "summarizes the article",
74
+ * { input: { article }, expected: { summary } },
75
+ * async ({ input, expected }) => {
76
+ * const output = await summarize(input.article);
77
+ * px.logOutput(output);
78
+ * await px.evaluate({ name: "matches", evaluate: () => output === expected.summary });
79
+ * }
80
+ * );
81
+ * ```
82
+ */
83
+ export interface PhoenixTest {
84
+ /**
85
+ * Declare a single Phoenix eval test case.
86
+ *
87
+ * @param name - Test case name; doubles as the dataset example label.
88
+ * @param params - Inline `input` and reference output that become the dataset example.
89
+ * @param fn - Test handler; receives `{ input, expected, metadata }`.
90
+ * @param timeout - Optional per-test timeout in milliseconds.
91
+ */
92
+ <Input extends KVMap = KVMap, Expected extends KVMap = KVMap>(name: string, params: TestParams<Input, Expected>, fn: TestFn<Input, Expected>, timeout?: number): void;
93
+ /**
94
+ * Run only this test case, skipping its siblings
95
+ * (matches the runner's `test.only`).
96
+ *
97
+ * @param name - Test case name; doubles as the dataset example label.
98
+ * @param params - Inline `input` and reference output that become the dataset example.
99
+ * @param fn - Test handler; receives `{ input, expected, metadata }`.
100
+ * @param timeout - Optional per-test timeout in milliseconds.
101
+ */
102
+ only<Input extends KVMap = KVMap, Expected extends KVMap = KVMap>(name: string, params: TestParams<Input, Expected>, fn: TestFn<Input, Expected>, timeout?: number): void;
103
+ /**
104
+ * Skip this test case (matches the runner's `test.skip`). No dataset example
105
+ * or experiment run is created on Phoenix.
106
+ *
107
+ * @param name - Test case name; doubles as the dataset example label.
108
+ * @param params - Inline `input` and reference output (not used while skipped).
109
+ * @param fn - Test handler (not executed).
110
+ * @param timeout - Optional per-test timeout in milliseconds.
111
+ */
112
+ skip<Input extends KVMap = KVMap, Expected extends KVMap = KVMap>(name: string, params: TestParams<Input, Expected>, fn: TestFn<Input, Expected>, timeout?: number): void;
113
+ /**
114
+ * Run the same test handler across many examples. Returns a function that
115
+ * takes a name (or template / name-builder) and the shared test body; each
116
+ * row in `table` becomes its own dataset example and experiment run.
117
+ *
118
+ * @param table - Rows of `{ input, expected?, metadata?, ... }` to fan out over.
119
+ * @returns A {@link PhoenixTestEach} that binds the name and shared handler.
120
+ *
121
+ * @example
122
+ * ```ts
123
+ * px.test.each([
124
+ * { input: { a: 1, b: 2 }, expected: { sum: 3 } },
125
+ * { input: { a: 2, b: 2 }, expected: { sum: 4 } },
126
+ * ])("adds %j", async ({ input, expected }) => {
127
+ * // ...
128
+ * });
129
+ * ```
130
+ */
131
+ each<Input extends KVMap, Expected extends KVMap>(table: TestEachRow<Input, Expected>[]): PhoenixTestEach<Input, Expected>;
132
+ }
133
+ /** The public testing surface returned by {@link createTestApi}. */
134
+ export interface PhoenixTestApi {
135
+ /** Declare a Phoenix eval test suite. See {@link PhoenixDescribe}. */
136
+ describe: PhoenixDescribe;
137
+ /** Declare a Phoenix eval test case. See {@link PhoenixTest}. */
138
+ test: PhoenixTest;
139
+ /** Canonical alias for {@link PhoenixTestApi.test}. */
140
+ it: PhoenixTest;
141
+ }
142
+ /**
143
+ * Build the public `describe`/`test`/`it` API for a runner adapter.
144
+ *
145
+ * Both the jest and vitest entrypoints expose the identical surface; the only
146
+ * thing that differs between them is how the {@link RunnerHooks} are obtained
147
+ * (vitest imports them statically, jest resolves them lazily from globals).
148
+ * That difference is captured by `getHooks`, which is invoked once per
149
+ * declaration so adapters are free to resolve hooks lazily.
150
+ *
151
+ * The JSDoc that surfaces in editors lives on the {@link PhoenixDescribe} and
152
+ * {@link PhoenixTest} interfaces rather than the implementations below, so the
153
+ * docs survive the `export const { describe, test, it } = createTestApi(...)`
154
+ * destructuring in each adapter.
155
+ */
156
+ export declare function createTestApi(getHooks: () => RunnerHooks): PhoenixTestApi;
157
+ //# sourceMappingURL=define-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":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8DzE"}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTestApi = createTestApi;
4
+ const runner_1 = require("./runner");
5
+ const types_1 = require("./types");
6
+ /**
7
+ * Build the public `describe`/`test`/`it` API for a runner adapter.
8
+ *
9
+ * Both the jest and vitest entrypoints expose the identical surface; the only
10
+ * thing that differs between them is how the {@link RunnerHooks} are obtained
11
+ * (vitest imports them statically, jest resolves them lazily from globals).
12
+ * That difference is captured by `getHooks`, which is invoked once per
13
+ * declaration so adapters are free to resolve hooks lazily.
14
+ *
15
+ * The JSDoc that surfaces in editors lives on the {@link PhoenixDescribe} and
16
+ * {@link PhoenixTest} interfaces rather than the implementations below, so the
17
+ * docs survive the `export const { describe, test, it } = createTestApi(...)`
18
+ * destructuring in each adapter.
19
+ */
20
+ function createTestApi(getHooks) {
21
+ const describe = ((name, fn, config) => {
22
+ (0, runner_1.declareDescribe)(getHooks(), name, fn, config !== null && config !== void 0 ? config : {});
23
+ });
24
+ describe.only = (name, fn, config) => {
25
+ (0, runner_1.declareDescribe)(getHooks(), name, fn, config !== null && config !== void 0 ? config : {}, "only");
26
+ };
27
+ describe.skip = (name, fn, config) => {
28
+ (0, runner_1.declareDescribe)(getHooks(), name, fn, config !== null && config !== void 0 ? config : {}, "skip");
29
+ };
30
+ const test = ((name, params, fn, timeout) => {
31
+ (0, runner_1.declareTest)(getHooks(), name, params, fn, "default", timeout);
32
+ });
33
+ test.only = (name, params, fn, timeout) => {
34
+ (0, runner_1.declareTest)(getHooks(), name, params, fn, "only", timeout);
35
+ };
36
+ test.skip = (name, params, fn, timeout) => {
37
+ (0, runner_1.declareTest)(getHooks(), name, params, fn, "skip", timeout);
38
+ };
39
+ test.each = (table) => {
40
+ return (name, fn, timeout) => {
41
+ table.forEach((row, i) => {
42
+ const testName = typeof name === "function"
43
+ ? name(row, i)
44
+ : interpolateName(name, row, i);
45
+ (0, runner_1.declareTest)(getHooks(), testName, {
46
+ id: row.id,
47
+ input: row.input,
48
+ expected: (0, types_1.resolveReference)(row),
49
+ metadata: row.metadata,
50
+ splits: row.splits,
51
+ repetitions: row.repetitions,
52
+ dryRun: row.dryRun,
53
+ }, fn, "default", timeout);
54
+ });
55
+ };
56
+ };
57
+ // `it` is the canonical alias for `test`.
58
+ const it = test;
59
+ return { describe, test, it };
60
+ }
61
+ /**
62
+ * Interpolate a `test.each` name template for a single row. Supports the
63
+ * common `%i`/`%s`/`%j` placeholders for surface parity with the underlying
64
+ * runners; when no placeholder is present the 1-based row index is appended.
65
+ */
66
+ function interpolateName(name, row, index) {
67
+ if (!name.includes("%")) {
68
+ return `${name} #${index + 1}`;
69
+ }
70
+ const replacements = [
71
+ [/%i/g, String(index)],
72
+ [/%s/g, JSON.stringify(row.input)],
73
+ [/%j/g, JSON.stringify(row)],
74
+ ];
75
+ let out = name;
76
+ for (const [pattern, value] of replacements) {
77
+ out = out.replace(pattern, value);
78
+ }
79
+ return out;
80
+ }
81
+ //# sourceMappingURL=define-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-api.js","sourceRoot":"","sources":["../../../src/testing/define-api.ts"],"names":[],"mappings":";;AA+LA,sCA8DC;AA7PD,qCAA0E;AAC1E,mCAOiB;AAyKjB;;;;;;;;;;;;;GAaG;AACH,SAAgB,aAAa,CAAC,QAA2B;IACvD,MAAM,QAAQ,GAAG,CAAC,CAChB,IAAY,EACZ,EAAc,EACd,MAAoB,EACd,EAAE;QACR,IAAA,wBAAe,EAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAC,CAAC;IACtD,CAAC,CAAoB,CAAC;IACtB,QAAQ,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE;QACnC,IAAA,wBAAe,EAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,aAAN,MAAM,cAAN,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,CAAC,OAAO,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACpC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { type SuiteState } from "./state";
2
+ import type { Annotation, EvaluationParams, EvaluationResult, Evaluator, KVMap } from "./types";
3
+ /**
4
+ * Log the output produced by the test for the current run.
5
+ *
6
+ * Calling this multiple times overwrites the previously recorded value.
7
+ * The argument can be any JSON-serializable value — typically an object
8
+ * matching the shape of the example's `expected` field.
9
+ */
10
+ export declare function logOutput(output: unknown): void;
11
+ /**
12
+ * Record an annotation on the current run.
13
+ *
14
+ * Annotations are collected during the test and posted to Phoenix as
15
+ * experiment evaluations after the test completes. The `name` is the
16
+ * Phoenix evaluation name; `score`, `label`, and `explanation` map to
17
+ * the standard Phoenix `EvaluationResult` fields.
18
+ *
19
+ * The annotation name `"pass"` is reserved — Phoenix eval tests always write
20
+ * a `pass` annotation derived from the test's assertion outcome, so a
21
+ * user-supplied annotation with that name would race / overwrite the
22
+ * built-in one. Such calls are silently ignored.
23
+ */
24
+ export declare function logAnnotation(annotation: Annotation): void;
25
+ /**
26
+ * Run an evaluator object against the current test run and record the result.
27
+ *
28
+ * The evaluator may come from `@arizeai/phoenix-evals.createEvaluator`,
29
+ * `asExperimentEvaluator`, or any plain object with `{ name, evaluate }`.
30
+ * When `params` is omitted, the current test's `input`, recorded `output`,
31
+ * `expected`, `metadata`, and task `traceId` are supplied.
32
+ */
33
+ export declare function evaluate<Params extends KVMap = EvaluationParams & KVMap, Result = EvaluationResult>(evaluator: Evaluator<Params, Result>, params?: Partial<Params> & KVMap): Promise<Result>;
34
+ /**
35
+ * Trace an evaluator function so its execution shows up as a separate
36
+ * `EVALUATOR` span in Phoenix and any `{ name, score }`-shaped return
37
+ * value is automatically captured as an annotation on the current run.
38
+ *
39
+ * The annotation name defaults to the traced function's name, falling
40
+ * back to `"evaluator"`.
41
+ */
42
+ export declare function traceEvaluator<EvaluatorParams extends KVMap, EvaluatorResult>(fn: (params: EvaluatorParams) => EvaluatorResult | Promise<EvaluatorResult>, options?: {
43
+ name?: string;
44
+ }): (params: EvaluatorParams) => Promise<EvaluatorResult>;
45
+ /**
46
+ * Internal: persist all collected annotations for the run.
47
+ *
48
+ * Phoenix's `experiment_evaluations` endpoint is keyed by
49
+ * `(experiment_run_id, name)` so two annotations with the same name on
50
+ * the same run race each other. We collapse duplicates by name (last
51
+ * wins) up front, which makes the final state deterministic; the
52
+ * remaining writes target distinct names, so they post in parallel.
53
+ */
54
+ export declare function flushAnnotations(runId: string | undefined, annotations: Annotation[], suite: SuiteState): Promise<void>;
55
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/testing/helpers.ts"],"names":[],"mappings":"AAKA,OAAO,EAAc,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AACtD,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAEhB,SAAS,EACT,KAAK,EACN,MAAM,SAAS,CAAC;AAEjB;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAU/C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAS1D;AAED;;;;;;;GAOG;AACH,wBAAsB,QAAQ,CAC5B,MAAM,SAAS,KAAK,GAAG,gBAAgB,GAAG,KAAK,EAC/C,MAAM,GAAG,gBAAgB,EAEzB,SAAS,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,EACpC,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,KAAK,GAC/B,OAAO,CAAC,MAAM,CAAC,CAoCjB;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,eAAe,SAAS,KAAK,EAAE,eAAe,EAC3E,EAAE,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,EAC3E,OAAO,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAC1B,CAAC,MAAM,EAAE,eAAe,KAAK,OAAO,CAAC,eAAe,CAAC,CAoBvD;AAqFD;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,WAAW,EAAE,UAAU,EAAE,EACzB,KAAK,EAAE,UAAU,GAChB,OAAO,CAAC,IAAI,CAAC,CAWf"}