@arizeai/phoenix-client 3.1.0 → 4.0.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/prompts/sdks/toAI.d.ts +13 -3
- package/dist/esm/prompts/sdks/toAI.d.ts.map +1 -1
- package/dist/esm/prompts/sdks/toAI.js +23 -15
- package/dist/esm/prompts/sdks/toAI.js.map +1 -1
- package/dist/esm/prompts/sdks/toSDK.d.ts +1 -1
- package/dist/esm/schemas/llm/constants.d.ts +30 -12
- package/dist/esm/schemas/llm/constants.d.ts.map +1 -1
- package/dist/esm/schemas/llm/converters.d.ts +120 -48
- package/dist/esm/schemas/llm/converters.d.ts.map +1 -1
- package/dist/esm/schemas/llm/openai/converters.d.ts +6 -3
- package/dist/esm/schemas/llm/openai/converters.d.ts.map +1 -1
- package/dist/esm/schemas/llm/openai/converters.js +7 -4
- package/dist/esm/schemas/llm/openai/converters.js.map +1 -1
- package/dist/esm/schemas/llm/schemas.d.ts +37 -16
- package/dist/esm/schemas/llm/schemas.d.ts.map +1 -1
- package/dist/esm/schemas/llm/vercel/messagePartSchemas.d.ts +42 -12
- package/dist/esm/schemas/llm/vercel/messagePartSchemas.d.ts.map +1 -1
- package/dist/esm/schemas/llm/vercel/messagePartSchemas.js +5 -2
- package/dist/esm/schemas/llm/vercel/messagePartSchemas.js.map +1 -1
- package/dist/esm/schemas/llm/vercel/messageSchemas.d.ts +31 -10
- package/dist/esm/schemas/llm/vercel/messageSchemas.d.ts.map +1 -1
- package/dist/esm/schemas/llm/vercel/toolSchemas.d.ts +3 -3
- package/dist/esm/schemas/llm/vercel/toolSchemas.js +1 -1
- package/dist/esm/schemas/llm/vercel/toolSchemas.js.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/prompts/sdks/toAI.d.ts +13 -3
- package/dist/src/prompts/sdks/toAI.d.ts.map +1 -1
- package/dist/src/prompts/sdks/toAI.js +24 -16
- package/dist/src/prompts/sdks/toAI.js.map +1 -1
- package/dist/src/prompts/sdks/toSDK.d.ts +1 -1
- package/dist/src/schemas/llm/constants.d.ts +30 -12
- package/dist/src/schemas/llm/constants.d.ts.map +1 -1
- package/dist/src/schemas/llm/converters.d.ts +120 -48
- package/dist/src/schemas/llm/converters.d.ts.map +1 -1
- package/dist/src/schemas/llm/openai/converters.d.ts +6 -3
- package/dist/src/schemas/llm/openai/converters.d.ts.map +1 -1
- package/dist/src/schemas/llm/openai/converters.js +7 -4
- package/dist/src/schemas/llm/openai/converters.js.map +1 -1
- package/dist/src/schemas/llm/schemas.d.ts +37 -16
- package/dist/src/schemas/llm/schemas.d.ts.map +1 -1
- package/dist/src/schemas/llm/vercel/messagePartSchemas.d.ts +42 -12
- package/dist/src/schemas/llm/vercel/messagePartSchemas.d.ts.map +1 -1
- package/dist/src/schemas/llm/vercel/messagePartSchemas.js +5 -2
- package/dist/src/schemas/llm/vercel/messagePartSchemas.js.map +1 -1
- package/dist/src/schemas/llm/vercel/messageSchemas.d.ts +31 -10
- package/dist/src/schemas/llm/vercel/messageSchemas.d.ts.map +1 -1
- package/dist/src/schemas/llm/vercel/toolSchemas.d.ts +3 -3
- package/dist/src/schemas/llm/vercel/toolSchemas.js +1 -1
- package/dist/src/schemas/llm/vercel/toolSchemas.js.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 +4 -4
- package/src/__generated__/api/v1.d.ts +1240 -1238
- package/src/__generated__/api/v1.ts +185 -47
- package/src/prompts/sdks/toAI.ts +42 -32
- package/src/schemas/llm/openai/converters.ts +7 -4
- package/src/schemas/llm/vercel/messagePartSchemas.ts +5 -2
- package/src/schemas/llm/vercel/toolSchemas.ts +1 -1
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messagePartSchemas.js","sourceRoot":"","sources":["../../../../../src/schemas/llm/vercel/messagePartSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D;;;;GAIG;AAEH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IACjD,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IACvB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;CACjB,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;IACxB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,4DAA4D;IAC/E,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAChC,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,CAAC,MAAM,CAAC;IACrD,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC;IAC5B,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,
|
|
1
|
+
{"version":3,"file":"messagePartSchemas.js","sourceRoot":"","sources":["../../../../../src/schemas/llm/vercel/messagePartSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D;;;;GAIG;AAEH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IACjD,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IACvB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;CACjB,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;IACxB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,4DAA4D;IAC/E,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAChC,CAAC,CAAC;AAIH,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,CAAC,MAAM,CAAC;IACrD,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC;IAC5B,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,KAAK,EAAE,iBAAiB,EAAE,+BAA+B;CAC1D,CAAC,CAAC;AAMH,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC,MAAM,CAAC;IACvD,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC;IAC9B,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,6CAA6C;QACtE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;KAClB,CAAC;CACH,CAAC,CAAC;AAMH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE;IACjE,0BAA0B;IAC1B,2BAA2B;IAC3B,8BAA8B;IAC9B,gCAAgC;CACjC,CAAC,CAAC"}
|
|
@@ -69,17 +69,17 @@ export declare const vercelAIMessageSchema: z.ZodDiscriminatedUnion<"role", [z.Z
|
|
|
69
69
|
type: z.ZodLiteral<"tool-call">;
|
|
70
70
|
toolCallId: z.ZodString;
|
|
71
71
|
toolName: z.ZodString;
|
|
72
|
-
|
|
72
|
+
input: z.ZodType<import("../../jsonLiteralSchema.js").JSONLiteral, z.ZodTypeDef, import("../../jsonLiteralSchema.js").JSONLiteral>;
|
|
73
73
|
}, "strip", z.ZodTypeAny, {
|
|
74
74
|
type: "tool-call";
|
|
75
|
+
input: import("../../jsonLiteralSchema.js").JSONLiteral;
|
|
75
76
|
toolName: string;
|
|
76
77
|
toolCallId: string;
|
|
77
|
-
args: import("../../jsonLiteralSchema.js").JSONLiteral;
|
|
78
78
|
}, {
|
|
79
79
|
type: "tool-call";
|
|
80
|
+
input: import("../../jsonLiteralSchema.js").JSONLiteral;
|
|
80
81
|
toolName: string;
|
|
81
82
|
toolCallId: string;
|
|
82
|
-
args: import("../../jsonLiteralSchema.js").JSONLiteral;
|
|
83
83
|
}>]>, "many">, z.ZodString]>;
|
|
84
84
|
}, "strip", z.ZodTypeAny, {
|
|
85
85
|
content: string | ({
|
|
@@ -87,9 +87,9 @@ export declare const vercelAIMessageSchema: z.ZodDiscriminatedUnion<"role", [z.Z
|
|
|
87
87
|
type: "text";
|
|
88
88
|
} | {
|
|
89
89
|
type: "tool-call";
|
|
90
|
+
input: import("../../jsonLiteralSchema.js").JSONLiteral;
|
|
90
91
|
toolName: string;
|
|
91
92
|
toolCallId: string;
|
|
92
|
-
args: import("../../jsonLiteralSchema.js").JSONLiteral;
|
|
93
93
|
})[];
|
|
94
94
|
role: "assistant";
|
|
95
95
|
}, {
|
|
@@ -98,9 +98,9 @@ export declare const vercelAIMessageSchema: z.ZodDiscriminatedUnion<"role", [z.Z
|
|
|
98
98
|
type: "text";
|
|
99
99
|
} | {
|
|
100
100
|
type: "tool-call";
|
|
101
|
+
input: import("../../jsonLiteralSchema.js").JSONLiteral;
|
|
101
102
|
toolName: string;
|
|
102
103
|
toolCallId: string;
|
|
103
|
-
args: import("../../jsonLiteralSchema.js").JSONLiteral;
|
|
104
104
|
})[];
|
|
105
105
|
role: "assistant";
|
|
106
106
|
}>, z.ZodObject<{
|
|
@@ -109,32 +109,53 @@ export declare const vercelAIMessageSchema: z.ZodDiscriminatedUnion<"role", [z.Z
|
|
|
109
109
|
type: z.ZodLiteral<"tool-result">;
|
|
110
110
|
toolCallId: z.ZodString;
|
|
111
111
|
toolName: z.ZodString;
|
|
112
|
-
|
|
112
|
+
output: z.ZodObject<{
|
|
113
|
+
type: z.ZodLiteral<"text">;
|
|
114
|
+
value: z.ZodString;
|
|
115
|
+
}, "strip", z.ZodTypeAny, {
|
|
116
|
+
value: string;
|
|
117
|
+
type: "text";
|
|
118
|
+
}, {
|
|
119
|
+
value: string;
|
|
120
|
+
type: "text";
|
|
121
|
+
}>;
|
|
113
122
|
}, "strip", z.ZodTypeAny, {
|
|
114
123
|
type: "tool-result";
|
|
124
|
+
output: {
|
|
125
|
+
value: string;
|
|
126
|
+
type: "text";
|
|
127
|
+
};
|
|
115
128
|
toolName: string;
|
|
116
129
|
toolCallId: string;
|
|
117
|
-
result: import("../../jsonLiteralSchema.js").JSONLiteral;
|
|
118
130
|
}, {
|
|
119
131
|
type: "tool-result";
|
|
132
|
+
output: {
|
|
133
|
+
value: string;
|
|
134
|
+
type: "text";
|
|
135
|
+
};
|
|
120
136
|
toolName: string;
|
|
121
137
|
toolCallId: string;
|
|
122
|
-
result: import("../../jsonLiteralSchema.js").JSONLiteral;
|
|
123
138
|
}>, "many">;
|
|
124
139
|
}, "strip", z.ZodTypeAny, {
|
|
125
140
|
content: {
|
|
126
141
|
type: "tool-result";
|
|
142
|
+
output: {
|
|
143
|
+
value: string;
|
|
144
|
+
type: "text";
|
|
145
|
+
};
|
|
127
146
|
toolName: string;
|
|
128
147
|
toolCallId: string;
|
|
129
|
-
result: import("../../jsonLiteralSchema.js").JSONLiteral;
|
|
130
148
|
}[];
|
|
131
149
|
role: "tool";
|
|
132
150
|
}, {
|
|
133
151
|
content: {
|
|
134
152
|
type: "tool-result";
|
|
153
|
+
output: {
|
|
154
|
+
value: string;
|
|
155
|
+
type: "text";
|
|
156
|
+
};
|
|
135
157
|
toolName: string;
|
|
136
158
|
toolCallId: string;
|
|
137
|
-
result: import("../../jsonLiteralSchema.js").JSONLiteral;
|
|
138
159
|
}[];
|
|
139
160
|
role: "tool";
|
|
140
161
|
}>]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageSchemas.d.ts","sourceRoot":"","sources":["../../../../../src/schemas/llm/vercel/messageSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAepB,eAAO,MAAM,yBAAyB,oDAKpC,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,eAAO,MAAM,qBAAqB
|
|
1
|
+
{"version":3,"file":"messageSchemas.d.ts","sourceRoot":"","sources":["../../../../../src/schemas/llm/vercel/messageSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAepB,eAAO,MAAM,yBAAyB,oDAKpC,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA2BhC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
|
|
@@ -8,7 +8,7 @@ import { z } from "zod";
|
|
|
8
8
|
export declare const vercelAIToolDefinitionSchema: z.ZodObject<{
|
|
9
9
|
type: z.ZodLiteral<"function">;
|
|
10
10
|
description: z.ZodOptional<z.ZodString>;
|
|
11
|
-
|
|
11
|
+
inputSchema: z.ZodObject<{
|
|
12
12
|
_type: z.ZodDefault<z.ZodOptional<z.ZodUnknown>>;
|
|
13
13
|
validate: z.ZodDefault<z.ZodOptional<z.ZodUnknown>>;
|
|
14
14
|
jsonSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
@@ -23,7 +23,7 @@ export declare const vercelAIToolDefinitionSchema: z.ZodObject<{
|
|
|
23
23
|
}>;
|
|
24
24
|
}, "strip", z.ZodTypeAny, {
|
|
25
25
|
type: "function";
|
|
26
|
-
|
|
26
|
+
inputSchema: {
|
|
27
27
|
_type?: unknown;
|
|
28
28
|
validate?: unknown;
|
|
29
29
|
jsonSchema?: Record<string, unknown> | undefined;
|
|
@@ -31,7 +31,7 @@ export declare const vercelAIToolDefinitionSchema: z.ZodObject<{
|
|
|
31
31
|
description?: string | undefined;
|
|
32
32
|
}, {
|
|
33
33
|
type: "function";
|
|
34
|
-
|
|
34
|
+
inputSchema: {
|
|
35
35
|
_type?: unknown;
|
|
36
36
|
validate?: unknown;
|
|
37
37
|
jsonSchema?: Record<string, unknown> | undefined;
|
|
@@ -8,7 +8,7 @@ import { z } from "zod";
|
|
|
8
8
|
export const vercelAIToolDefinitionSchema = z.object({
|
|
9
9
|
type: z.literal("function"),
|
|
10
10
|
description: z.string().optional(),
|
|
11
|
-
|
|
11
|
+
inputSchema: z.object({
|
|
12
12
|
_type: z.unknown().optional().default(undefined),
|
|
13
13
|
validate: z.unknown().optional().default(undefined),
|
|
14
14
|
jsonSchema: z.record(z.string(), z.unknown()).optional(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolSchemas.js","sourceRoot":"","sources":["../../../../../src/schemas/llm/vercel/toolSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC,MAAM,CAAC;IACnD,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;IAC3B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,
|
|
1
|
+
{"version":3,"file":"toolSchemas.js","sourceRoot":"","sources":["../../../../../src/schemas/llm/vercel/toolSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC,MAAM,CAAC;IACnD,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;IAC3B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC;QAChD,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC;QACnD,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE;KACzD,CAAC;CACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ClientFn } from "../types/core.js";
|
|
2
|
+
import { DocumentAnnotation } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Parameters to add a document annotation
|
|
5
|
+
*/
|
|
6
|
+
export interface AddDocumentAnnotationParams extends ClientFn {
|
|
7
|
+
documentAnnotation: DocumentAnnotation;
|
|
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 document within a span.
|
|
17
|
+
*
|
|
18
|
+
* The annotation can be of type "LLM", "CODE", or "HUMAN" and can include a label, score, explanation, and metadata.
|
|
19
|
+
* At least one of label, score, or explanation must be provided.
|
|
20
|
+
*
|
|
21
|
+
* @param params - The parameters to add a document annotation
|
|
22
|
+
* @returns The ID of the created annotation
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const result = await addDocumentAnnotation({
|
|
27
|
+
* documentAnnotation: {
|
|
28
|
+
* spanId: "123abc",
|
|
29
|
+
* documentPosition: 0,
|
|
30
|
+
* name: "relevance_score",
|
|
31
|
+
* label: "relevant",
|
|
32
|
+
* score: 0.95,
|
|
33
|
+
* annotatorKind: "LLM",
|
|
34
|
+
* explanation: "Document is highly relevant to the query",
|
|
35
|
+
* metadata: {
|
|
36
|
+
* model: "gpt-4"
|
|
37
|
+
* }
|
|
38
|
+
* }
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function addDocumentAnnotation({ client: _client, documentAnnotation, sync, }: AddDocumentAnnotationParams): Promise<{
|
|
43
|
+
id: string;
|
|
44
|
+
} | null>;
|
|
45
|
+
//# sourceMappingURL=addDocumentAnnotation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addDocumentAnnotation.d.ts","sourceRoot":"","sources":["../../../src/spans/addDocumentAnnotation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAA4B,MAAM,SAAS,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,2BAA4B,SAAQ,QAAQ;IAC3D,kBAAkB,EAAE,kBAAkB,CAAC;IACvC;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,qBAAqB,CAAC,EAC1C,MAAM,EAAE,OAAO,EACf,kBAAkB,EAClB,IAAY,GACb,EAAE,2BAA2B,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CAiB9D"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { createClient } from "../client.js";
|
|
2
|
+
import { toDocumentAnnotationData } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Add an annotation to a document within a span.
|
|
5
|
+
*
|
|
6
|
+
* The annotation can be of type "LLM", "CODE", or "HUMAN" and can include a label, score, explanation, and metadata.
|
|
7
|
+
* At least one of label, score, or explanation must be provided.
|
|
8
|
+
*
|
|
9
|
+
* @param params - The parameters to add a document annotation
|
|
10
|
+
* @returns The ID of the created annotation
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const result = await addDocumentAnnotation({
|
|
15
|
+
* documentAnnotation: {
|
|
16
|
+
* spanId: "123abc",
|
|
17
|
+
* documentPosition: 0,
|
|
18
|
+
* name: "relevance_score",
|
|
19
|
+
* label: "relevant",
|
|
20
|
+
* score: 0.95,
|
|
21
|
+
* annotatorKind: "LLM",
|
|
22
|
+
* explanation: "Document is highly relevant to the query",
|
|
23
|
+
* metadata: {
|
|
24
|
+
* model: "gpt-4"
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export async function addDocumentAnnotation({ client: _client, documentAnnotation, sync = false, }) {
|
|
31
|
+
const client = _client ?? createClient();
|
|
32
|
+
const { data, error } = await client.POST("/v1/document_annotations", {
|
|
33
|
+
params: {
|
|
34
|
+
query: { sync },
|
|
35
|
+
},
|
|
36
|
+
body: {
|
|
37
|
+
data: [toDocumentAnnotationData(documentAnnotation)],
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
if (error) {
|
|
41
|
+
throw new Error(`Failed to add document annotation: ${error}`);
|
|
42
|
+
}
|
|
43
|
+
return data?.data?.[0] || null;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=addDocumentAnnotation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addDocumentAnnotation.js","sourceRoot":"","sources":["../../../src/spans/addDocumentAnnotation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAsB,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAevE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,EAC1C,MAAM,EAAE,OAAO,EACf,kBAAkB,EAClB,IAAI,GAAG,KAAK,GACgB;IAC5B,MAAM,MAAM,GAAG,OAAO,IAAI,YAAY,EAAE,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,CAAC,wBAAwB,CAAC,kBAAkB,CAAC,CAAC;SACrD;KACF,CAAC,CAAC;IAEH,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,sCAAsC,KAAK,EAAE,CAAC,CAAC;IACjE,CAAC;IAED,OAAO,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AACjC,CAAC"}
|
|
@@ -5,6 +5,12 @@ import { SpanAnnotation } from "./types.js";
|
|
|
5
5
|
*/
|
|
6
6
|
export interface AddSpanAnnotationParams extends ClientFn {
|
|
7
7
|
spanAnnotation: SpanAnnotation;
|
|
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;
|
|
8
14
|
}
|
|
9
15
|
/**
|
|
10
16
|
* Add an annotation to a span.
|
|
@@ -32,7 +38,7 @@ export interface AddSpanAnnotationParams extends ClientFn {
|
|
|
32
38
|
* });
|
|
33
39
|
* ```
|
|
34
40
|
*/
|
|
35
|
-
export declare function addSpanAnnotation({ client: _client, spanAnnotation, }: AddSpanAnnotationParams): Promise<{
|
|
41
|
+
export declare function addSpanAnnotation({ client: _client, spanAnnotation, sync, }: AddSpanAnnotationParams): Promise<{
|
|
36
42
|
id: string;
|
|
37
|
-
}>;
|
|
43
|
+
} | null>;
|
|
38
44
|
//# sourceMappingURL=addSpanAnnotation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addSpanAnnotation.d.ts","sourceRoot":"","sources":["../../../src/spans/addSpanAnnotation.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,uBAAwB,SAAQ,QAAQ;IACvD,cAAc,EAAE,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"addSpanAnnotation.d.ts","sourceRoot":"","sources":["../../../src/spans/addSpanAnnotation.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,uBAAwB,SAAQ,QAAQ;IACvD,cAAc,EAAE,cAAc,CAAC;IAC/B;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,iBAAiB,CAAC,EACtC,MAAM,EAAE,OAAO,EACf,cAAc,EACd,IAAY,GACb,EAAE,uBAAuB,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CAiB1D"}
|
|
@@ -26,9 +26,12 @@ import { toSpanAnnotationData } from "./types.js";
|
|
|
26
26
|
* });
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
|
-
export async function addSpanAnnotation({ client: _client, spanAnnotation, }) {
|
|
29
|
+
export async function addSpanAnnotation({ client: _client, spanAnnotation, sync = false, }) {
|
|
30
30
|
const client = _client ?? createClient();
|
|
31
31
|
const { data, error } = await client.POST("/v1/span_annotations", {
|
|
32
|
+
params: {
|
|
33
|
+
query: { sync },
|
|
34
|
+
},
|
|
32
35
|
body: {
|
|
33
36
|
data: [toSpanAnnotationData(spanAnnotation)],
|
|
34
37
|
},
|
|
@@ -36,9 +39,6 @@ export async function addSpanAnnotation({ client: _client, spanAnnotation, }) {
|
|
|
36
39
|
if (error) {
|
|
37
40
|
throw new Error(`Failed to add span annotation: ${error}`);
|
|
38
41
|
}
|
|
39
|
-
|
|
40
|
-
throw new Error("No annotation ID returned from server");
|
|
41
|
-
}
|
|
42
|
-
return data.data[0];
|
|
42
|
+
return data?.data?.[0] || null;
|
|
43
43
|
}
|
|
44
44
|
//# sourceMappingURL=addSpanAnnotation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addSpanAnnotation.js","sourceRoot":"","sources":["../../../src/spans/addSpanAnnotation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAkB,oBAAoB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"addSpanAnnotation.js","sourceRoot":"","sources":["../../../src/spans/addSpanAnnotation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAkB,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAe/D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,EACtC,MAAM,EAAE,OAAO,EACf,cAAc,EACd,IAAI,GAAG,KAAK,GACY;IACxB,MAAM,MAAM,GAAG,OAAO,IAAI,YAAY,EAAE,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,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC;SAC7C;KACF,CAAC,CAAC;IAEH,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,kCAAkC,KAAK,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AACjC,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from "./addSpanAnnotation.js";
|
|
2
2
|
export * from "./logSpanAnnotations.js";
|
|
3
|
+
export * from "./addDocumentAnnotation.js";
|
|
4
|
+
export * from "./logDocumentAnnotations.js";
|
|
3
5
|
export * from "./getSpans.js";
|
|
4
6
|
export * from "./getSpanAnnotations.js";
|
|
5
7
|
export * from "./deleteSpan.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/spans/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/spans/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC"}
|
package/dist/esm/spans/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export * from "./addSpanAnnotation.js";
|
|
2
2
|
export * from "./logSpanAnnotations.js";
|
|
3
|
+
export * from "./addDocumentAnnotation.js";
|
|
4
|
+
export * from "./logDocumentAnnotations.js";
|
|
3
5
|
export * from "./getSpans.js";
|
|
4
6
|
export * from "./getSpanAnnotations.js";
|
|
5
7
|
export * from "./deleteSpan.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/spans/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/spans/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ClientFn } from "../types/core.js";
|
|
2
|
+
import { DocumentAnnotation } from "./types.js";
|
|
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,55 @@
|
|
|
1
|
+
import { createClient } from "../client.js";
|
|
2
|
+
import { toDocumentAnnotationData } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Log multiple document annotations in a single request.
|
|
5
|
+
*
|
|
6
|
+
* Each annotation can be of type "LLM", "CODE", or "HUMAN" and can include a label, score, explanation, and metadata.
|
|
7
|
+
* At least one of label, score, or explanation must be provided for each annotation.
|
|
8
|
+
*
|
|
9
|
+
* @param params - The parameters to log document annotations
|
|
10
|
+
* @returns The IDs of the created annotations
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const results = await logDocumentAnnotations({
|
|
15
|
+
* documentAnnotations: [
|
|
16
|
+
* {
|
|
17
|
+
* spanId: "123abc",
|
|
18
|
+
* documentPosition: 0,
|
|
19
|
+
* name: "relevance_score",
|
|
20
|
+
* label: "relevant",
|
|
21
|
+
* score: 0.95,
|
|
22
|
+
* annotatorKind: "LLM",
|
|
23
|
+
* explanation: "Document is highly relevant to the query",
|
|
24
|
+
* metadata: {
|
|
25
|
+
* model: "gpt-4"
|
|
26
|
+
* }
|
|
27
|
+
* },
|
|
28
|
+
* {
|
|
29
|
+
* spanId: "123abc",
|
|
30
|
+
* documentPosition: 1,
|
|
31
|
+
* name: "relevance_score",
|
|
32
|
+
* label: "somewhat_relevant",
|
|
33
|
+
* score: 0.6,
|
|
34
|
+
* annotatorKind: "LLM"
|
|
35
|
+
* }
|
|
36
|
+
* ]
|
|
37
|
+
* });
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export async function logDocumentAnnotations({ client: _client, documentAnnotations, sync = false, }) {
|
|
41
|
+
const client = _client ?? createClient();
|
|
42
|
+
const { data, error } = await client.POST("/v1/document_annotations", {
|
|
43
|
+
params: {
|
|
44
|
+
query: { sync },
|
|
45
|
+
},
|
|
46
|
+
body: {
|
|
47
|
+
data: documentAnnotations.map(toDocumentAnnotationData),
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
if (error) {
|
|
51
|
+
throw new Error(`Failed to log document annotations: ${error}`);
|
|
52
|
+
}
|
|
53
|
+
return data?.data || [];
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=logDocumentAnnotations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logDocumentAnnotations.js","sourceRoot":"","sources":["../../../src/spans/logDocumentAnnotations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAsB,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAkBvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,EAC3C,MAAM,EAAE,OAAO,EACf,mBAAmB,EACnB,IAAI,GAAG,KAAK,GACiB;IAC7B,MAAM,MAAM,GAAG,OAAO,IAAI,YAAY,EAAE,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,wBAAwB,CAAC;SACxD;KACF,CAAC,CAAC;IAEH,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,uCAAuC,KAAK,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,OAAO,IAAI,EAAE,IAAI,IAAI,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"}
|
|
@@ -35,9 +35,12 @@ import { toSpanAnnotationData } from "./types.js";
|
|
|
35
35
|
* });
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
|
-
export async function logSpanAnnotations({ client: _client, spanAnnotations, }) {
|
|
38
|
+
export async function logSpanAnnotations({ client: _client, spanAnnotations, sync = false, }) {
|
|
39
39
|
const client = _client ?? createClient();
|
|
40
40
|
const { data, error } = await client.POST("/v1/span_annotations", {
|
|
41
|
+
params: {
|
|
42
|
+
query: { sync },
|
|
43
|
+
},
|
|
41
44
|
body: {
|
|
42
45
|
data: spanAnnotations.map(toSpanAnnotationData),
|
|
43
46
|
},
|
|
@@ -45,9 +48,6 @@ export async function logSpanAnnotations({ client: _client, spanAnnotations, })
|
|
|
45
48
|
if (error) {
|
|
46
49
|
throw new Error(`Failed to log span annotations: ${error}`);
|
|
47
50
|
}
|
|
48
|
-
|
|
49
|
-
throw new Error("No annotation IDs returned from server");
|
|
50
|
-
}
|
|
51
|
-
return data.data;
|
|
51
|
+
return data?.data || [];
|
|
52
52
|
}
|
|
53
53
|
//# sourceMappingURL=logSpanAnnotations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logSpanAnnotations.js","sourceRoot":"","sources":["../../../src/spans/logSpanAnnotations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAkB,oBAAoB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"logSpanAnnotations.js","sourceRoot":"","sources":["../../../src/spans/logSpanAnnotations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAkB,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAkB/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;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,sBAAsB,EAAE;QAChE,MAAM,EAAE;YACN,KAAK,EAAE,EAAE,IAAI,EAAE;SAChB;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,eAAe,CAAC,GAAG,CAAC,oBAAoB,CAAC;SAChD;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,IAAI,EAAE,CAAC;AAC1B,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { paths } from "../__generated__/api/v1.js";
|
|
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"}
|