@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.
- package/README.md +77 -0
- package/dist/esm/__generated__/api/v1.d.ts +30 -15
- package/dist/esm/__generated__/api/v1.d.ts.map +1 -1
- package/dist/esm/constants/serverRequirements.d.ts +1 -0
- package/dist/esm/constants/serverRequirements.d.ts.map +1 -1
- package/dist/esm/constants/serverRequirements.js +7 -0
- package/dist/esm/constants/serverRequirements.js.map +1 -1
- package/dist/esm/sessions/addSessionNote.d.ts +45 -0
- package/dist/esm/sessions/addSessionNote.d.ts.map +1 -0
- package/dist/esm/sessions/addSessionNote.js +45 -0
- package/dist/esm/sessions/addSessionNote.js.map +1 -0
- package/dist/esm/sessions/index.d.ts +1 -0
- package/dist/esm/sessions/index.d.ts.map +1 -1
- package/dist/esm/sessions/index.js +1 -0
- package/dist/esm/sessions/index.js.map +1 -1
- package/dist/esm/spans/addSpanNote.d.ts +5 -3
- package/dist/esm/spans/addSpanNote.d.ts.map +1 -1
- package/dist/esm/spans/addSpanNote.js +7 -4
- package/dist/esm/spans/addSpanNote.js.map +1 -1
- package/dist/esm/traces/addTraceAnnotation.d.ts +43 -0
- package/dist/esm/traces/addTraceAnnotation.d.ts.map +1 -0
- package/dist/esm/traces/addTraceAnnotation.js +43 -0
- package/dist/esm/traces/addTraceAnnotation.js.map +1 -0
- package/dist/esm/traces/addTraceNote.d.ts +5 -2
- package/dist/esm/traces/addTraceNote.d.ts.map +1 -1
- package/dist/esm/traces/addTraceNote.js +7 -3
- package/dist/esm/traces/addTraceNote.js.map +1 -1
- package/dist/esm/traces/index.d.ts +3 -0
- package/dist/esm/traces/index.d.ts.map +1 -1
- package/dist/esm/traces/index.js +2 -0
- package/dist/esm/traces/index.js.map +1 -1
- package/dist/esm/traces/logTraceAnnotations.d.ts +53 -0
- package/dist/esm/traces/logTraceAnnotations.d.ts.map +1 -0
- package/dist/esm/traces/logTraceAnnotations.js +50 -0
- package/dist/esm/traces/logTraceAnnotations.js.map +1 -0
- package/dist/esm/traces/types.d.ts +24 -0
- package/dist/esm/traces/types.d.ts.map +1 -0
- package/dist/esm/traces/types.js +38 -0
- package/dist/esm/traces/types.js.map +1 -0
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/esm/utils/apiErrorUtils.d.ts +2 -0
- package/dist/esm/utils/apiErrorUtils.d.ts.map +1 -0
- package/dist/esm/utils/apiErrorUtils.js +19 -0
- package/dist/esm/utils/apiErrorUtils.js.map +1 -0
- 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 +30 -15
- package/dist/src/__generated__/api/v1.d.ts.map +1 -1
- package/dist/src/constants/serverRequirements.d.ts +1 -0
- package/dist/src/constants/serverRequirements.d.ts.map +1 -1
- package/dist/src/constants/serverRequirements.js +8 -1
- package/dist/src/constants/serverRequirements.js.map +1 -1
- package/dist/src/sessions/addSessionNote.d.ts +45 -0
- package/dist/src/sessions/addSessionNote.d.ts.map +1 -0
- package/dist/src/sessions/addSessionNote.js +48 -0
- package/dist/src/sessions/addSessionNote.js.map +1 -0
- package/dist/src/sessions/index.d.ts +1 -0
- package/dist/src/sessions/index.d.ts.map +1 -1
- package/dist/src/sessions/index.js +1 -0
- package/dist/src/sessions/index.js.map +1 -1
- package/dist/src/spans/addSpanNote.d.ts +5 -3
- package/dist/src/spans/addSpanNote.d.ts.map +1 -1
- package/dist/src/spans/addSpanNote.js +7 -4
- package/dist/src/spans/addSpanNote.js.map +1 -1
- package/dist/src/traces/addTraceAnnotation.d.ts +43 -0
- package/dist/src/traces/addTraceAnnotation.d.ts.map +1 -0
- package/dist/src/traces/addTraceAnnotation.js +47 -0
- package/dist/src/traces/addTraceAnnotation.js.map +1 -0
- package/dist/src/traces/addTraceNote.d.ts +5 -2
- package/dist/src/traces/addTraceNote.d.ts.map +1 -1
- package/dist/src/traces/addTraceNote.js +7 -3
- package/dist/src/traces/addTraceNote.js.map +1 -1
- package/dist/src/traces/index.d.ts +3 -0
- package/dist/src/traces/index.d.ts.map +1 -1
- package/dist/src/traces/index.js +2 -0
- package/dist/src/traces/index.js.map +1 -1
- package/dist/src/traces/logTraceAnnotations.d.ts +53 -0
- package/dist/src/traces/logTraceAnnotations.d.ts.map +1 -0
- package/dist/src/traces/logTraceAnnotations.js +53 -0
- package/dist/src/traces/logTraceAnnotations.js.map +1 -0
- package/dist/src/traces/types.d.ts +24 -0
- package/dist/src/traces/types.d.ts.map +1 -0
- package/dist/src/traces/types.js +42 -0
- package/dist/src/traces/types.js.map +1 -0
- package/dist/src/utils/apiErrorUtils.d.ts +2 -0
- package/dist/src/utils/apiErrorUtils.d.ts.map +1 -0
- package/dist/src/utils/apiErrorUtils.js +22 -0
- package/dist/src/utils/apiErrorUtils.js.map +1 -0
- 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 +30 -15
- package/src/constants/serverRequirements.ts +8 -0
- package/src/sessions/addSessionNote.ts +74 -0
- package/src/sessions/index.ts +1 -0
- package/src/spans/addSpanNote.ts +7 -4
- package/src/traces/addTraceAnnotation.ts +65 -0
- package/src/traces/addTraceNote.ts +7 -3
- package/src/traces/index.ts +3 -0
- package/src/traces/logTraceAnnotations.ts +75 -0
- package/src/traces/types.ts +72 -0
- package/src/utils/apiErrorUtils.ts +17 -0
|
@@ -18,6 +18,7 @@ export declare const DELETE_SESSIONS: RouteRequirement;
|
|
|
18
18
|
export declare const LIST_PROJECT_SESSIONS: RouteRequirement;
|
|
19
19
|
export declare const ANNOTATE_SESSIONS: RouteRequirement;
|
|
20
20
|
export declare const ADD_TRACE_NOTE: RouteRequirement;
|
|
21
|
+
export declare const ADD_SESSION_NOTE: RouteRequirement;
|
|
21
22
|
export declare const GET_SPANS_TRACE_IDS: ParameterRequirement;
|
|
22
23
|
export declare const GET_SPANS_FILTERS: ParameterRequirement;
|
|
23
24
|
export declare const LIST_PROJECT_TRACES: RouteRequirement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverRequirements.d.ts","sourceRoot":"","sources":["../../../src/constants/serverRequirements.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACV,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EACjB,MAAM,6BAA6B,CAAC;AAErC,eAAO,MAAM,WAAW,EAAE,gBAKzB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,gBAK5B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,gBAK7B,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,gBAKnC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,gBAK/B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,gBAK5B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,oBAMjC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,oBAM/B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,gBAKjC,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,oBAMpC,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,oBAMxC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAAS,qBAAqB,
|
|
1
|
+
{"version":3,"file":"serverRequirements.d.ts","sourceRoot":"","sources":["../../../src/constants/serverRequirements.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EACV,qBAAqB,EACrB,oBAAoB,EACpB,gBAAgB,EACjB,MAAM,6BAA6B,CAAC;AAErC,eAAO,MAAM,WAAW,EAAE,gBAKzB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,gBAK5B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,gBAK7B,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,gBAKnC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,gBAK/B,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,gBAK5B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,gBAK9B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,oBAMjC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,oBAM/B,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,gBAKjC,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,oBAMpC,CAAC;AAEF,eAAO,MAAM,0BAA0B,EAAE,oBAMxC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,SAAS,qBAAqB,EAanD,CAAC"}
|
|
@@ -47,6 +47,12 @@ export const ADD_TRACE_NOTE = {
|
|
|
47
47
|
path: "/v1/trace_notes",
|
|
48
48
|
minServerVersion: [14, 13, 0],
|
|
49
49
|
};
|
|
50
|
+
export const ADD_SESSION_NOTE = {
|
|
51
|
+
kind: "route",
|
|
52
|
+
method: "POST",
|
|
53
|
+
path: "/v1/session_notes",
|
|
54
|
+
minServerVersion: [14, 17, 0],
|
|
55
|
+
};
|
|
50
56
|
export const GET_SPANS_TRACE_IDS = {
|
|
51
57
|
kind: "parameter",
|
|
52
58
|
parameterName: "trace_id",
|
|
@@ -94,6 +100,7 @@ export const ALL_REQUIREMENTS = [
|
|
|
94
100
|
LIST_PROJECT_SESSIONS,
|
|
95
101
|
ANNOTATE_SESSIONS,
|
|
96
102
|
ADD_TRACE_NOTE,
|
|
103
|
+
ADD_SESSION_NOTE,
|
|
97
104
|
GET_SPANS_TRACE_IDS,
|
|
98
105
|
GET_SPANS_FILTERS,
|
|
99
106
|
GET_SPANS_BY_ATTRIBUTE,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverRequirements.js","sourceRo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,CAAC,EAAE,CAAC,CAAC;CAC7B,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAqC;IAChE,WAAW;IACX,cAAc;IACd,eAAe;IACf,qBAAqB;IACrB,iBAAiB;IACjB,cAAc;IACd,gBAAgB;IAChB,mBAAmB;IACnB,iBAAiB;IACjB,sBAAsB;IACtB,mBAAmB;IACnB,0BAA0B;CAClB,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ClientFn } from "../types/core.js";
|
|
2
|
+
/**
|
|
3
|
+
* Parameters for a single session note.
|
|
4
|
+
*/
|
|
5
|
+
export interface SessionNote {
|
|
6
|
+
/**
|
|
7
|
+
* The session ID used to track a conversation, thread, or session.
|
|
8
|
+
*/
|
|
9
|
+
sessionId: string;
|
|
10
|
+
/**
|
|
11
|
+
* The note text to add to the session.
|
|
12
|
+
*/
|
|
13
|
+
note: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Parameters to add a session note.
|
|
17
|
+
*/
|
|
18
|
+
export interface AddSessionNoteParams extends ClientFn {
|
|
19
|
+
sessionNote: SessionNote;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Add a note to a session.
|
|
23
|
+
*
|
|
24
|
+
* Notes are a special type of annotation that allow multiple entries per session.
|
|
25
|
+
* Each note gets a unique UUIDv4 identifier.
|
|
26
|
+
*
|
|
27
|
+
* @param params - The parameters to add a session note.
|
|
28
|
+
* @returns The ID of the created note annotation.
|
|
29
|
+
*
|
|
30
|
+
* @requires Phoenix server >= 14.17.0
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* const result = await addSessionNote({
|
|
35
|
+
* sessionNote: {
|
|
36
|
+
* sessionId: "my-session",
|
|
37
|
+
* note: "Needs review"
|
|
38
|
+
* }
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function addSessionNote({ client: _client, sessionNote, }: AddSessionNoteParams): Promise<{
|
|
43
|
+
id: string;
|
|
44
|
+
}>;
|
|
45
|
+
//# sourceMappingURL=addSessionNote.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addSessionNote.d.ts","sourceRoot":"","sources":["../../../src/sessions/addSessionNote.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAI9C;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,QAAQ;IACpD,WAAW,EAAE,WAAW,CAAC;CAC1B;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,cAAc,CAAC,EACnC,MAAM,EAAE,OAAO,EACf,WAAW,GACZ,EAAE,oBAAoB,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,CAsBhD"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { createClient } from "../client.js";
|
|
2
|
+
import { ADD_SESSION_NOTE } from "../constants/serverRequirements.js";
|
|
3
|
+
import { formatApiError } from "../utils/apiErrorUtils.js";
|
|
4
|
+
import { ensureServerCapability } from "../utils/serverVersionUtils.js";
|
|
5
|
+
/**
|
|
6
|
+
* Add a note to a session.
|
|
7
|
+
*
|
|
8
|
+
* Notes are a special type of annotation that allow multiple entries per session.
|
|
9
|
+
* Each note gets a unique UUIDv4 identifier.
|
|
10
|
+
*
|
|
11
|
+
* @param params - The parameters to add a session note.
|
|
12
|
+
* @returns The ID of the created note annotation.
|
|
13
|
+
*
|
|
14
|
+
* @requires Phoenix server >= 14.17.0
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* const result = await addSessionNote({
|
|
19
|
+
* sessionNote: {
|
|
20
|
+
* sessionId: "my-session",
|
|
21
|
+
* note: "Needs review"
|
|
22
|
+
* }
|
|
23
|
+
* });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export async function addSessionNote({ client: _client, sessionNote, }) {
|
|
27
|
+
const client = _client ?? createClient();
|
|
28
|
+
await ensureServerCapability({ client, requirement: ADD_SESSION_NOTE });
|
|
29
|
+
const { data, error } = await client.POST("/v1/session_notes", {
|
|
30
|
+
body: {
|
|
31
|
+
data: {
|
|
32
|
+
session_id: sessionNote.sessionId.trim(),
|
|
33
|
+
note: sessionNote.note,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
if (error) {
|
|
38
|
+
throw new Error(`Failed to add session note: ${formatApiError(error)}`);
|
|
39
|
+
}
|
|
40
|
+
if (!data?.data) {
|
|
41
|
+
throw new Error("Failed to add session note: no data returned");
|
|
42
|
+
}
|
|
43
|
+
return data.data;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=addSessionNote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addSessionNote.js","sourceRoot":"","sources":["../../../src/sessions/addSessionNote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAuBrE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,EACnC,MAAM,EAAE,OAAO,EACf,WAAW,GACU;IACrB,MAAM,MAAM,GAAG,OAAO,IAAI,YAAY,EAAE,CAAC;IACzC,MAAM,sBAAsB,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC,CAAC;IAExE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,mBAAmB,EAAE;QAC7D,IAAI,EAAE;YACJ,IAAI,EAAE;gBACJ,UAAU,EAAE,WAAW,CAAC,SAAS,CAAC,IAAI,EAAE;gBACxC,IAAI,EAAE,WAAW,CAAC,IAAI;aACvB;SACF;KACF,CAAC,CAAC;IAEH,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,+BAA+B,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,CAAC;IAED,OAAO,IAAI,CAAC,IAAI,CAAC;AACnB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sessions/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sessions/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sessions/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sessions/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC"}
|
|
@@ -21,9 +21,11 @@ export interface AddSpanNoteParams extends ClientFn {
|
|
|
21
21
|
/**
|
|
22
22
|
* Add a note to a span.
|
|
23
23
|
*
|
|
24
|
-
* Notes are
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* Notes are append-only: each call creates a new note with an auto-generated
|
|
25
|
+
* UUIDv4 identifier, so multiple notes accumulate on the same span. Structured
|
|
26
|
+
* annotations, by contrast, are keyed by `(name, spanId, identifier)` — to keep
|
|
27
|
+
* multiple structured annotations with the same name on a span, supply distinct
|
|
28
|
+
* identifiers; otherwise re-writing the same name overwrites the existing one.
|
|
27
29
|
*
|
|
28
30
|
* @param params - The parameters to add a span note
|
|
29
31
|
* @returns The ID of the created note annotation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addSpanNote.d.ts","sourceRoot":"","sources":["../../../src/spans/addSpanNote.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"addSpanNote.d.ts","sourceRoot":"","sources":["../../../src/spans/addSpanNote.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAG9C;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,QAAQ;IACjD,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,WAAW,CAAC,EAChC,MAAM,EAAE,OAAO,EACf,QAAQ,GACT,EAAE,iBAAiB,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,CAqB7C"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { createClient } from "../client.js";
|
|
2
|
+
import { formatApiError } from "../utils/apiErrorUtils.js";
|
|
2
3
|
/**
|
|
3
4
|
* Add a note to a span.
|
|
4
5
|
*
|
|
5
|
-
* Notes are
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Notes are append-only: each call creates a new note with an auto-generated
|
|
7
|
+
* UUIDv4 identifier, so multiple notes accumulate on the same span. Structured
|
|
8
|
+
* annotations, by contrast, are keyed by `(name, spanId, identifier)` — to keep
|
|
9
|
+
* multiple structured annotations with the same name on a span, supply distinct
|
|
10
|
+
* identifiers; otherwise re-writing the same name overwrites the existing one.
|
|
8
11
|
*
|
|
9
12
|
* @param params - The parameters to add a span note
|
|
10
13
|
* @returns The ID of the created note annotation
|
|
@@ -30,7 +33,7 @@ export async function addSpanNote({ client: _client, spanNote, }) {
|
|
|
30
33
|
},
|
|
31
34
|
});
|
|
32
35
|
if (error) {
|
|
33
|
-
throw new Error(`Failed to add span note: ${error}`);
|
|
36
|
+
throw new Error(`Failed to add span note: ${formatApiError(error)}`);
|
|
34
37
|
}
|
|
35
38
|
if (!data?.data) {
|
|
36
39
|
throw new Error("Failed to add span note: no data returned");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addSpanNote.js","sourceRoot":"","sources":["../../../src/spans/addSpanNote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"addSpanNote.js","sourceRoot":"","sources":["../../../src/spans/addSpanNote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAuBxD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,EAChC,MAAM,EAAE,OAAO,EACf,QAAQ,GACU;IAClB,MAAM,MAAM,GAAG,OAAO,IAAI,YAAY,EAAE,CAAC;IAEzC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,gBAAgB,EAAE;QAC1D,IAAI,EAAE;YACJ,IAAI,EAAE;gBACJ,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE;gBAC/B,IAAI,EAAE,QAAQ,CAAC,IAAI;aACpB;SACF;KACF,CAAC,CAAC;IAEH,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,4BAA4B,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACvE,CAAC;IAED,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC/D,CAAC;IAED,OAAO,IAAI,CAAC,IAAI,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ClientFn } from "../types/core.js";
|
|
2
|
+
import type { TraceAnnotation } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Parameters to add a trace annotation
|
|
5
|
+
*/
|
|
6
|
+
export interface AddTraceAnnotationParams extends ClientFn {
|
|
7
|
+
traceAnnotation: TraceAnnotation;
|
|
8
|
+
/**
|
|
9
|
+
* If true, the request will be fulfilled synchronously and return the annotation ID.
|
|
10
|
+
* If false, the request will be processed asynchronously and return null.
|
|
11
|
+
* @default false
|
|
12
|
+
*/
|
|
13
|
+
sync?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Add an annotation to a trace.
|
|
17
|
+
*
|
|
18
|
+
* The annotation can be of type "LLM", "CODE", or "HUMAN" and can include a label, score, and metadata.
|
|
19
|
+
* If an identifier is provided and an annotation with that identifier already exists, it will be updated.
|
|
20
|
+
*
|
|
21
|
+
* @param params - The parameters to add a trace annotation
|
|
22
|
+
* @returns The ID of the created or updated annotation
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const result = await addTraceAnnotation({
|
|
27
|
+
* traceAnnotation: {
|
|
28
|
+
* traceId: "abc123",
|
|
29
|
+
* name: "correctness",
|
|
30
|
+
* label: "correct",
|
|
31
|
+
* score: 1.0,
|
|
32
|
+
* annotatorKind: "HUMAN",
|
|
33
|
+
* identifier: "custom_id_123",
|
|
34
|
+
* metadata: { reviewer: "alice" }
|
|
35
|
+
* },
|
|
36
|
+
* sync: true,
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function addTraceAnnotation({ client: _client, traceAnnotation, sync, }: AddTraceAnnotationParams): Promise<{
|
|
41
|
+
id: string;
|
|
42
|
+
} | null>;
|
|
43
|
+
//# sourceMappingURL=addTraceAnnotation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addTraceAnnotation.d.ts","sourceRoot":"","sources":["../../../src/traces/addTraceAnnotation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG/C;;GAEG;AACH,MAAM,WAAW,wBAAyB,SAAQ,QAAQ;IACxD,eAAe,EAAE,eAAe,CAAC;IACjC;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,MAAM,EAAE,OAAO,EACf,eAAe,EACf,IAAY,GACb,EAAE,wBAAwB,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CAiB3D"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { createClient } from "../client.js";
|
|
2
|
+
import { toTraceAnnotationData } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Add an annotation to a trace.
|
|
5
|
+
*
|
|
6
|
+
* The annotation can be of type "LLM", "CODE", or "HUMAN" and can include a label, score, and metadata.
|
|
7
|
+
* If an identifier is provided and an annotation with that identifier already exists, it will be updated.
|
|
8
|
+
*
|
|
9
|
+
* @param params - The parameters to add a trace annotation
|
|
10
|
+
* @returns The ID of the created or updated annotation
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const result = await addTraceAnnotation({
|
|
15
|
+
* traceAnnotation: {
|
|
16
|
+
* traceId: "abc123",
|
|
17
|
+
* name: "correctness",
|
|
18
|
+
* label: "correct",
|
|
19
|
+
* score: 1.0,
|
|
20
|
+
* annotatorKind: "HUMAN",
|
|
21
|
+
* identifier: "custom_id_123",
|
|
22
|
+
* metadata: { reviewer: "alice" }
|
|
23
|
+
* },
|
|
24
|
+
* sync: true,
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export async function addTraceAnnotation({ client: _client, traceAnnotation, sync = false, }) {
|
|
29
|
+
const client = _client ?? createClient();
|
|
30
|
+
const { data, error } = await client.POST("/v1/trace_annotations", {
|
|
31
|
+
params: {
|
|
32
|
+
query: { sync },
|
|
33
|
+
},
|
|
34
|
+
body: {
|
|
35
|
+
data: [toTraceAnnotationData(traceAnnotation)],
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
if (error) {
|
|
39
|
+
throw new Error(`Failed to add trace annotation: ${error}`);
|
|
40
|
+
}
|
|
41
|
+
return data?.data?.[0] || null;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=addTraceAnnotation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addTraceAnnotation.js","sourceRoot":"","sources":["../../../src/traces/addTraceAnnotation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAehD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,EACvC,MAAM,EAAE,OAAO,EACf,eAAe,EACf,IAAI,GAAG,KAAK,GACa;IACzB,MAAM,MAAM,GAAG,OAAO,IAAI,YAAY,EAAE,CAAC;IAEzC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,uBAAuB,EAAE;QACjE,MAAM,EAAE;YACN,KAAK,EAAE,EAAE,IAAI,EAAE;SAChB;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,CAAC,qBAAqB,CAAC,eAAe,CAAC,CAAC;SAC/C;KACF,CAAC,CAAC;IAEH,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,mCAAmC,KAAK,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AACjC,CAAC"}
|
|
@@ -21,8 +21,11 @@ export interface AddTraceNoteParams extends ClientFn {
|
|
|
21
21
|
/**
|
|
22
22
|
* Add a note to a trace.
|
|
23
23
|
*
|
|
24
|
-
* Notes are
|
|
25
|
-
*
|
|
24
|
+
* Notes are append-only: each call creates a new note with an auto-generated
|
|
25
|
+
* UUIDv4 identifier, so multiple notes accumulate on the same trace. Structured
|
|
26
|
+
* annotations, by contrast, are keyed by `(name, traceId, identifier)` — to keep
|
|
27
|
+
* multiple structured annotations with the same name on a trace, supply distinct
|
|
28
|
+
* identifiers; otherwise re-writing the same name overwrites the existing one.
|
|
26
29
|
*
|
|
27
30
|
* @param params - The parameters to add a trace note.
|
|
28
31
|
* @returns The ID of the created note annotation.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addTraceNote.d.ts","sourceRoot":"","sources":["../../../src/traces/addTraceNote.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"addTraceNote.d.ts","sourceRoot":"","sources":["../../../src/traces/addTraceNote.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAI9C;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,QAAQ;IAClD,SAAS,EAAE,SAAS,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,YAAY,CAAC,EACjC,MAAM,EAAE,OAAO,EACf,SAAS,GACV,EAAE,kBAAkB,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC,CAsB9C"}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { createClient } from "../client.js";
|
|
2
2
|
import { ADD_TRACE_NOTE } from "../constants/serverRequirements.js";
|
|
3
|
+
import { formatApiError } from "../utils/apiErrorUtils.js";
|
|
3
4
|
import { ensureServerCapability } from "../utils/serverVersionUtils.js";
|
|
4
5
|
/**
|
|
5
6
|
* Add a note to a trace.
|
|
6
7
|
*
|
|
7
|
-
* Notes are
|
|
8
|
-
*
|
|
8
|
+
* Notes are append-only: each call creates a new note with an auto-generated
|
|
9
|
+
* UUIDv4 identifier, so multiple notes accumulate on the same trace. Structured
|
|
10
|
+
* annotations, by contrast, are keyed by `(name, traceId, identifier)` — to keep
|
|
11
|
+
* multiple structured annotations with the same name on a trace, supply distinct
|
|
12
|
+
* identifiers; otherwise re-writing the same name overwrites the existing one.
|
|
9
13
|
*
|
|
10
14
|
* @param params - The parameters to add a trace note.
|
|
11
15
|
* @returns The ID of the created note annotation.
|
|
@@ -32,7 +36,7 @@ export async function addTraceNote({ client: _client, traceNote, }) {
|
|
|
32
36
|
},
|
|
33
37
|
});
|
|
34
38
|
if (error) {
|
|
35
|
-
throw new Error(`Failed to add trace note: ${error}`);
|
|
39
|
+
throw new Error(`Failed to add trace note: ${formatApiError(error)}`);
|
|
36
40
|
}
|
|
37
41
|
if (!data?.data) {
|
|
38
42
|
throw new Error("Failed to add trace note: no data returned");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addTraceNote.js","sourceRoot":"","sources":["../../../src/traces/addTraceNote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAuBrE
|
|
1
|
+
{"version":3,"file":"addTraceNote.js","sourceRoot":"","sources":["../../../src/traces/addTraceNote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEjE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAuBrE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,EACjC,MAAM,EAAE,OAAO,EACf,SAAS,GACU;IACnB,MAAM,MAAM,GAAG,OAAO,IAAI,YAAY,EAAE,CAAC;IACzC,MAAM,sBAAsB,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC,CAAC;IAEtE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,iBAAiB,EAAE;QAC3D,IAAI,EAAE;YACJ,IAAI,EAAE;gBACJ,QAAQ,EAAE,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE;gBAClC,IAAI,EAAE,SAAS,CAAC,IAAI;aACrB;SACF;KACF,CAAC,CAAC;IAEH,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,6BAA6B,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACxE,CAAC;IAED,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,IAAI,CAAC,IAAI,CAAC;AACnB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/traces/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/traces/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC;AACtC,YAAY,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/esm/traces/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/traces/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/traces/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { ClientFn } from "../types/core.js";
|
|
2
|
+
import type { TraceAnnotation } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Parameters to log multiple trace annotations
|
|
5
|
+
*/
|
|
6
|
+
export interface LogTraceAnnotationsParams extends ClientFn {
|
|
7
|
+
/**
|
|
8
|
+
* The trace annotations to log
|
|
9
|
+
*/
|
|
10
|
+
traceAnnotations: TraceAnnotation[];
|
|
11
|
+
/**
|
|
12
|
+
* If true, the request will be fulfilled synchronously and return the annotation IDs.
|
|
13
|
+
* If false, the request will be processed asynchronously and return null.
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
sync?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Log multiple trace annotations in a single request.
|
|
20
|
+
*
|
|
21
|
+
* Each annotation can be of type "LLM", "CODE", or "HUMAN" and can include a label, score, and metadata.
|
|
22
|
+
* If an identifier is provided and an annotation with that identifier already exists, it will be updated.
|
|
23
|
+
*
|
|
24
|
+
* @param params - The parameters to log trace annotations
|
|
25
|
+
* @returns The IDs of the created or updated annotations
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const results = await logTraceAnnotations({
|
|
30
|
+
* traceAnnotations: [
|
|
31
|
+
* {
|
|
32
|
+
* traceId: "abc123",
|
|
33
|
+
* name: "correctness",
|
|
34
|
+
* label: "correct",
|
|
35
|
+
* score: 1.0,
|
|
36
|
+
* annotatorKind: "HUMAN",
|
|
37
|
+
* },
|
|
38
|
+
* {
|
|
39
|
+
* traceId: "def456",
|
|
40
|
+
* name: "faithfulness",
|
|
41
|
+
* label: "faithful",
|
|
42
|
+
* score: 0.9,
|
|
43
|
+
* annotatorKind: "LLM",
|
|
44
|
+
* },
|
|
45
|
+
* ],
|
|
46
|
+
* sync: true,
|
|
47
|
+
* });
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function logTraceAnnotations({ client: _client, traceAnnotations, sync, }: LogTraceAnnotationsParams): Promise<{
|
|
51
|
+
id: string;
|
|
52
|
+
}[]>;
|
|
53
|
+
//# sourceMappingURL=logTraceAnnotations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logTraceAnnotations.d.ts","sourceRoot":"","sources":["../../../src/traces/logTraceAnnotations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAG/C;;GAEG;AACH,MAAM,WAAW,yBAA0B,SAAQ,QAAQ;IACzD;;OAEG;IACH,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAsB,mBAAmB,CAAC,EACxC,MAAM,EAAE,OAAO,EACf,gBAAgB,EAChB,IAAY,GACb,EAAE,yBAAyB,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC,CAiBvD"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { createClient } from "../client.js";
|
|
2
|
+
import { toTraceAnnotationData } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Log multiple trace annotations in a single request.
|
|
5
|
+
*
|
|
6
|
+
* Each annotation can be of type "LLM", "CODE", or "HUMAN" and can include a label, score, and metadata.
|
|
7
|
+
* If an identifier is provided and an annotation with that identifier already exists, it will be updated.
|
|
8
|
+
*
|
|
9
|
+
* @param params - The parameters to log trace annotations
|
|
10
|
+
* @returns The IDs of the created or updated annotations
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const results = await logTraceAnnotations({
|
|
15
|
+
* traceAnnotations: [
|
|
16
|
+
* {
|
|
17
|
+
* traceId: "abc123",
|
|
18
|
+
* name: "correctness",
|
|
19
|
+
* label: "correct",
|
|
20
|
+
* score: 1.0,
|
|
21
|
+
* annotatorKind: "HUMAN",
|
|
22
|
+
* },
|
|
23
|
+
* {
|
|
24
|
+
* traceId: "def456",
|
|
25
|
+
* name: "faithfulness",
|
|
26
|
+
* label: "faithful",
|
|
27
|
+
* score: 0.9,
|
|
28
|
+
* annotatorKind: "LLM",
|
|
29
|
+
* },
|
|
30
|
+
* ],
|
|
31
|
+
* sync: true,
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export async function logTraceAnnotations({ client: _client, traceAnnotations, sync = false, }) {
|
|
36
|
+
const client = _client ?? createClient();
|
|
37
|
+
const { data, error } = await client.POST("/v1/trace_annotations", {
|
|
38
|
+
params: {
|
|
39
|
+
query: { sync },
|
|
40
|
+
},
|
|
41
|
+
body: {
|
|
42
|
+
data: traceAnnotations.map(toTraceAnnotationData),
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
if (error) {
|
|
46
|
+
throw new Error(`Failed to log trace annotations: ${error}`);
|
|
47
|
+
}
|
|
48
|
+
return data?.data || [];
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=logTraceAnnotations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logTraceAnnotations.js","sourceRoot":"","sources":["../../../src/traces/logTraceAnnotations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAkBhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,EACxC,MAAM,EAAE,OAAO,EACf,gBAAgB,EAChB,IAAI,GAAG,KAAK,GACc;IAC1B,MAAM,MAAM,GAAG,OAAO,IAAI,YAAY,EAAE,CAAC;IAEzC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,uBAAuB,EAAE;QACjE,MAAM,EAAE;YACN,KAAK,EAAE,EAAE,IAAI,EAAE;SAChB;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,gBAAgB,CAAC,GAAG,CAAC,qBAAqB,CAAC;SAClD;KACF,CAAC,CAAC;IAEH,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,oCAAoC,KAAK,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED,OAAO,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { paths } from "../__generated__/api/v1.js";
|
|
2
|
+
import type { Annotation } from "../types/annotations.js";
|
|
3
|
+
type TraceAnnotationData = paths["/v1/trace_annotations"]["post"]["requestBody"]["content"]["application/json"]["data"][0];
|
|
4
|
+
/**
|
|
5
|
+
* Parameters for a single trace annotation
|
|
6
|
+
*/
|
|
7
|
+
export interface TraceAnnotation extends Annotation {
|
|
8
|
+
/**
|
|
9
|
+
* The OpenTelemetry Trace ID (hex format without 0x prefix)
|
|
10
|
+
*/
|
|
11
|
+
traceId: string;
|
|
12
|
+
/**
|
|
13
|
+
* The kind of annotator used for the annotation
|
|
14
|
+
* Can be "HUMAN", "LLM", or "CODE"
|
|
15
|
+
* @default "HUMAN"
|
|
16
|
+
*/
|
|
17
|
+
annotatorKind?: TraceAnnotationData["annotator_kind"];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Convert a TraceAnnotation to the API format
|
|
21
|
+
*/
|
|
22
|
+
export declare function toTraceAnnotationData(annotation: TraceAnnotation): TraceAnnotationData;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/traces/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAoB,MAAM,sBAAsB,CAAC;AAEzE,KAAK,mBAAmB,GACtB,KAAK,CAAC,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAElG;;GAEG;AACH,MAAM,WAAW,eAAgB,SAAQ,UAAU;IACjD;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,aAAa,CAAC,EAAE,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;CACvD;AA8BD;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,eAAe,GAC1B,mBAAmB,CAgBrB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build and validate annotation result fields
|
|
3
|
+
*/
|
|
4
|
+
function buildTraceAnnotationResult(annotation) {
|
|
5
|
+
const result = {};
|
|
6
|
+
if (annotation.label !== undefined) {
|
|
7
|
+
result.label = annotation.label.trim() || null;
|
|
8
|
+
}
|
|
9
|
+
if (annotation.score !== undefined) {
|
|
10
|
+
result.score = annotation.score;
|
|
11
|
+
}
|
|
12
|
+
if (annotation.explanation !== undefined) {
|
|
13
|
+
result.explanation = annotation.explanation.trim() || null;
|
|
14
|
+
}
|
|
15
|
+
const hasValidResult = result.label || result.score !== undefined || result.explanation;
|
|
16
|
+
if (!hasValidResult) {
|
|
17
|
+
throw new Error("At least one of label, score, or explanation must be provided for trace annotation");
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Convert a TraceAnnotation to the API format
|
|
23
|
+
*/
|
|
24
|
+
export function toTraceAnnotationData(annotation) {
|
|
25
|
+
if (annotation.name.trim() === "note") {
|
|
26
|
+
throw new Error('The name "note" is reserved for trace and span notes. Use addTraceNote instead.');
|
|
27
|
+
}
|
|
28
|
+
const result = buildTraceAnnotationResult(annotation);
|
|
29
|
+
return {
|
|
30
|
+
trace_id: annotation.traceId.trim(),
|
|
31
|
+
name: annotation.name.trim(),
|
|
32
|
+
annotator_kind: annotation.annotatorKind ?? "HUMAN",
|
|
33
|
+
result,
|
|
34
|
+
metadata: annotation.metadata ?? null,
|
|
35
|
+
identifier: annotation.identifier?.trim() ?? "",
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/traces/types.ts"],"names":[],"mappings":"AAsBA;;GAEG;AACH,SAAS,0BAA0B,CACjC,UAAoE;IAEpE,MAAM,MAAM,GAAqB,EAAE,CAAC;IAEpC,IAAI,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACnC,MAAM,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,IAAI,CAAC;IACjD,CAAC;IACD,IAAI,UAAU,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QACnC,MAAM,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;IAClC,CAAC;IACD,IAAI,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QACzC,MAAM,CAAC,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,IAAI,CAAC;IAC7D,CAAC;IAED,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