@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.
- package/dist/esm/__generated__/api/v1.d.ts +323 -47
- package/dist/esm/__generated__/api/v1.d.ts.map +1 -1
- package/dist/esm/constants/serverRequirements.d.ts +3 -0
- package/dist/esm/constants/serverRequirements.d.ts.map +1 -1
- package/dist/esm/constants/serverRequirements.js +24 -0
- package/dist/esm/constants/serverRequirements.js.map +1 -1
- package/dist/esm/experiments/helpers/getExampleGlobalId.d.ts +8 -0
- package/dist/esm/experiments/helpers/getExampleGlobalId.d.ts.map +1 -0
- package/dist/esm/experiments/helpers/getExampleGlobalId.js +9 -0
- package/dist/esm/experiments/helpers/getExampleGlobalId.js.map +1 -0
- package/dist/esm/experiments/resumeEvaluation.d.ts.map +1 -1
- package/dist/esm/experiments/resumeEvaluation.js +2 -1
- package/dist/esm/experiments/resumeEvaluation.js.map +1 -1
- package/dist/esm/experiments/resumeExperiment.d.ts.map +1 -1
- package/dist/esm/experiments/resumeExperiment.js +3 -2
- package/dist/esm/experiments/resumeExperiment.js.map +1 -1
- package/dist/esm/experiments/runExperiment.d.ts.map +1 -1
- package/dist/esm/experiments/runExperiment.js +6 -3
- package/dist/esm/experiments/runExperiment.js.map +1 -1
- package/dist/esm/sessions/addSessionNote.d.ts +11 -2
- package/dist/esm/sessions/addSessionNote.d.ts.map +1 -1
- package/dist/esm/sessions/addSessionNote.js +12 -3
- package/dist/esm/sessions/addSessionNote.js.map +1 -1
- package/dist/esm/spans/addSpanNote.d.ts +11 -5
- package/dist/esm/spans/addSpanNote.d.ts.map +1 -1
- package/dist/esm/spans/addSpanNote.js +13 -5
- package/dist/esm/spans/addSpanNote.js.map +1 -1
- package/dist/esm/spans/getSpanAnnotations.d.ts +1 -1
- package/dist/esm/spans/getSpanAnnotations.d.ts.map +1 -1
- package/dist/esm/traces/addTraceNote.d.ts +11 -5
- package/dist/esm/traces/addTraceNote.d.ts.map +1 -1
- package/dist/esm/traces/addTraceNote.js +12 -6
- package/dist/esm/traces/addTraceNote.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/esm/utils/formatPromptMessages.d.ts.map +1 -1
- package/dist/esm/utils/getPromptBySelector.d.ts.map +1 -1
- package/dist/src/__generated__/api/v1.d.ts +323 -47
- package/dist/src/__generated__/api/v1.d.ts.map +1 -1
- package/dist/src/constants/serverRequirements.d.ts +3 -0
- package/dist/src/constants/serverRequirements.d.ts.map +1 -1
- package/dist/src/constants/serverRequirements.js +25 -1
- package/dist/src/constants/serverRequirements.js.map +1 -1
- package/dist/src/experiments/helpers/getExampleGlobalId.d.ts +8 -0
- package/dist/src/experiments/helpers/getExampleGlobalId.d.ts.map +1 -0
- package/dist/src/experiments/helpers/getExampleGlobalId.js +13 -0
- package/dist/src/experiments/helpers/getExampleGlobalId.js.map +1 -0
- package/dist/src/experiments/resumeEvaluation.d.ts.map +1 -1
- package/dist/src/experiments/resumeEvaluation.js +2 -1
- package/dist/src/experiments/resumeEvaluation.js.map +1 -1
- package/dist/src/experiments/resumeExperiment.d.ts.map +1 -1
- package/dist/src/experiments/resumeExperiment.js +3 -2
- package/dist/src/experiments/resumeExperiment.js.map +1 -1
- package/dist/src/experiments/runExperiment.d.ts.map +1 -1
- package/dist/src/experiments/runExperiment.js +6 -3
- package/dist/src/experiments/runExperiment.js.map +1 -1
- package/dist/src/sessions/addSessionNote.d.ts +11 -2
- package/dist/src/sessions/addSessionNote.d.ts.map +1 -1
- package/dist/src/sessions/addSessionNote.js +11 -2
- package/dist/src/sessions/addSessionNote.js.map +1 -1
- package/dist/src/spans/addSpanNote.d.ts +11 -5
- package/dist/src/spans/addSpanNote.d.ts.map +1 -1
- package/dist/src/spans/addSpanNote.js +13 -5
- package/dist/src/spans/addSpanNote.js.map +1 -1
- package/dist/src/spans/getSpanAnnotations.d.ts +1 -1
- package/dist/src/spans/getSpanAnnotations.d.ts.map +1 -1
- package/dist/src/traces/addTraceNote.d.ts +11 -5
- package/dist/src/traces/addTraceNote.d.ts.map +1 -1
- package/dist/src/traces/addTraceNote.js +11 -5
- package/dist/src/traces/addTraceNote.js.map +1 -1
- package/dist/src/utils/formatPromptMessages.d.ts.map +1 -1
- package/dist/src/utils/getPromptBySelector.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/__generated__/api/v1.ts +323 -47
- package/src/constants/serverRequirements.ts +27 -0
- package/src/experiments/helpers/getExampleGlobalId.ts +12 -0
- package/src/experiments/resumeEvaluation.ts +2 -1
- package/src/experiments/resumeExperiment.ts +3 -2
- package/src/experiments/runExperiment.ts +6 -3
- package/src/sessions/addSessionNote.ts +22 -3
- package/src/spans/addSpanNote.ts +20 -5
- package/src/spans/getSpanAnnotations.ts +1 -1
- 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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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 {
|
|
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
|
-
*
|
|
32
|
-
*
|
|
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
|
});
|
package/src/spans/addSpanNote.ts
CHANGED
|
@@ -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
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
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.
|
|
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 {
|
|
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
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
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
|
});
|