@arizeai/phoenix-client 6.8.1 → 6.9.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 (103) hide show
  1. package/README.md +77 -0
  2. package/dist/esm/__generated__/api/v1.d.ts +30 -15
  3. package/dist/esm/__generated__/api/v1.d.ts.map +1 -1
  4. package/dist/esm/constants/serverRequirements.d.ts +1 -0
  5. package/dist/esm/constants/serverRequirements.d.ts.map +1 -1
  6. package/dist/esm/constants/serverRequirements.js +7 -0
  7. package/dist/esm/constants/serverRequirements.js.map +1 -1
  8. package/dist/esm/sessions/addSessionNote.d.ts +45 -0
  9. package/dist/esm/sessions/addSessionNote.d.ts.map +1 -0
  10. package/dist/esm/sessions/addSessionNote.js +45 -0
  11. package/dist/esm/sessions/addSessionNote.js.map +1 -0
  12. package/dist/esm/sessions/index.d.ts +1 -0
  13. package/dist/esm/sessions/index.d.ts.map +1 -1
  14. package/dist/esm/sessions/index.js +1 -0
  15. package/dist/esm/sessions/index.js.map +1 -1
  16. package/dist/esm/spans/addSpanNote.d.ts +5 -3
  17. package/dist/esm/spans/addSpanNote.d.ts.map +1 -1
  18. package/dist/esm/spans/addSpanNote.js +7 -4
  19. package/dist/esm/spans/addSpanNote.js.map +1 -1
  20. package/dist/esm/traces/addTraceAnnotation.d.ts +43 -0
  21. package/dist/esm/traces/addTraceAnnotation.d.ts.map +1 -0
  22. package/dist/esm/traces/addTraceAnnotation.js +43 -0
  23. package/dist/esm/traces/addTraceAnnotation.js.map +1 -0
  24. package/dist/esm/traces/addTraceNote.d.ts +5 -2
  25. package/dist/esm/traces/addTraceNote.d.ts.map +1 -1
  26. package/dist/esm/traces/addTraceNote.js +7 -3
  27. package/dist/esm/traces/addTraceNote.js.map +1 -1
  28. package/dist/esm/traces/index.d.ts +3 -0
  29. package/dist/esm/traces/index.d.ts.map +1 -1
  30. package/dist/esm/traces/index.js +2 -0
  31. package/dist/esm/traces/index.js.map +1 -1
  32. package/dist/esm/traces/logTraceAnnotations.d.ts +53 -0
  33. package/dist/esm/traces/logTraceAnnotations.d.ts.map +1 -0
  34. package/dist/esm/traces/logTraceAnnotations.js +50 -0
  35. package/dist/esm/traces/logTraceAnnotations.js.map +1 -0
  36. package/dist/esm/traces/types.d.ts +24 -0
  37. package/dist/esm/traces/types.d.ts.map +1 -0
  38. package/dist/esm/traces/types.js +38 -0
  39. package/dist/esm/traces/types.js.map +1 -0
  40. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  41. package/dist/esm/utils/apiErrorUtils.d.ts +2 -0
  42. package/dist/esm/utils/apiErrorUtils.d.ts.map +1 -0
  43. package/dist/esm/utils/apiErrorUtils.js +19 -0
  44. package/dist/esm/utils/apiErrorUtils.js.map +1 -0
  45. package/dist/esm/utils/formatPromptMessages.d.ts.map +1 -1
  46. package/dist/esm/utils/getPromptBySelector.d.ts.map +1 -1
  47. package/dist/src/__generated__/api/v1.d.ts +30 -15
  48. package/dist/src/__generated__/api/v1.d.ts.map +1 -1
  49. package/dist/src/constants/serverRequirements.d.ts +1 -0
  50. package/dist/src/constants/serverRequirements.d.ts.map +1 -1
  51. package/dist/src/constants/serverRequirements.js +8 -1
  52. package/dist/src/constants/serverRequirements.js.map +1 -1
  53. package/dist/src/sessions/addSessionNote.d.ts +45 -0
  54. package/dist/src/sessions/addSessionNote.d.ts.map +1 -0
  55. package/dist/src/sessions/addSessionNote.js +48 -0
  56. package/dist/src/sessions/addSessionNote.js.map +1 -0
  57. package/dist/src/sessions/index.d.ts +1 -0
  58. package/dist/src/sessions/index.d.ts.map +1 -1
  59. package/dist/src/sessions/index.js +1 -0
  60. package/dist/src/sessions/index.js.map +1 -1
  61. package/dist/src/spans/addSpanNote.d.ts +5 -3
  62. package/dist/src/spans/addSpanNote.d.ts.map +1 -1
  63. package/dist/src/spans/addSpanNote.js +7 -4
  64. package/dist/src/spans/addSpanNote.js.map +1 -1
  65. package/dist/src/traces/addTraceAnnotation.d.ts +43 -0
  66. package/dist/src/traces/addTraceAnnotation.d.ts.map +1 -0
  67. package/dist/src/traces/addTraceAnnotation.js +47 -0
  68. package/dist/src/traces/addTraceAnnotation.js.map +1 -0
  69. package/dist/src/traces/addTraceNote.d.ts +5 -2
  70. package/dist/src/traces/addTraceNote.d.ts.map +1 -1
  71. package/dist/src/traces/addTraceNote.js +7 -3
  72. package/dist/src/traces/addTraceNote.js.map +1 -1
  73. package/dist/src/traces/index.d.ts +3 -0
  74. package/dist/src/traces/index.d.ts.map +1 -1
  75. package/dist/src/traces/index.js +2 -0
  76. package/dist/src/traces/index.js.map +1 -1
  77. package/dist/src/traces/logTraceAnnotations.d.ts +53 -0
  78. package/dist/src/traces/logTraceAnnotations.d.ts.map +1 -0
  79. package/dist/src/traces/logTraceAnnotations.js +53 -0
  80. package/dist/src/traces/logTraceAnnotations.js.map +1 -0
  81. package/dist/src/traces/types.d.ts +24 -0
  82. package/dist/src/traces/types.d.ts.map +1 -0
  83. package/dist/src/traces/types.js +42 -0
  84. package/dist/src/traces/types.js.map +1 -0
  85. package/dist/src/utils/apiErrorUtils.d.ts +2 -0
  86. package/dist/src/utils/apiErrorUtils.d.ts.map +1 -0
  87. package/dist/src/utils/apiErrorUtils.js +22 -0
  88. package/dist/src/utils/apiErrorUtils.js.map +1 -0
  89. package/dist/src/utils/formatPromptMessages.d.ts.map +1 -1
  90. package/dist/src/utils/getPromptBySelector.d.ts.map +1 -1
  91. package/dist/tsconfig.tsbuildinfo +1 -1
  92. package/package.json +1 -1
  93. package/src/__generated__/api/v1.ts +30 -15
  94. package/src/constants/serverRequirements.ts +8 -0
  95. package/src/sessions/addSessionNote.ts +74 -0
  96. package/src/sessions/index.ts +1 -0
  97. package/src/spans/addSpanNote.ts +7 -4
  98. package/src/traces/addTraceAnnotation.ts +65 -0
  99. package/src/traces/addTraceNote.ts +7 -3
  100. package/src/traces/index.ts +3 -0
  101. package/src/traces/logTraceAnnotations.ts +75 -0
  102. package/src/traces/types.ts +72 -0
  103. package/src/utils/apiErrorUtils.ts +17 -0
