@arizeai/phoenix-client 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -1
- package/dist/esm/__generated__/api/v1.d.ts +185 -47
- package/dist/esm/__generated__/api/v1.d.ts.map +1 -1
- package/dist/esm/spans/addDocumentAnnotation.d.ts +45 -0
- package/dist/esm/spans/addDocumentAnnotation.d.ts.map +1 -0
- package/dist/esm/spans/addDocumentAnnotation.js +45 -0
- package/dist/esm/spans/addDocumentAnnotation.js.map +1 -0
- package/dist/esm/spans/addSpanAnnotation.d.ts +8 -2
- package/dist/esm/spans/addSpanAnnotation.d.ts.map +1 -1
- package/dist/esm/spans/addSpanAnnotation.js +5 -5
- package/dist/esm/spans/addSpanAnnotation.js.map +1 -1
- package/dist/esm/spans/index.d.ts +2 -0
- package/dist/esm/spans/index.d.ts.map +1 -1
- package/dist/esm/spans/index.js +2 -0
- package/dist/esm/spans/index.js.map +1 -1
- package/dist/esm/spans/logDocumentAnnotations.d.ts +58 -0
- package/dist/esm/spans/logDocumentAnnotations.d.ts.map +1 -0
- package/dist/esm/spans/logDocumentAnnotations.js +55 -0
- package/dist/esm/spans/logDocumentAnnotations.js.map +1 -0
- package/dist/esm/spans/logSpanAnnotations.d.ts +7 -1
- package/dist/esm/spans/logSpanAnnotations.d.ts.map +1 -1
- package/dist/esm/spans/logSpanAnnotations.js +5 -5
- package/dist/esm/spans/logSpanAnnotations.js.map +1 -1
- package/dist/esm/spans/types.d.ts +48 -0
- package/dist/esm/spans/types.d.ts.map +1 -1
- package/dist/esm/spans/types.js +41 -8
- package/dist/esm/spans/types.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 +185 -47
- package/dist/src/__generated__/api/v1.d.ts.map +1 -1
- package/dist/src/spans/addDocumentAnnotation.d.ts +45 -0
- package/dist/src/spans/addDocumentAnnotation.d.ts.map +1 -0
- package/dist/src/spans/addDocumentAnnotation.js +49 -0
- package/dist/src/spans/addDocumentAnnotation.js.map +1 -0
- package/dist/src/spans/addSpanAnnotation.d.ts +8 -2
- package/dist/src/spans/addSpanAnnotation.d.ts.map +1 -1
- package/dist/src/spans/addSpanAnnotation.js +6 -6
- package/dist/src/spans/addSpanAnnotation.js.map +1 -1
- package/dist/src/spans/index.d.ts +2 -0
- package/dist/src/spans/index.d.ts.map +1 -1
- package/dist/src/spans/index.js +2 -0
- package/dist/src/spans/index.js.map +1 -1
- package/dist/src/spans/logDocumentAnnotations.d.ts +58 -0
- package/dist/src/spans/logDocumentAnnotations.d.ts.map +1 -0
- package/dist/src/spans/logDocumentAnnotations.js +58 -0
- package/dist/src/spans/logDocumentAnnotations.js.map +1 -0
- package/dist/src/spans/logSpanAnnotations.d.ts +7 -1
- package/dist/src/spans/logSpanAnnotations.d.ts.map +1 -1
- package/dist/src/spans/logSpanAnnotations.js +5 -6
- package/dist/src/spans/logSpanAnnotations.js.map +1 -1
- package/dist/src/spans/types.d.ts +48 -0
- package/dist/src/spans/types.d.ts.map +1 -1
- package/dist/src/spans/types.js +45 -10
- package/dist/src/spans/types.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.d.ts +1240 -1238
- package/src/__generated__/api/v1.ts +185 -47
- package/src/spans/addDocumentAnnotation.ts +66 -0
- package/src/spans/addSpanAnnotation.ts +12 -6
- package/src/spans/index.ts +2 -0
- package/src/spans/logDocumentAnnotations.ts +79 -0
- package/src/spans/logSpanAnnotations.ts +11 -5
- package/src/spans/types.ts +112 -8
package/dist/src/spans/index.js
CHANGED
|
@@ -16,6 +16,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./addSpanAnnotation"), exports);
|
|
18
18
|
__exportStar(require("./logSpanAnnotations"), exports);
|
|
19
|
+
__exportStar(require("./addDocumentAnnotation"), exports);
|
|
20
|
+
__exportStar(require("./logDocumentAnnotations"), exports);
|
|
19
21
|
__exportStar(require("./getSpans"), exports);
|
|
20
22
|
__exportStar(require("./getSpanAnnotations"), exports);
|
|
21
23
|
__exportStar(require("./deleteSpan"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/spans/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,uDAAqC;AACrC,6CAA2B;AAC3B,uDAAqC;AACrC,+CAA6B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/spans/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAoC;AACpC,uDAAqC;AACrC,0DAAwC;AACxC,2DAAyC;AACzC,6CAA2B;AAC3B,uDAAqC;AACrC,+CAA6B"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ClientFn } from "../types/core";
|
|
2
|
+
import { DocumentAnnotation } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Parameters to log multiple document annotations
|
|
5
|
+
*/
|
|
6
|
+
export interface LogDocumentAnnotationsParams extends ClientFn {
|
|
7
|
+
/**
|
|
8
|
+
* The document annotations to log
|
|
9
|
+
*/
|
|
10
|
+
documentAnnotations: DocumentAnnotation[];
|
|
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 document annotations in a single request.
|
|
20
|
+
*
|
|
21
|
+
* Each annotation can be of type "LLM", "CODE", or "HUMAN" and can include a label, score, explanation, and metadata.
|
|
22
|
+
* At least one of label, score, or explanation must be provided for each annotation.
|
|
23
|
+
*
|
|
24
|
+
* @param params - The parameters to log document annotations
|
|
25
|
+
* @returns The IDs of the created annotations
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const results = await logDocumentAnnotations({
|
|
30
|
+
* documentAnnotations: [
|
|
31
|
+
* {
|
|
32
|
+
* spanId: "123abc",
|
|
33
|
+
* documentPosition: 0,
|
|
34
|
+
* name: "relevance_score",
|
|
35
|
+
* label: "relevant",
|
|
36
|
+
* score: 0.95,
|
|
37
|
+
* annotatorKind: "LLM",
|
|
38
|
+
* explanation: "Document is highly relevant to the query",
|
|
39
|
+
* metadata: {
|
|
40
|
+
* model: "gpt-4"
|
|
41
|
+
* }
|
|
42
|
+
* },
|
|
43
|
+
* {
|
|
44
|
+
* spanId: "123abc",
|
|
45
|
+
* documentPosition: 1,
|
|
46
|
+
* name: "relevance_score",
|
|
47
|
+
* label: "somewhat_relevant",
|
|
48
|
+
* score: 0.6,
|
|
49
|
+
* annotatorKind: "LLM"
|
|
50
|
+
* }
|
|
51
|
+
* ]
|
|
52
|
+
* });
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function logDocumentAnnotations({ client: _client, documentAnnotations, sync, }: LogDocumentAnnotationsParams): Promise<{
|
|
56
|
+
id: string;
|
|
57
|
+
}[]>;
|
|
58
|
+
//# sourceMappingURL=logDocumentAnnotations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logDocumentAnnotations.d.ts","sourceRoot":"","sources":["../../../src/spans/logDocumentAnnotations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAA4B,MAAM,SAAS,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,4BAA6B,SAAQ,QAAQ;IAC5D;;OAEG;IACH,mBAAmB,EAAE,kBAAkB,EAAE,CAAC;IAC1C;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAsB,sBAAsB,CAAC,EAC3C,MAAM,EAAE,OAAO,EACf,mBAAmB,EACnB,IAAY,GACb,EAAE,4BAA4B,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC,CAiB1D"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.logDocumentAnnotations = logDocumentAnnotations;
|
|
4
|
+
const client_1 = require("../client");
|
|
5
|
+
const types_1 = require("./types");
|
|
6
|
+
/**
|
|
7
|
+
* Log multiple document annotations in a single request.
|
|
8
|
+
*
|
|
9
|
+
* Each annotation can be of type "LLM", "CODE", or "HUMAN" and can include a label, score, explanation, and metadata.
|
|
10
|
+
* At least one of label, score, or explanation must be provided for each annotation.
|
|
11
|
+
*
|
|
12
|
+
* @param params - The parameters to log document annotations
|
|
13
|
+
* @returns The IDs of the created annotations
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const results = await logDocumentAnnotations({
|
|
18
|
+
* documentAnnotations: [
|
|
19
|
+
* {
|
|
20
|
+
* spanId: "123abc",
|
|
21
|
+
* documentPosition: 0,
|
|
22
|
+
* name: "relevance_score",
|
|
23
|
+
* label: "relevant",
|
|
24
|
+
* score: 0.95,
|
|
25
|
+
* annotatorKind: "LLM",
|
|
26
|
+
* explanation: "Document is highly relevant to the query",
|
|
27
|
+
* metadata: {
|
|
28
|
+
* model: "gpt-4"
|
|
29
|
+
* }
|
|
30
|
+
* },
|
|
31
|
+
* {
|
|
32
|
+
* spanId: "123abc",
|
|
33
|
+
* documentPosition: 1,
|
|
34
|
+
* name: "relevance_score",
|
|
35
|
+
* label: "somewhat_relevant",
|
|
36
|
+
* score: 0.6,
|
|
37
|
+
* annotatorKind: "LLM"
|
|
38
|
+
* }
|
|
39
|
+
* ]
|
|
40
|
+
* });
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
async function logDocumentAnnotations({ client: _client, documentAnnotations, sync = false, }) {
|
|
44
|
+
const client = _client !== null && _client !== void 0 ? _client : (0, client_1.createClient)();
|
|
45
|
+
const { data, error } = await client.POST("/v1/document_annotations", {
|
|
46
|
+
params: {
|
|
47
|
+
query: { sync },
|
|
48
|
+
},
|
|
49
|
+
body: {
|
|
50
|
+
data: documentAnnotations.map(types_1.toDocumentAnnotationData),
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
if (error) {
|
|
54
|
+
throw new Error(`Failed to log document annotations: ${error}`);
|
|
55
|
+
}
|
|
56
|
+
return (data === null || data === void 0 ? void 0 : data.data) || [];
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=logDocumentAnnotations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logDocumentAnnotations.js","sourceRoot":"","sources":["../../../src/spans/logDocumentAnnotations.ts"],"names":[],"mappings":";;AAyDA,wDAqBC;AA9ED,sCAAyC;AAEzC,mCAAuE;AAkBvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACI,KAAK,UAAU,sBAAsB,CAAC,EAC3C,MAAM,EAAE,OAAO,EACf,mBAAmB,EACnB,IAAI,GAAG,KAAK,GACiB;IAC7B,MAAM,MAAM,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,IAAA,qBAAY,GAAE,CAAC;IAEzC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,0BAA0B,EAAE;QACpE,MAAM,EAAE;YACN,KAAK,EAAE,EAAE,IAAI,EAAE;SAChB;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,mBAAmB,CAAC,GAAG,CAAC,gCAAwB,CAAC;SACxD;KACF,CAAC,CAAC;IAEH,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,uCAAuC,KAAK,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,OAAO,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,KAAI,EAAE,CAAC;AAC1B,CAAC"}
|
|
@@ -8,6 +8,12 @@ export interface LogSpanAnnotationsParams extends ClientFn {
|
|
|
8
8
|
* The span annotations to log
|
|
9
9
|
*/
|
|
10
10
|
spanAnnotations: SpanAnnotation[];
|
|
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;
|
|
11
17
|
}
|
|
12
18
|
/**
|
|
13
19
|
* Log multiple span annotations in a single request.
|
|
@@ -44,7 +50,7 @@ export interface LogSpanAnnotationsParams extends ClientFn {
|
|
|
44
50
|
* });
|
|
45
51
|
* ```
|
|
46
52
|
*/
|
|
47
|
-
export declare function logSpanAnnotations({ client: _client, spanAnnotations, }: LogSpanAnnotationsParams): Promise<{
|
|
53
|
+
export declare function logSpanAnnotations({ client: _client, spanAnnotations, sync, }: LogSpanAnnotationsParams): Promise<{
|
|
48
54
|
id: string;
|
|
49
55
|
}[]>;
|
|
50
56
|
//# sourceMappingURL=logSpanAnnotations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logSpanAnnotations.d.ts","sourceRoot":"","sources":["../../../src/spans/logSpanAnnotations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,cAAc,EAAwB,MAAM,SAAS,CAAC;AAE/D;;GAEG;AACH,MAAM,WAAW,wBAAyB,SAAQ,QAAQ;IACxD;;OAEG;IACH,eAAe,EAAE,cAAc,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"logSpanAnnotations.d.ts","sourceRoot":"","sources":["../../../src/spans/logSpanAnnotations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,cAAc,EAAwB,MAAM,SAAS,CAAC;AAE/D;;GAEG;AACH,MAAM,WAAW,wBAAyB,SAAQ,QAAQ;IACxD;;OAEG;IACH,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAsB,kBAAkB,CAAC,EACvC,MAAM,EAAE,OAAO,EACf,eAAe,EACf,IAAY,GACb,EAAE,wBAAwB,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EAAE,CAAC,CAiBtD"}
|
|
@@ -38,10 +38,12 @@ const types_1 = require("./types");
|
|
|
38
38
|
* });
|
|
39
39
|
* ```
|
|
40
40
|
*/
|
|
41
|
-
async function logSpanAnnotations({ client: _client, spanAnnotations, }) {
|
|
42
|
-
var _a;
|
|
41
|
+
async function logSpanAnnotations({ client: _client, spanAnnotations, sync = false, }) {
|
|
43
42
|
const client = _client !== null && _client !== void 0 ? _client : (0, client_1.createClient)();
|
|
44
43
|
const { data, error } = await client.POST("/v1/span_annotations", {
|
|
44
|
+
params: {
|
|
45
|
+
query: { sync },
|
|
46
|
+
},
|
|
45
47
|
body: {
|
|
46
48
|
data: spanAnnotations.map(types_1.toSpanAnnotationData),
|
|
47
49
|
},
|
|
@@ -49,9 +51,6 @@ async function logSpanAnnotations({ client: _client, spanAnnotations, }) {
|
|
|
49
51
|
if (error) {
|
|
50
52
|
throw new Error(`Failed to log span annotations: ${error}`);
|
|
51
53
|
}
|
|
52
|
-
|
|
53
|
-
throw new Error("No annotation IDs returned from server");
|
|
54
|
-
}
|
|
55
|
-
return data.data;
|
|
54
|
+
return (data === null || data === void 0 ? void 0 : data.data) || [];
|
|
56
55
|
}
|
|
57
56
|
//# sourceMappingURL=logSpanAnnotations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logSpanAnnotations.js","sourceRoot":"","sources":["../../../src/spans/logSpanAnnotations.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"logSpanAnnotations.js","sourceRoot":"","sources":["../../../src/spans/logSpanAnnotations.ts"],"names":[],"mappings":";;AAuDA,gDAqBC;AA5ED,sCAAyC;AAEzC,mCAA+D;AAkB/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACI,KAAK,UAAU,kBAAkB,CAAC,EACvC,MAAM,EAAE,OAAO,EACf,eAAe,EACf,IAAI,GAAG,KAAK,GACa;IACzB,MAAM,MAAM,GAAG,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,IAAA,qBAAY,GAAE,CAAC;IAEzC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,sBAAsB,EAAE;QAChE,MAAM,EAAE;YACN,KAAK,EAAE,EAAE,IAAI,EAAE;SAChB;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,eAAe,CAAC,GAAG,CAAC,4BAAoB,CAAC;SAChD;KACF,CAAC,CAAC;IAEH,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,mCAAmC,KAAK,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,KAAI,EAAE,CAAC;AAC1B,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { paths } from "../__generated__/api/v1";
|
|
2
2
|
type SpanAnnotationData = paths["/v1/span_annotations"]["post"]["requestBody"]["content"]["application/json"]["data"][0];
|
|
3
|
+
type SpanDocumentAnnotationData = paths["/v1/document_annotations"]["post"]["requestBody"]["content"]["application/json"]["data"][0];
|
|
3
4
|
/**
|
|
4
5
|
* Parameters for a single span annotation
|
|
5
6
|
*/
|
|
@@ -20,6 +21,10 @@ export interface SpanAnnotation {
|
|
|
20
21
|
* The score assigned by the annotation
|
|
21
22
|
*/
|
|
22
23
|
score?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Explanation of the annotation result
|
|
26
|
+
*/
|
|
27
|
+
explanation?: string;
|
|
23
28
|
/**
|
|
24
29
|
* The identifier of the annotation. If provided, the annotation will be updated if it already exists.
|
|
25
30
|
*/
|
|
@@ -35,9 +40,52 @@ export interface SpanAnnotation {
|
|
|
35
40
|
*/
|
|
36
41
|
annotatorKind?: SpanAnnotationData["annotator_kind"];
|
|
37
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Parameters for a single document annotation
|
|
45
|
+
*/
|
|
46
|
+
export interface DocumentAnnotation {
|
|
47
|
+
/**
|
|
48
|
+
* The OpenTelemetry Span ID (hex format without 0x prefix)
|
|
49
|
+
*/
|
|
50
|
+
spanId: string;
|
|
51
|
+
/**
|
|
52
|
+
* The 0-based index of the document within the span
|
|
53
|
+
*/
|
|
54
|
+
documentPosition: number;
|
|
55
|
+
/**
|
|
56
|
+
* The name of the annotation
|
|
57
|
+
*/
|
|
58
|
+
name: string;
|
|
59
|
+
/**
|
|
60
|
+
* The label assigned by the annotation
|
|
61
|
+
*/
|
|
62
|
+
label?: string;
|
|
63
|
+
/**
|
|
64
|
+
* The score assigned by the annotation
|
|
65
|
+
*/
|
|
66
|
+
score?: number;
|
|
67
|
+
/**
|
|
68
|
+
* Explanation of the annotation result
|
|
69
|
+
*/
|
|
70
|
+
explanation?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Metadata for the annotation
|
|
73
|
+
*/
|
|
74
|
+
metadata?: Record<string, unknown>;
|
|
75
|
+
/**
|
|
76
|
+
* The kind of annotator used for the annotation
|
|
77
|
+
* Can be "HUMAN", "LLM", or "CODE"
|
|
78
|
+
* @default "HUMAN"
|
|
79
|
+
*/
|
|
80
|
+
annotatorKind?: SpanDocumentAnnotationData["annotator_kind"];
|
|
81
|
+
}
|
|
38
82
|
/**
|
|
39
83
|
* Convert a SpanAnnotation to the API format
|
|
40
84
|
*/
|
|
41
85
|
export declare function toSpanAnnotationData(annotation: SpanAnnotation): SpanAnnotationData;
|
|
86
|
+
/**
|
|
87
|
+
* Convert a DocumentAnnotation to the API format
|
|
88
|
+
*/
|
|
89
|
+
export declare function toDocumentAnnotationData(annotation: DocumentAnnotation): SpanDocumentAnnotationData;
|
|
42
90
|
export {};
|
|
43
91
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/spans/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEhD,KAAK,kBAAkB,GACrB,KAAK,CAAC,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAEjG;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC;;;;OAIG;IACH,aAAa,CAAC,EAAE,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;CACtD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,cAAc,GACzB,kBAAkB,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/spans/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEhD,KAAK,kBAAkB,GACrB,KAAK,CAAC,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAEjG,KAAK,0BAA0B,GAC7B,KAAK,CAAC,0BAA0B,CAAC,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAErG;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC;;;;OAIG;IACH,aAAa,CAAC,EAAE,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;CACtD;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC;;;;OAIG;IACH,aAAa,CAAC,EAAE,0BAA0B,CAAC,gBAAgB,CAAC,CAAC;CAC9D;AA2CD;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,cAAc,GACzB,kBAAkB,CAWpB;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,kBAAkB,GAC7B,0BAA0B,CAW5B"}
|
package/dist/src/spans/types.js
CHANGED
|
@@ -1,22 +1,57 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.toSpanAnnotationData = toSpanAnnotationData;
|
|
4
|
+
exports.toDocumentAnnotationData = toDocumentAnnotationData;
|
|
5
|
+
/**
|
|
6
|
+
* Build and validate annotation result fields
|
|
7
|
+
*/
|
|
8
|
+
function buildAnnotationResult(annotation, annotationType) {
|
|
9
|
+
const result = {};
|
|
10
|
+
// Build result with trimming for string fields
|
|
11
|
+
if (annotation.label !== undefined) {
|
|
12
|
+
result.label = annotation.label.trim() || null;
|
|
13
|
+
}
|
|
14
|
+
if (annotation.score !== undefined) {
|
|
15
|
+
result.score = annotation.score;
|
|
16
|
+
}
|
|
17
|
+
if (annotation.explanation !== undefined) {
|
|
18
|
+
result.explanation = annotation.explanation.trim() || null;
|
|
19
|
+
}
|
|
20
|
+
// Validate that at least one result field is provided
|
|
21
|
+
const hasValidResult = result.label || result.score !== undefined || result.explanation;
|
|
22
|
+
if (!hasValidResult) {
|
|
23
|
+
throw new Error(`At least one of label, score, or explanation must be provided for ${annotationType} annotation`);
|
|
24
|
+
}
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
4
27
|
/**
|
|
5
28
|
* Convert a SpanAnnotation to the API format
|
|
6
29
|
*/
|
|
7
30
|
function toSpanAnnotationData(annotation) {
|
|
8
|
-
var _a, _b, _c, _d
|
|
31
|
+
var _a, _b, _c, _d;
|
|
32
|
+
const result = buildAnnotationResult(annotation, "span");
|
|
33
|
+
return {
|
|
34
|
+
span_id: annotation.spanId.trim(),
|
|
35
|
+
name: annotation.name.trim(),
|
|
36
|
+
annotator_kind: (_a = annotation.annotatorKind) !== null && _a !== void 0 ? _a : "HUMAN",
|
|
37
|
+
result,
|
|
38
|
+
metadata: (_b = annotation.metadata) !== null && _b !== void 0 ? _b : null,
|
|
39
|
+
identifier: (_d = (_c = annotation.identifier) === null || _c === void 0 ? void 0 : _c.trim()) !== null && _d !== void 0 ? _d : "",
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Convert a DocumentAnnotation to the API format
|
|
44
|
+
*/
|
|
45
|
+
function toDocumentAnnotationData(annotation) {
|
|
46
|
+
var _a, _b;
|
|
47
|
+
const result = buildAnnotationResult(annotation, "document");
|
|
9
48
|
return {
|
|
10
|
-
span_id: annotation.spanId,
|
|
11
|
-
|
|
49
|
+
span_id: annotation.spanId.trim(),
|
|
50
|
+
document_position: annotation.documentPosition,
|
|
51
|
+
name: annotation.name.trim(),
|
|
12
52
|
annotator_kind: (_a = annotation.annotatorKind) !== null && _a !== void 0 ? _a : "HUMAN",
|
|
13
|
-
result
|
|
14
|
-
|
|
15
|
-
score: (_c = annotation.score) !== null && _c !== void 0 ? _c : null,
|
|
16
|
-
explanation: null,
|
|
17
|
-
},
|
|
18
|
-
metadata: (_d = annotation.metadata) !== null && _d !== void 0 ? _d : null,
|
|
19
|
-
identifier: (_e = annotation.identifier) !== null && _e !== void 0 ? _e : "",
|
|
53
|
+
result,
|
|
54
|
+
metadata: (_b = annotation.metadata) !== null && _b !== void 0 ? _b : null,
|
|
20
55
|
};
|
|
21
56
|
}
|
|
22
57
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/spans/types.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/spans/types.ts"],"names":[],"mappings":";;AAoIA,oDAaC;AAKD,4DAaC;AArED;;GAEG;AACH,SAAS,qBAAqB,CAC5B,UAGC,EACD,cAAmC;IAEnC,MAAM,MAAM,GAAqB,EAAE,CAAC;IAEpC,+CAA+C;IAC/C,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,sDAAsD;IACtD,MAAM,cAAc,GAClB,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,IAAI,MAAM,CAAC,WAAW,CAAC;IACnE,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CACb,qEAAqE,cAAc,aAAa,CACjG,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAClC,UAA0B;;IAE1B,MAAM,MAAM,GAAG,qBAAqB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAEzD,OAAO;QACL,OAAO,EAAE,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE;QACjC,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE;QAC5B,cAAc,EAAE,MAAA,UAAU,CAAC,aAAa,mCAAI,OAAO;QACnD,MAAM;QACN,QAAQ,EAAE,MAAA,UAAU,CAAC,QAAQ,mCAAI,IAAI;QACrC,UAAU,EAAE,MAAA,MAAA,UAAU,CAAC,UAAU,0CAAE,IAAI,EAAE,mCAAI,EAAE;KAChD,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAgB,wBAAwB,CACtC,UAA8B;;IAE9B,MAAM,MAAM,GAAG,qBAAqB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAE7D,OAAO;QACL,OAAO,EAAE,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE;QACjC,iBAAiB,EAAE,UAAU,CAAC,gBAAgB;QAC9C,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE;QAC5B,cAAc,EAAE,MAAA,UAAU,CAAC,aAAa,mCAAI,OAAO;QACnD,MAAM;QACN,QAAQ,EAAE,MAAA,UAAU,CAAC,QAAQ,mCAAI,IAAI;KACtC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formatPromptMessages.d.ts","sourceRoot":"","sources":["../../../src/utils/formatPromptMessages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAO3E;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,oBAAoB,EAC5B,cAAc,EAAE,iBAAiB,EAAE,EACnC,SAAS,GAAE,SAAc;;;;;;;
|
|
1
|
+
{"version":3,"file":"formatPromptMessages.d.ts","sourceRoot":"","sources":["../../../src/utils/formatPromptMessages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAO3E;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,oBAAoB,EAC5B,cAAc,EAAE,iBAAiB,EAAE,EACnC,SAAS,GAAE,SAAc;;;;;;;mBA4Dmy7E,uDAAsB;;;;;;;;;IAlBn17E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPromptBySelector.d.ts","sourceRoot":"","sources":["../../../src/utils/getPromptBySelector.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,QAAQ,GAAG;IACjD;;OAEG;IACH,MAAM,EAAE,cAAc,CAAC;CACxB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAsB,mBAAmB,CAAC,EACxC,MAAM,EAAE,OAAO,EACf,MAAM,GACP,EAAE,yBAAyB;;
|
|
1
|
+
{"version":3,"file":"getPromptBySelector.d.ts","sourceRoot":"","sources":["../../../src/utils/getPromptBySelector.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,QAAQ,GAAG;IACjD;;OAEG;IACH,MAAM,EAAE,cAAc,CAAC;CACxB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAsB,mBAAmB,CAAC,EACxC,MAAM,EAAE,OAAO,EACf,MAAM,GACP,EAAE,yBAAyB;;oBAkD86jE,uDAAsB;;cAAkI,uDAAsB,yBAAwB,uDAAsB;mBAAoD,uDAAsB;qBAAoD,uDAAsB;2BAAqG,uDAAsB,uCAAsC,uDAAsB,4CAA2C,uDAAsB,0CAAyC,uDAAsB,uCAAsC,uDAAsB,yCAAwC,uDAAsB,oCAAmC,uDAAsB,uCAAsC,uDAAsB;YAAsD,uDAAsB;sBAAwF,uDAAsB;;UADzhmE"}
|