@arizeai/phoenix-client 1.1.0 → 1.2.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 (67) hide show
  1. package/dist/esm/__generated__/api/v1.d.ts +375 -0
  2. package/dist/esm/__generated__/api/v1.d.ts.map +1 -1
  3. package/dist/esm/experiments/runExperiment.d.ts +48 -13
  4. package/dist/esm/experiments/runExperiment.d.ts.map +1 -1
  5. package/dist/esm/experiments/runExperiment.js +139 -36
  6. package/dist/esm/experiments/runExperiment.js.map +1 -1
  7. package/dist/esm/spans/addSpanAnnotation.d.ts +39 -0
  8. package/dist/esm/spans/addSpanAnnotation.d.ts.map +1 -0
  9. package/dist/esm/spans/addSpanAnnotation.js +44 -0
  10. package/dist/esm/spans/addSpanAnnotation.js.map +1 -0
  11. package/dist/esm/spans/index.d.ts +3 -0
  12. package/dist/esm/spans/index.d.ts.map +1 -0
  13. package/dist/esm/spans/index.js +3 -0
  14. package/dist/esm/spans/index.js.map +1 -0
  15. package/dist/esm/spans/logSpanAnnotations.d.ts +51 -0
  16. package/dist/esm/spans/logSpanAnnotations.d.ts.map +1 -0
  17. package/dist/esm/spans/logSpanAnnotations.js +53 -0
  18. package/dist/esm/spans/logSpanAnnotations.js.map +1 -0
  19. package/dist/esm/spans/types.d.ts +43 -0
  20. package/dist/esm/spans/types.d.ts.map +1 -0
  21. package/dist/esm/spans/types.js +18 -0
  22. package/dist/esm/spans/types.js.map +1 -0
  23. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  24. package/dist/esm/types/annotations.d.ts +2 -1
  25. package/dist/esm/types/annotations.d.ts.map +1 -1
  26. package/dist/esm/types/experiments.d.ts +1 -7
  27. package/dist/esm/types/experiments.d.ts.map +1 -1
  28. package/dist/esm/utils/formatPromptMessages.d.ts.map +1 -1
  29. package/dist/esm/utils/getPromptBySelector.d.ts.map +1 -1
  30. package/dist/src/__generated__/api/v1.d.ts +375 -0
  31. package/dist/src/__generated__/api/v1.d.ts.map +1 -1
  32. package/dist/src/experiments/runExperiment.d.ts +48 -13
  33. package/dist/src/experiments/runExperiment.d.ts.map +1 -1
  34. package/dist/src/experiments/runExperiment.js +138 -36
  35. package/dist/src/experiments/runExperiment.js.map +1 -1
  36. package/dist/src/spans/addSpanAnnotation.d.ts +39 -0
  37. package/dist/src/spans/addSpanAnnotation.d.ts.map +1 -0
  38. package/dist/src/spans/addSpanAnnotation.js +59 -0
  39. package/dist/src/spans/addSpanAnnotation.js.map +1 -0
  40. package/dist/src/spans/index.d.ts +3 -0
  41. package/dist/src/spans/index.d.ts.map +1 -0
  42. package/dist/src/spans/index.js +19 -0
  43. package/dist/src/spans/index.js.map +1 -0
  44. package/dist/src/spans/logSpanAnnotations.d.ts +51 -0
  45. package/dist/src/spans/logSpanAnnotations.d.ts.map +1 -0
  46. package/dist/src/spans/logSpanAnnotations.js +68 -0
  47. package/dist/src/spans/logSpanAnnotations.js.map +1 -0
  48. package/dist/src/spans/types.d.ts +43 -0
  49. package/dist/src/spans/types.d.ts.map +1 -0
  50. package/dist/src/spans/types.js +22 -0
  51. package/dist/src/spans/types.js.map +1 -0
  52. package/dist/src/types/annotations.d.ts +2 -1
  53. package/dist/src/types/annotations.d.ts.map +1 -1
  54. package/dist/src/types/experiments.d.ts +1 -7
  55. package/dist/src/types/experiments.d.ts.map +1 -1
  56. package/dist/src/utils/formatPromptMessages.d.ts.map +1 -1
  57. package/dist/src/utils/getPromptBySelector.d.ts.map +1 -1
  58. package/dist/tsconfig.tsbuildinfo +1 -1
  59. package/package.json +7 -1
  60. package/src/__generated__/api/v1.ts +375 -0
  61. package/src/experiments/runExperiment.ts +211 -74
  62. package/src/spans/addSpanAnnotation.ts +59 -0
  63. package/src/spans/index.ts +2 -0
  64. package/src/spans/logSpanAnnotations.ts +71 -0
  65. package/src/spans/types.ts +60 -0
  66. package/src/types/annotations.ts +4 -1
  67. package/src/types/experiments.ts +1 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arizeai/phoenix-client",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "A client for the Phoenix API",
