@arizeai/phoenix-client 6.9.3 → 6.10.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 (83) hide show
  1. package/dist/esm/__generated__/api/v1.d.ts +323 -47
  2. package/dist/esm/__generated__/api/v1.d.ts.map +1 -1
  3. package/dist/esm/constants/serverRequirements.d.ts +3 -0
  4. package/dist/esm/constants/serverRequirements.d.ts.map +1 -1
  5. package/dist/esm/constants/serverRequirements.js +24 -0
  6. package/dist/esm/constants/serverRequirements.js.map +1 -1
  7. package/dist/esm/experiments/helpers/getExampleGlobalId.d.ts +8 -0
  8. package/dist/esm/experiments/helpers/getExampleGlobalId.d.ts.map +1 -0
  9. package/dist/esm/experiments/helpers/getExampleGlobalId.js +9 -0
  10. package/dist/esm/experiments/helpers/getExampleGlobalId.js.map +1 -0
  11. package/dist/esm/experiments/resumeEvaluation.d.ts.map +1 -1
  12. package/dist/esm/experiments/resumeEvaluation.js +2 -1
  13. package/dist/esm/experiments/resumeEvaluation.js.map +1 -1
  14. package/dist/esm/experiments/resumeExperiment.d.ts.map +1 -1
  15. package/dist/esm/experiments/resumeExperiment.js +3 -2
  16. package/dist/esm/experiments/resumeExperiment.js.map +1 -1
  17. package/dist/esm/experiments/runExperiment.d.ts.map +1 -1
  18. package/dist/esm/experiments/runExperiment.js +6 -3
  19. package/dist/esm/experiments/runExperiment.js.map +1 -1
  20. package/dist/esm/sessions/addSessionNote.d.ts +11 -2
  21. package/dist/esm/sessions/addSessionNote.d.ts.map +1 -1
  22. package/dist/esm/sessions/addSessionNote.js +12 -3
  23. package/dist/esm/sessions/addSessionNote.js.map +1 -1
  24. package/dist/esm/spans/addSpanNote.d.ts +11 -5
  25. package/dist/esm/spans/addSpanNote.d.ts.map +1 -1
  26. package/dist/esm/spans/addSpanNote.js +13 -5
  27. package/dist/esm/spans/addSpanNote.js.map +1 -1
  28. package/dist/esm/spans/getSpanAnnotations.d.ts +1 -1
  29. package/dist/esm/spans/getSpanAnnotations.d.ts.map +1 -1
  30. package/dist/esm/traces/addTraceNote.d.ts +11 -5
  31. package/dist/esm/traces/addTraceNote.d.ts.map +1 -1
  32. package/dist/esm/traces/addTraceNote.js +12 -6
  33. package/dist/esm/traces/addTraceNote.js.map +1 -1
  34. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  35. package/dist/esm/utils/formatPromptMessages.d.ts.map +1 -1
  36. package/dist/esm/utils/getPromptBySelector.d.ts.map +1 -1
  37. package/dist/src/__generated__/api/v1.d.ts +323 -47
  38. package/dist/src/__generated__/api/v1.d.ts.map +1 -1
  39. package/dist/src/constants/serverRequirements.d.ts +3 -0
  40. package/dist/src/constants/serverRequirements.d.ts.map +1 -1
  41. package/dist/src/constants/serverRequirements.js +25 -1
  42. package/dist/src/constants/serverRequirements.js.map +1 -1
  43. package/dist/src/experiments/helpers/getExampleGlobalId.d.ts +8 -0
  44. package/dist/src/experiments/helpers/getExampleGlobalId.d.ts.map +1 -0
  45. package/dist/src/experiments/helpers/getExampleGlobalId.js +13 -0
  46. package/dist/src/experiments/helpers/getExampleGlobalId.js.map +1 -0
  47. package/dist/src/experiments/resumeEvaluation.d.ts.map +1 -1
  48. package/dist/src/experiments/resumeEvaluation.js +2 -1
  49. package/dist/src/experiments/resumeEvaluation.js.map +1 -1
  50. package/dist/src/experiments/resumeExperiment.d.ts.map +1 -1
  51. package/dist/src/experiments/resumeExperiment.js +3 -2
  52. package/dist/src/experiments/resumeExperiment.js.map +1 -1
  53. package/dist/src/experiments/runExperiment.d.ts.map +1 -1
  54. package/dist/src/experiments/runExperiment.js +6 -3
  55. package/dist/src/experiments/runExperiment.js.map +1 -1
  56. package/dist/src/sessions/addSessionNote.d.ts +11 -2
  57. package/dist/src/sessions/addSessionNote.d.ts.map +1 -1
  58. package/dist/src/sessions/addSessionNote.js +11 -2
  59. package/dist/src/sessions/addSessionNote.js.map +1 -1
  60. package/dist/src/spans/addSpanNote.d.ts +11 -5
  61. package/dist/src/spans/addSpanNote.d.ts.map +1 -1
  62. package/dist/src/spans/addSpanNote.js +13 -5
  63. package/dist/src/spans/addSpanNote.js.map +1 -1
  64. package/dist/src/spans/getSpanAnnotations.d.ts +1 -1
  65. package/dist/src/spans/getSpanAnnotations.d.ts.map +1 -1
  66. package/dist/src/traces/addTraceNote.d.ts +11 -5
  67. package/dist/src/traces/addTraceNote.d.ts.map +1 -1
  68. package/dist/src/traces/addTraceNote.js +11 -5
  69. package/dist/src/traces/addTraceNote.js.map +1 -1
  70. package/dist/src/utils/formatPromptMessages.d.ts.map +1 -1
  71. package/dist/src/utils/getPromptBySelector.d.ts.map +1 -1
  72. package/dist/tsconfig.tsbuildinfo +1 -1
  73. package/package.json +1 -1
  74. package/src/__generated__/api/v1.ts +323 -47
  75. package/src/constants/serverRequirements.ts +27 -0
  76. package/src/experiments/helpers/getExampleGlobalId.ts +12 -0
  77. package/src/experiments/resumeEvaluation.ts +2 -1
  78. package/src/experiments/resumeExperiment.ts +3 -2
  79. package/src/experiments/runExperiment.ts +6 -3
  80. package/src/sessions/addSessionNote.ts +22 -3
  81. package/src/spans/addSpanNote.ts +20 -5
  82. package/src/spans/getSpanAnnotations.ts +1 -1
  83. package/src/traces/addTraceNote.ts +22 -6