package/README.md CHANGED
@@ -368,6 +368,69 @@ do {
368
368
 
369
369
  > **Note:** Requires Phoenix server >= 13.15.0.
370
370
 
371
+ ### Trace Annotations
372
+
373
+ Add structured feedback (label/score by name) to entire traces. Use `addTraceAnnotation` for one trace or `logTraceAnnotations` for batches.
374
+
375
+ ```ts
376
+ import {
377
+ addTraceAnnotation,
378
+ logTraceAnnotations,
379
+ } from "@arizeai/phoenix-client/traces";
380
+
381
+ // Single annotation
382
+ const result = await addTraceAnnotation({
383
+ traceAnnotation: {
384
+ traceId: "abc123",
385
+ name: "correctness",
386
+ label: "correct",
387
+ score: 1.0,
388
+ annotatorKind: "HUMAN",
389
+ },
390
+ sync: true, // returns { id: "..." } when sync, null when async
391
+ });
392
+
393
+ // Batch
394
+ await logTraceAnnotations({
395
+ traceAnnotations: [
396
+ {
397
+ traceId: "abc123",
398
+ name: "correctness",
399
+ label: "correct",
400
+ score: 1.0,
401
+ annotatorKind: "HUMAN",
402
+ },
403
+ {
404
+ traceId: "def456",
405
+ name: "faithfulness",
406
+ label: "faithful",
407
+ score: 0.9,
408
+ annotatorKind: "LLM",
409
+ },
410
+ ],
411
+ sync: true,
412
+ });
413
+ ```
414
+
415
+ The reserved name `note` is rejected — use `addTraceNote` instead for free-form notes (see below).
416
+
417
+ ### Trace Notes
418
+
419
+ Notes are a special type of annotation for free-form text — useful for open coding, where reviewers leave qualitative observations on a trace before any rubric exists. Multiple notes can coexist on the same trace.
420
+
421
+ ```ts
422
+ import { addTraceNote } from "@arizeai/phoenix-client/traces";
423
+
424
+ await addTraceNote({
425
+ traceNote: {
426
+ traceId: "abc123",
427
+ note: "Needs follow-up — unexpected tool call sequence",
428
+ },
429
+ });
430
+ ```
431
+
432
+ > **Note:** `addTraceNote` requires Phoenix server >= 14.13.0.
433
+
371
434
  ## Spans
372
435
 
373
436
  The `@arizeai/phoenix-client` package provides a `spans` export for querying spans with powerful filtering.
@@ -505,6 +568,7 @@ import {
505
568
  listSessions,
506
569
  getSession,
507
570
  addSessionAnnotation,
571
+ addSessionNote,
508
572
  } from "@arizeai/phoenix-client/sessions";
509
573
 
510
574
  // List all sessions for a project
@@ -537,6 +601,19 @@ await addSessionAnnotation({
537
601
  });
538
602
  ```
539
603
 
604
+ ### Adding Session Notes
605
+
606
+ Session notes require Phoenix server `14.17.0` or newer.
607
+
608
+ ```ts
609
+ await addSessionNote({
610
+ sessionNote: {
611
+ sessionId: "my-session-id",
612
+ note: "Needs review",
613
+ },
614
+ });
615
+ ```
616
+
540
617
  ## Examples
541
618
 
542
619
  To run examples, install dependencies using `pnpm` and run:
@@ -66,7 +66,10 @@ export interface paths {
66
66
  path?: never;
67
67
  cookie?: never;
68
68
  };
69
- /** Get span annotations for a list of span_ids. */
69
+ /**
70
+ * Get span annotations filtered by span_ids and/or identifier.
71
+ * @description Return span annotations for a project, filtered by `span_ids`, `identifier`, or both. At least one of `span_ids` or `identifier` must be supplied. When both are supplied, results are the AND-intersection of the two filters.
72
+ */
70
73
  get: operations["listSpanAnnotationsBySpanIds"];
71
74
  put?: never;
72
75
  post?: never;
@@ -83,7 +86,10 @@ export interface paths {
83
86
  path?: never;
84
87
  cookie?: never;
85
88
  };
86
- /** Get trace annotations for a list of trace_ids. */
89
+ /**
90
+ * Get trace annotations filtered by trace_ids and/or identifier.
91
+ * @description Return trace annotations for a project, filtered by `trace_ids`, `identifier`, or both. At least one of `trace_ids` or `identifier` must be supplied. When both are supplied, results are the AND-intersection of the two filters.
92
+ */
87
93
  get: operations["listTraceAnnotationsByTraceIds"];
88
94
  put?: never;
89
95
  post?: never;
@@ -100,7 +106,10 @@ export interface paths {
100
106
  path?: never;
101
107
  cookie?: never;
102
108
  };
103
- /** Get session annotations for a list of session_ids. */
109
+ /**
110
+ * Get session annotations filtered by session_ids and/or identifier.
111
+ * @description Return session annotations for a project, filtered by `session_ids`, `identifier`, or both. At least one of `session_ids` or `identifier` must be supplied. When both are supplied, results are the AND-intersection of the two filters.
112
+ */
104
113
  get: operations["listSessionAnnotationsBySessionIds"];
105
114
  put?: never;
106
115
  post?: never;
@@ -485,7 +494,7 @@ export interface paths {
485
494
  put?: never;
486
495
  /**
487
496
  * Create a trace note
488
- * @description Add a note annotation to a trace. Notes are special annotations that allow multiple entries per trace (unlike regular annotations which are unique by name and identifier). Each note gets a unique UUIDv4 identifier.
497
+ * @description Add a note annotation to a trace. Each call appends a new note with an auto-generated UUIDv4 identifier, so multiple notes accumulate on the same trace. Structured annotations, by contrast, are keyed by (name, trace_id, identifier) — re-writing the same key overwrites the existing annotation, so to keep multiple structured annotations with the same name on a trace you must supply distinct identifiers.
489
498
  */
490
499
  post: operations["createTraceNote"];
491
500
  delete?: never;
@@ -590,7 +599,7 @@ export interface paths {
590
599
  put?: never;
591
600
  /**
592
601
  * Create a span note
593
- * @description Add a note annotation to a span. Notes are special annotations that allow multiple entries per span (unlike regular annotations which are unique by name and identifier). Each note gets a unique UUIDv4 identifier.
602
+ * @description Add a note annotation to a span. Each call appends a new note with an auto-generated UUIDv4 identifier, so multiple notes accumulate on the same span. Structured annotations, by contrast, are keyed by (name, span_id, identifier) — re-writing the same key overwrites the existing annotation, so to keep multiple structured annotations with the same name on a span you must supply distinct identifiers.
594
603
  */
595
604
  post: operations["createSpanNote"];
596
605
  delete?: never;
@@ -941,7 +950,7 @@ export interface paths {
941
950
  put?: never;
942
951
  /**
943
952
  * Create a session note
944
- * @description Add a note annotation to a session. Notes are special annotations that allow multiple entries per session (unlike regular annotations which are unique by name and identifier). Each note gets a unique UUIDv4 identifier.
953
+ * @description Add a note annotation to a session. Each call appends a new note with an auto-generated UUIDv4 identifier, so multiple notes accumulate on the same session. Structured annotations, by contrast, are keyed by (name, session_id, identifier) — re-writing the same key overwrites the existing annotation, so to keep multiple structured annotations with the same name on a session you must supply distinct identifiers.
945
954
  */
946
955
  post: operations["createSessionNote"];
947
956
  delete?: never;
@@ -3966,9 +3975,11 @@ export interface operations {
3966
3975
  };
3967
3976
  listSpanAnnotationsBySpanIds: {
3968
3977
  parameters: {
3969
- query: {
3970
- /** @description One or more span id to fetch annotations for */
3971
- span_ids: string[];
3978
+ query?: {
3979
+ /** @description Optional list of span ids to fetch annotations for. If omitted, `identifier` must be supplied. */
3980
+ span_ids?: string[] | null;
3981
+ /** @description Optional list of annotation identifiers to filter by. Each value must be non-empty. If omitted, `span_ids` must be supplied. When combined with `span_ids`, results are the AND-intersection of both filters. */
3982
+ identifier?: string[] | null;
3972
3983
  /** @description Optional list of annotation names to include. If provided, only annotations with these names will be returned. 'note' annotations are excluded by default unless explicitly included in this list. */
3973
3984
  include_annotation_names?: string[] | null;
3974
3985
  /** @description Optional list of annotation names to exclude from results. */
@@ -4027,9 +4038,11 @@ export interface operations {
4027
4038
  };
4028
4039
  listTraceAnnotationsByTraceIds: {
4029
4040
  parameters: {
4030
- query: {
4031
- /** @description One or more trace id to fetch annotations for */
4032
- trace_ids: string[];
4041
+ query?: {
4042
+ /** @description Optional list of trace ids to fetch annotations for. If omitted, `identifier` must be supplied. */
4043
+ trace_ids?: string[] | null;
4044
+ /** @description Optional list of annotation identifiers to filter by. Each value must be non-empty. If omitted, `trace_ids` must be supplied. When combined with `trace_ids`, results are the AND-intersection of both filters. */
4045
+ identifier?: string[] | null;
4033
4046
  /** @description Optional list of annotation names to include. If provided, only annotations with these names will be returned. 'note' annotations are excluded by default unless explicitly included in this list. */
4034
4047
  include_annotation_names?: string[] | null;
4035
4048
  /** @description Optional list of annotation names to exclude from results. */
@@ -4088,9 +4101,11 @@ export interface operations {
4088
4101
  };
4089
4102
  listSessionAnnotationsBySessionIds: {
4090
4103
  parameters: {
4091
- query: {
4092
- /** @description One or more session id to fetch annotations for */
4093
- session_ids: string[];
4104
+ query?: {
4105
+ /** @description Optional list of session ids to fetch annotations for. If omitted, `identifier` must be supplied. */
4106
+ session_ids?: string[] | null;
4107
+ /** @description Optional list of annotation identifiers to filter by. Each value must be non-empty. If omitted, `session_ids` must be supplied. When combined with `session_ids`, results are the AND-intersection of both filters. */
4108
+ identifier?: string[] | null;
4094
4109
  /** @description Optional list of annotation names to include. If provided, only annotations with these names will be returned. 'note' annotations are excluded by default unless explicitly included in this list. */
4095
4110
  include_annotation_names?: string[] | null;
4096
4111
  /** @description Optional list of annotation names to exclude from results. */