5
5
  "main": "dist/src/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -14,6 +14,10 @@
14
14
  "import": "./dist/esm/prompts/index.js",
15
15
  "require": "./dist/src/prompts/index.js"
16
16
  },
17
+ "./spans": {
18
+ "import": "./dist/esm/spans/index.js",
19
+ "require": "./dist/src/spans/index.js"
20
+ },
17
21
  "./experiments": {
18
22
  "import": "./dist/esm/experiments/index.js",
19
23
  "require": "./dist/src/experiments/index.js"
@@ -38,6 +42,7 @@
38
42
  "devDependencies": {
39
43
  "@ai-sdk/openai": "^1.1.15",
40
44
  "@anthropic-ai/sdk": "^0.35.0",
45
+ "@types/async": "^3.2.24",
41
46
  "@types/node": "^20.17.22",
42
47
  "ai": "^4.1.24",
43
48
  "openai": "^4.77.0",
@@ -47,6 +52,7 @@
47
52
  "vitest": "^2.1.9"
48
53
  },
49
54
  "dependencies": {
55
+ "async": "^3.2.6",
50
56
  "openapi-fetch": "^0.12.5",
51
57
  "tiny-invariant": "^1.3.3",
52
58
  "zod": "^3.24.2",
@@ -283,6 +283,41 @@ export interface paths {
283
283
  patch?: never;
284
284
  trace?: never;
285
285
  };
286
+ "/v1/experiments/{experiment_id}/runs": {
287
+ parameters: {
288
+ query?: never;
289
+ header?: never;
290
+ path?: never;
291
+ cookie?: never;
292
+ };
293
+ /** List runs for an experiment */
294
+ get: operations["listExperimentRuns"];
295
+ put?: never;
296
+ /** Create run for an experiment */
297
+ post: operations["createExperimentRun"];
298
+ delete?: never;
299
+ options?: never;
300
+ head?: never;
301
+ patch?: never;
302
+ trace?: never;
303
+ };
304
+ "/v1/experiment_evaluations": {
305
+ parameters: {
306
+ query?: never;
307
+ header?: never;
308
+ path?: never;
309
+ cookie?: never;
310
+ };
311
+ get?: never;
312
+ put?: never;
313
+ /** Create or update evaluation for an experiment run */
314
+ post: operations["upsertExperimentEvaluation"];
315
+ delete?: never;
316
+ options?: never;
317
+ head?: never;
318
+ patch?: never;
319
+ trace?: never;
320
+ };
286
321
  "/v1/span_annotations": {
287
322
  parameters: {
288
323
  query?: never;
@@ -632,6 +667,58 @@ export interface components {
632
667
  CreateExperimentResponseBody: {
633
668
  data: components["schemas"]["Experiment"];
634
669
  };
670
+ /** CreateExperimentRunRequestBody */
671
+ CreateExperimentRunRequestBody: {
672
+ /**
673
+ * Dataset Example Id
674
+ * @description The ID of the dataset example used in the experiment run
675
+ */
676
+ dataset_example_id: string;
677
+ /**
678
+ * Output
679
+ * @description The output of the experiment task
680
+ */
681
+ output: unknown;
682
+ /**
683
+ * Repetition Number
684
+ * @description The repetition number of the experiment run
685
+ */
686
+ repetition_number: number;
687
+ /**
688
+ * Start Time
689
+ * Format: date-time
690
+ * @description The start time of the experiment run
691
+ */
692
+ start_time: string;
693
+ /**
694
+ * End Time
695
+ * Format: date-time
696
+ * @description The end time of the experiment run
697
+ */
698
+ end_time: string;
699
+ /**
700
+ * Trace Id
701
+ * @description The ID of the corresponding trace (if one exists)
702
+ */
703
+ trace_id?: string | null;
704
+ /**
705
+ * Error
706
+ * @description Optional error message if the experiment run encountered an error
707
+ */
708
+ error?: string | null;
709
+ };
710
+ /** CreateExperimentRunResponseBody */
711
+ CreateExperimentRunResponseBody: {
712
+ data: components["schemas"]["CreateExperimentRunResponseBodyData"];
713
+ };
714
+ /** CreateExperimentRunResponseBodyData */
715
+ CreateExperimentRunResponseBodyData: {
716
+ /**
717
+ * Id
718
+ * @description The ID of the newly created experiment run
719
+ */
720
+ id: string;
721
+ };
635
722
  /** CreateProjectRequestBody */
636
723
  CreateProjectRequestBody: {
637
724
  /** Name */
@@ -790,6 +877,74 @@ export interface components {
790
877
  */
791
878
  updated_at: string;
792
879
  };
880
+ /** ExperimentEvaluationResult */
881
+ ExperimentEvaluationResult: {
882
+ /**
883
+ * Label
884
+ * @description The label assigned by the evaluation
885
+ */
886
+ label?: string | null;
887
+ /**
888
+ * Score
889
+ * @description The score assigned by the evaluation
890
+ */
891
+ score?: number | null;
892
+ /**
893
+ * Explanation
894
+ * @description Explanation of the evaluation result
895
+ */
896
+ explanation?: string | null;
897
+ };
898
+ /** ExperimentRunResponse */
899
+ ExperimentRunResponse: {
900
+ /**
901
+ * Dataset Example Id
902
+ * @description The ID of the dataset example used in the experiment run
903
+ */
904
+ dataset_example_id: string;
905
+ /**
906
+ * Output
907
+ * @description The output of the experiment task
908
+ */
909
+ output: unknown;
910
+ /**
911
+ * Repetition Number
912
+ * @description The repetition number of the experiment run
913
+ */
914
+ repetition_number: number;
915
+ /**
916
+ * Start Time
917
+ * Format: date-time
918
+ * @description The start time of the experiment run
919
+ */
920
+ start_time: string;
921
+ /**
922
+ * End Time
923
+ * Format: date-time
924
+ * @description The end time of the experiment run
925
+ */
926
+ end_time: string;
927
+ /**
928
+ * Trace Id
929
+ * @description The ID of the corresponding trace (if one exists)
930
+ */
931
+ trace_id?: string | null;
932
+ /**
933
+ * Error
934
+ * @description Optional error message if the experiment run encountered an error
935
+ */
936
+ error?: string | null;
937
+ /**
938
+ * Id
939
+ * @description The ID of the experiment run
940
+ */
941
+ id: string;
942
+ /**
943
+ * Experiment Id
944
+ * @description The ID of the experiment
945
+ */
946
+ experiment_id: string;
947
+ };
793
948
  /** FreeformAnnotationConfig */
794
949
  FreeformAnnotationConfig: {
795
950
  /** Name */
@@ -914,6 +1069,11 @@ export interface components {
914
1069
  /** Next Cursor */
915
1070
  next_cursor: string | null;
916
1071
  };
1072
+ /** ListExperimentRunsResponseBody */
1073
+ ListExperimentRunsResponseBody: {
1074
+ /** Data */
1075
+ data: components["schemas"]["ExperimentRunResponse"][];
1076
+ };
917
1077
  /** ListExperimentsResponseBody */
918
1078
  ListExperimentsResponseBody: {
919
1079
  /** Data */
@@ -1449,6 +1609,68 @@ export interface components {
1449
1609
  UploadDatasetResponseBody: {
1450
1610
  data: components["schemas"]["UploadDatasetData"];
1451
1611
  };
1612
+ /** UpsertExperimentEvaluationRequestBody */
1613
+ UpsertExperimentEvaluationRequestBody: {
1614
+ /**
1615
+ * Experiment Run Id
1616
+ * @description The ID of the experiment run being evaluated
1617
+ */
1618
+ experiment_run_id: string;
1619
+ /**
1620
+ * Name
1621
+ * @description The name of the evaluation
1622
+ */
1623
+ name: string;
1624
+ /**
1625
+ * Annotator Kind
1626
+ * @description The kind of annotator used for the evaluation
1627
+ * @enum {string}
1628
+ */
1629
+ annotator_kind: "LLM" | "CODE" | "HUMAN";
1630
+ /**
1631
+ * Start Time
1632
+ * Format: date-time
1633
+ * @description The start time of the evaluation in ISO format
1634
+ */
1635
+ start_time: string;
1636
+ /**
1637
+ * End Time
1638
+ * Format: date-time
1639
+ * @description The end time of the evaluation in ISO format
1640
+ */
1641
+ end_time: string;
1642
+ /** @description The result of the evaluation */
1643
+ result: components["schemas"]["ExperimentEvaluationResult"];
1644
+ /**
1645
+ * Error
1646
+ * @description Optional error message if the evaluation encountered an error
1647
+ */
1648
+ error?: string | null;
1649
+ /**
1650
+ * Metadata
1651
+ * @description Metadata for the evaluation
1652
+ */
1653
+ metadata?: {
1654
+ [key: string]: unknown;
1655
+ } | null;
1656
+ /**
1657
+ * Trace Id
1658
+ * @description Optional trace ID for tracking
1659
+ */
1660
+ trace_id?: string | null;
1661
+ };
1662
+ /** UpsertExperimentEvaluationResponseBody */
1663
+ UpsertExperimentEvaluationResponseBody: {
1664
+ data: components["schemas"]["UpsertExperimentEvaluationResponseBodyData"];
1665
+ };
1666
+ /** UpsertExperimentEvaluationResponseBodyData */
1667
+ UpsertExperimentEvaluationResponseBodyData: {
1668
+ /**
1669
+ * Id
1670
+ * @description The ID of the upserted experiment evaluation
1671
+ */
1672
+ id: string;
1673
+ };
1452
1674
  /** ValidationError */
1453
1675
  ValidationError: {
1454
1676
  /** Location */
@@ -2415,6 +2637,159 @@ export interface operations {
2415
2637
  };
2416
2638
  };
2417
2639
  };
2640
+ listExperimentRuns: {
2641
+ parameters: {
2642
+ query?: never;
2643
+ header?: never;
2644
+ path: {
2645
+ experiment_id: string;
2646
+ };
2647
+ cookie?: never;
2648
+ };
2649
+ requestBody?: never;
2650
+ responses: {
2651
+ /** @description Experiment runs retrieved successfully */
2652
+ 200: {
2653
+ headers: {
2654
+ [name: string]: unknown;
2655
+ };
2656
+ content: {
2657
+ "application/json": components["schemas"]["ListExperimentRunsResponseBody"];
2658
+ };
2659
+ };
2660
+ /** @description Forbidden */
2661
+ 403: {
2662
+ headers: {
2663
+ [name: string]: unknown;
2664
+ };
2665
+ content: {
2666
+ "text/plain": string;
2667
+ };
2668
+ };
2669
+ /** @description Experiment not found */
2670
+ 404: {
2671
+ headers: {
2672
+ [name: string]: unknown;
2673
+ };
2674
+ content: {
2675
+ "text/plain": string;
2676
+ };
2677
+ };
2678
+ /** @description Validation Error */
2679
+ 422: {
2680
+ headers: {
2681
+ [name: string]: unknown;
2682
+ };
2683
+ content: {
2684
+ "application/json": components["schemas"]["HTTPValidationError"];
2685
+ };
2686
+ };
2687
+ };
2688
+ };
2689
+ createExperimentRun: {
2690
+ parameters: {
2691
+ query?: never;
2692
+ header?: never;
2693
+ path: {
2694
+ experiment_id: string;
2695
+ };
2696
+ cookie?: never;
2697
+ };
2698
+ requestBody: {
2699
+ content: {
2700
+ "application/json": components["schemas"]["CreateExperimentRunRequestBody"];
2701
+ };
2702
+ };
2703
+ responses: {
2704
+ /** @description Experiment run created successfully */
2705
+ 200: {
2706
+ headers: {
2707
+ [name: string]: unknown;
2708
+ };
2709
+ content: {
2710
+ "application/json": components["schemas"]["CreateExperimentRunResponseBody"];
2711
+ };
2712
+ };
2713
+ /** @description Forbidden */
2714
+ 403: {
2715
+ headers: {
2716
+ [name: string]: unknown;
2717
+ };
2718
+ content: {
2719
+ "text/plain": string;
2720
+ };
2721
+ };
2722
+ /** @description Experiment or dataset example not found */
2723
+ 404: {
2724
+ headers: {
2725
+ [name: string]: unknown;
2726
+ };
2727
+ content: {
2728
+ "text/plain": string;
2729
+ };
2730
+ };
2731
+ /** @description Validation Error */
2732
+ 422: {
2733
+ headers: {
2734
+ [name: string]: unknown;
2735
+ };
2736
+ content: {
2737
+ "application/json": components["schemas"]["HTTPValidationError"];
2738
+ };
2739
+ };
2740
+ };
2741
+ };
2742
+ upsertExperimentEvaluation: {
2743
+ parameters: {
2744
+ query?: never;
2745
+ header?: never;
2746
+ path?: never;
2747
+ cookie?: never;
2748
+ };
2749
+ requestBody: {
2750
+ content: {
2751
+ "application/json": components["schemas"]["UpsertExperimentEvaluationRequestBody"];
2752
+ };
2753
+ };
2754
+ responses: {
2755
+ /** @description Successful Response */
2756
+ 200: {
2757
+ headers: {
2758
+ [name: string]: unknown;
2759
+ };
2760
+ content: {
2761
+ "application/json": components["schemas"]["UpsertExperimentEvaluationResponseBody"];
2762
+ };
2763
+ };
2764
+ /** @description Forbidden */
2765
+ 403: {
2766
+ headers: {
2767
+ [name: string]: unknown;
2768
+ };
2769
+ content: {
2770
+ "text/plain": string;
2771
+ };
2772
+ };
2773
+ /** @description Experiment run not found */
2774
+ 404: {
2775
+ headers: {
2776
+ [name: string]: unknown;
2777
+ };
2778
+ content: {
2779
+ "text/plain": string;
2780
+ };
2781
+ };
2782
+ /** @description Validation Error */
2783
+ 422: {
2784
+ headers: {
2785
+ [name: string]: unknown;
2786
+ };
2787
+ content: {
2788
+ "application/json": components["schemas"]["HTTPValidationError"];
2789
+ };
2790
+ };
2791
+ };
2792
+ };
2418
2793
  annotateSpans: {
2419
2794
  parameters: {
2420
2795
  query?: {