@@ -106,6 +106,30 @@ export const DATASET_UPLOAD_EXAMPLE_IDS: ParameterRequirement = {
106
106
  minServerVersion: [15, 0, 0],
107
107
  };
108
108
 
109
+ export const ADD_TRACE_NOTE_IDENTIFIER: ParameterRequirement = {
110
+ kind: "parameter",
111
+ parameterName: "identifier",
112
+ parameterLocation: "body",
113
+ route: "POST /v1/trace_notes",
114
+ minServerVersion: [15, 5, 0],
115
+ };
116
+
117
+ export const ADD_SPAN_NOTE_IDENTIFIER: ParameterRequirement = {
118
+ kind: "parameter",
119
+ parameterName: "identifier",
120
+ parameterLocation: "body",
121
+ route: "POST /v1/span_notes",
122
+ minServerVersion: [15, 5, 0],
123
+ };
124
+
125
+ export const ADD_SESSION_NOTE_IDENTIFIER: ParameterRequirement = {
126
+ kind: "parameter",
127
+ parameterName: "identifier",
128
+ parameterLocation: "body",
129
+ route: "POST /v1/session_notes",
130
+ minServerVersion: [15, 5, 0],
131
+ };
132
+
109
133
  /**
110
134
  * Aggregate list of every known capability requirement.
111
135
  *
@@ -125,4 +149,7 @@ export const ALL_REQUIREMENTS: readonly CapabilityRequirement[] = [
125
149
  GET_SPANS_BY_ATTRIBUTE,
126
150
  LIST_PROJECT_TRACES,
127
151
  DATASET_UPLOAD_EXAMPLE_IDS,
152
+ ADD_TRACE_NOTE_IDENTIFIER,
153
+ ADD_SPAN_NOTE_IDENTIFIER,
154
+ ADD_SESSION_NOTE_IDENTIFIER,
128
155
  ] as const;
@@ -0,0 +1,12 @@
1
+ import type { ExampleWithId } from "../../types/datasets";
2
+
3
+ /**
4
+ * The example's node GlobalID, which experiment runs record as their
5
+ * `dataset_example_id`. Servers that predate the `nodeId` field deliver the
6
+ * GlobalID in the `id` field instead.
7
+ */
8
+ export function getExampleGlobalId(
9
+ example: Pick<ExampleWithId, "id"> & Partial<Pick<ExampleWithId, "nodeId">>
10
+ ): string {
11
+ return example.nodeId ?? example.id;
12
+ }
@@ -29,6 +29,7 @@ import { ensureString } from "../utils/ensureString";
29
29
  import { toObjectHeaders } from "../utils/toObjectHeaders";
30
30
  import { getExperimentInfo } from "./getExperimentInfo.js";
31
31
  import { getExperimentEvaluators } from "./helpers";
32
+ import { getExampleGlobalId } from "./helpers/getExampleGlobalId";
32
33
  import { logEvalResumeSummary, PROGRESS_PREFIX } from "./logging";
33
34
  import { cleanupOwnedTracerProvider } from "./tracing";
34
35
 
@@ -729,7 +730,7 @@ async function runSingleEvaluation({
729
730
  ...objectAsAttributes({
730
731
  experiment_id: experimentId,
731
732
  experiment_run_id: experimentRun.id,
732
- dataset_example_id: datasetExample.nodeId,
733
+ dataset_example_id: getExampleGlobalId(datasetExample),
733
734
  }),
734
735
  });
735
736
 
@@ -28,6 +28,7 @@ import { isHttpErrorWithStatus } from "../utils/isHttpError";
28
28
  import { toObjectHeaders } from "../utils/toObjectHeaders";
29
29
  import { getDatasetExperimentsUrl, getExperimentUrl } from "../utils/urlUtils";
30
30
  import { getExperimentInfo } from "./getExperimentInfo.js";
31
+ import { getExampleGlobalId } from "./helpers/getExampleGlobalId";
31
32
  import {
32
33
  logExperimentResumeSummary,
33
34
  logLinks,
@@ -619,7 +620,7 @@ async function recordTaskResult({
619
620
  },
620
621
  },
621
622
  body: {
622
- dataset_example_id: example.nodeId,
623
+ dataset_example_id: getExampleGlobalId(example),
623
624
  repetition_number: repetitionNumber,
624
625
  output: output as Record<string, unknown>,
625
626
  start_time: startTime.toISOString(),
@@ -695,7 +696,7 @@ async function runSingleTask({
695
696
  [SemanticConventions.INPUT_MIME_TYPE]: MimeType.JSON,
696
697
  ...objectAsAttributes({
697
698
  experiment_id: experimentId,
698
- dataset_example_id: example.nodeId,
699
+ dataset_example_id: getExampleGlobalId(example),
699
700
  repetition_number: repetitionNumber,
700
701
  }),
701
702
  });
@@ -47,6 +47,7 @@ import {
47
47
  } from "../utils/urlUtils";
48
48
  import { getExperimentInfo } from "./getExperimentInfo";
49
49
  import { getExperimentEvaluators } from "./helpers";
50
+ import { getExampleGlobalId } from "./helpers/getExampleGlobalId";
50
51
  import {
51
52
  logEvalSummary,
52
53
  logLinks,
@@ -485,7 +486,7 @@ function runTaskWithExamples({
485
486
  id: localId(), // initialized with local id, will be replaced with server-assigned id when dry run is false
486
487
  traceId,
487
488
  experimentId,
488
- datasetExampleId: example.id,
489
+ datasetExampleId: getExampleGlobalId(example),
489
490
  startTime: new Date(),
490
491
  endTime: new Date(), // will get replaced with actual end time
491
492
  output: null,
@@ -509,7 +510,7 @@ function runTaskWithExamples({
509
510
  },
510
511
  },
511
512
  body: {
512
- dataset_example_id: example.nodeId,
513
+ dataset_example_id: getExampleGlobalId(example),
513
514
  output: thisRun.output,
514
515
  repetition_number: repetitionNumber,
515
516
  start_time: thisRun.startTime.toISOString(),
@@ -681,9 +682,11 @@ export async function evaluateExperiment({
681
682
  type EvaluationId = string;
682
683
  const evaluationRuns: Record<EvaluationId, ExperimentEvaluationRun> = {};
683
684
 
685
+ // Index examples by node GlobalID, matching how runs record
686
+ // datasetExampleId.
684
687
  const examplesById: Record<string, Example> = {};
685
688
  for (const example of dataset.examples) {
686
- examplesById[example.id] = example;
689
+ examplesById[getExampleGlobalId(example)] = example;
687
690
  }
688
691
 
689
692
  const onEvaluationComplete = (run: ExperimentEvaluationRun) => {
@@ -1,5 +1,8 @@
1
1
  import { createClient } from "../client";
2
- import { ADD_SESSION_NOTE } from "../constants/serverRequirements";
2
+ import {
3
+ ADD_SESSION_NOTE,
4
+ ADD_SESSION_NOTE_IDENTIFIER,
5
+ } from "../constants/serverRequirements";
3
6
  import type { ClientFn } from "../types/core";
4
7
  import { formatApiError } from "../utils/apiErrorUtils";
5
8
  import { ensureServerCapability } from "../utils/serverVersionUtils";
@@ -16,6 +19,13 @@ export interface SessionNote {
16
19
  * The note text to add to the session.
17
20
  */
18
21
  note: string;
22
+ /**
23
+ * Optional caller-supplied identifier. When non-empty, the note is upserted
24
+ * on `(sessionId, name='note', identifier)` — repeated calls with the same
25
+ * identifier overwrite the existing note. When omitted, the server stamps a
26
+ * unique `px-session-note:<uuid>` identifier so each call appends a new note.
27
+ */
28
+ identifier?: string;
19
29
  }
20
30
 
21
31
  /**
@@ -28,8 +38,10 @@ export interface AddSessionNoteParams extends ClientFn {
28
38
  /**
29
39
  * Add a note to a session.
30
40
  *
31
- * Notes are a special type of annotation that allow multiple entries per session.
32
- * Each note gets a unique UUIDv4 identifier.
41
+ * When `sessionNote.identifier` is omitted, each call appends a new note with
42
+ * an auto-generated identifier. When `identifier` is non-empty, repeated calls
43
+ * with the same `(sessionId, name='note', identifier)` overwrite the existing
44
+ * note.
33
45
  *
34
46
  * @param params - The parameters to add a session note.
35
47
  * @returns The ID of the created note annotation.
@@ -52,12 +64,19 @@ export async function addSessionNote({
52
64
  }: AddSessionNoteParams): Promise<{ id: string }> {
53
65
  const client = _client ?? createClient();
54
66
  await ensureServerCapability({ client, requirement: ADD_SESSION_NOTE });
67
+ if (sessionNote.identifier) {
68
+ await ensureServerCapability({
69
+ client,
70
+ requirement: ADD_SESSION_NOTE_IDENTIFIER,
71
+ });
72
+ }
55
73
 
56
74
  const { data, error } = await client.POST("/v1/session_notes", {
57
75
  body: {
58
76
  data: {
59
77
  session_id: sessionNote.sessionId.trim(),
60
78
  note: sessionNote.note,
79
+ identifier: sessionNote.identifier,
61
80
  },
62
81
  },
63
82
  });
@@ -1,6 +1,8 @@
1
1
  import { createClient } from "../client";
2
+ import { ADD_SPAN_NOTE_IDENTIFIER } from "../constants/serverRequirements";
2
3
  import type { ClientFn } from "../types/core";
3
4
  import { formatApiError } from "../utils/apiErrorUtils";
5
+ import { ensureServerCapability } from "../utils/serverVersionUtils";
4
6
 
5
7
  /**
6
8
  * Parameters for a single span note
@@ -14,6 +16,13 @@ export interface SpanNote {
14
16
  * The note text to add to the span
15
17
  */
16
18
  note: string;
19
+ /**
20
+ * Optional caller-supplied identifier. When non-empty, the note is upserted
21
+ * on `(spanId, name='note', identifier)` — repeated calls with the same
22
+ * identifier overwrite the existing note. When omitted, the server stamps a
23
+ * unique `px-span-note:<uuid>` identifier so each call appends a new note.
24
+ */
25
+ identifier?: string;
17
26
  }
18
27
 
19
28
  /**
@@ -26,11 +35,10 @@ export interface AddSpanNoteParams extends ClientFn {
26
35
  /**
27
36
  * Add a note to a span.
28
37
  *
29
- * Notes are append-only: each call creates a new note with an auto-generated
30
- * UUIDv4 identifier, so multiple notes accumulate on the same span. Structured
31
- * annotations, by contrast, are keyed by `(name, spanId, identifier)` — to keep
32
- * multiple structured annotations with the same name on a span, supply distinct
33
- * identifiers; otherwise re-writing the same name overwrites the existing one.
38
+ * When `spanNote.identifier` is omitted, each call appends a new note with an
39
+ * auto-generated identifier. When `identifier` is non-empty, repeated calls
40
+ * with the same `(spanId, name='note', identifier)` overwrite the existing
41
+ * note.
34
42
  *
35
43
  * @param params - The parameters to add a span note
36
44
  * @returns The ID of the created note annotation
@@ -50,12 +58,19 @@ export async function addSpanNote({
50
58
  spanNote,
51
59
  }: AddSpanNoteParams): Promise<{ id: string }> {
52
60
  const client = _client ?? createClient();
61
+ if (spanNote.identifier) {
62
+ await ensureServerCapability({
63
+ client,
64
+ requirement: ADD_SPAN_NOTE_IDENTIFIER,
65
+ });
66
+ }
53
67
 
54
68
  const { data, error } = await client.POST("/v1/span_notes", {
55
69
  body: {
56
70
  data: {
57
71
  span_id: spanNote.spanId.trim(),
58
72
  note: spanNote.note,
73
+ identifier: spanNote.identifier,
59
74
  },
60
75
  },
61
76
  });
@@ -12,7 +12,7 @@ export interface GetSpanAnnotationsParams extends ClientFn {
12
12
  project: ProjectIdentifier;
13
13
  /** One or more span IDs to fetch annotations for */
14
14
  spanIds: string[];
15
- /** 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. */
15
+ /** Optional list of annotation names to include. If provided, only annotations with these names will be returned (allowlist). When omitted, the response includes every matching row regardless of name (no annotation names are excluded by default). */
16
16
  includeAnnotationNames?: string[];
17
17
  /** Optional list of annotation names to exclude from results. */
18
18
  excludeAnnotationNames?: string[];
@@ -1,5 +1,8 @@
1
1
  import { createClient } from "../client";
2
- import { ADD_TRACE_NOTE } from "../constants/serverRequirements";
2
+ import {
3
+ ADD_TRACE_NOTE,
4
+ ADD_TRACE_NOTE_IDENTIFIER,
5
+ } from "../constants/serverRequirements";
3
6
  import type { ClientFn } from "../types/core";
4
7
  import { formatApiError } from "../utils/apiErrorUtils";
5
8
  import { ensureServerCapability } from "../utils/serverVersionUtils";
@@ -16,6 +19,13 @@ export interface TraceNote {
16
19
  * The note text to add to the trace.
17
20
  */
18
21
  note: string;
22
+ /**
23
+ * Optional caller-supplied identifier. When non-empty, the note is upserted
24
+ * on `(traceId, name='note', identifier)` — repeated calls with the same
25
+ * identifier overwrite the existing note. When omitted, the server stamps a
26
+ * unique `px-trace-note:<uuid>` identifier so each call appends a new note.
27
+ */
28
+ identifier?: string;
19
29
  }
20
30
 
21
31
  /**
@@ -28,11 +38,10 @@ export interface AddTraceNoteParams extends ClientFn {
28
38
  /**
29
39
  * Add a note to a trace.
30
40
  *
31
- * Notes are append-only: each call creates a new note with an auto-generated
32
- * UUIDv4 identifier, so multiple notes accumulate on the same trace. Structured
33
- * annotations, by contrast, are keyed by `(name, traceId, identifier)` — to keep
34
- * multiple structured annotations with the same name on a trace, supply distinct
35
- * identifiers; otherwise re-writing the same name overwrites the existing one.
41
+ * When `traceNote.identifier` is omitted, each call appends a new note with an
42
+ * auto-generated identifier. When `identifier` is non-empty, repeated calls
43
+ * with the same `(traceId, name='note', identifier)` overwrite the existing
44
+ * note.
36
45
  *
37
46
  * @param params - The parameters to add a trace note.
38
47
  * @returns The ID of the created note annotation.
@@ -53,12 +62,19 @@ export async function addTraceNote({
53
62
  }: AddTraceNoteParams): Promise<{ id: string }> {
54
63
  const client = _client ?? createClient();
55
64
  await ensureServerCapability({ client, requirement: ADD_TRACE_NOTE });
65
+ if (traceNote.identifier) {
66
+ await ensureServerCapability({
67
+ client,
68
+ requirement: ADD_TRACE_NOTE_IDENTIFIER,
69
+ });
70
+ }
56
71
 
57
72
  const { data, error } = await client.POST("/v1/trace_notes", {
58
73
  body: {
59
74
  data: {
60
75
  trace_id: traceNote.traceId.trim(),
61
76
  note: traceNote.note,
77
+ identifier: traceNote.identifier,
62
78
  },
63
79
  },
64
80
  });