@latitude-data/telemetry 2.0.1 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +33 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +33 -4
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -218,17 +218,23 @@ const expectedOutputConfiguration = zod.z.object({
|
|
|
218
218
|
fieldAccessor: zod.z.string().optional(), // Field accessor to get the output from if it's a key-value format
|
|
219
219
|
});
|
|
220
220
|
const EVALUATION_TRIGGER_TARGETS = ['first', 'every', 'last'];
|
|
221
|
-
const DEFAULT_LAST_INTERACTION_DEBOUNCE_SECONDS = 120;
|
|
222
221
|
const LAST_INTERACTION_DEBOUNCE_MIN_SECONDS = 30;
|
|
223
222
|
const LAST_INTERACTION_DEBOUNCE_MAX_SECONDS = 60 * 60 * 24; // 1 day
|
|
223
|
+
const MIN_EVALUATION_SAMPLE_RATE = 0; // 0%
|
|
224
|
+
const MAX_EVALUATION_SAMPLE_RATE = 100; // 100%
|
|
224
225
|
const triggerConfiguration = zod.z.object({
|
|
225
226
|
target: zod.z.enum(EVALUATION_TRIGGER_TARGETS),
|
|
226
227
|
lastInteractionDebounce: zod.z
|
|
227
228
|
.number()
|
|
228
229
|
.min(LAST_INTERACTION_DEBOUNCE_MIN_SECONDS)
|
|
229
230
|
.max(LAST_INTERACTION_DEBOUNCE_MAX_SECONDS)
|
|
230
|
-
.optional()
|
|
231
|
-
|
|
231
|
+
.optional(),
|
|
232
|
+
sampleRate: zod.z
|
|
233
|
+
.number()
|
|
234
|
+
.int()
|
|
235
|
+
.min(MIN_EVALUATION_SAMPLE_RATE)
|
|
236
|
+
.max(MAX_EVALUATION_SAMPLE_RATE)
|
|
237
|
+
.optional(),
|
|
232
238
|
});
|
|
233
239
|
const baseEvaluationConfiguration = zod.z.object({
|
|
234
240
|
reverseScale: zod.z.boolean(), // If true, lower is better, otherwise, higher is better
|
|
@@ -259,6 +265,7 @@ const compositeEvaluationResultMetadata = baseEvaluationResultMetadata.extend({
|
|
|
259
265
|
score: zod.z.number(), // Normalized score
|
|
260
266
|
reason: zod.z.string(),
|
|
261
267
|
passed: zod.z.boolean(),
|
|
268
|
+
tokens: zod.z.number().optional(), // Optional llm evaluation usage
|
|
262
269
|
})),
|
|
263
270
|
});
|
|
264
271
|
const compositeEvaluationResultError = baseEvaluationResultError.extend({
|
|
@@ -1171,6 +1178,12 @@ const OptimizationBudgetSchema = zod.z.object({
|
|
|
1171
1178
|
tokens: zod.z.number().min(0).optional(),
|
|
1172
1179
|
});
|
|
1173
1180
|
zod.z.object({
|
|
1181
|
+
dataset: zod.z
|
|
1182
|
+
.object({
|
|
1183
|
+
target: zod.z.number().min(0).optional(), // Note: number of rows to curate when not provided by the user
|
|
1184
|
+
label: zod.z.string().optional(), // Note: expected output column when using a labeled evaluation
|
|
1185
|
+
})
|
|
1186
|
+
.optional(),
|
|
1174
1187
|
parameters: zod.z
|
|
1175
1188
|
.record(zod.z.string(), zod.z.object({
|
|
1176
1189
|
column: zod.z.string().optional(), // Note: corresponding column in the user-provided trainset and testset
|
|
@@ -1614,6 +1627,7 @@ class ManualInstrumentation {
|
|
|
1614
1627
|
attributes,
|
|
1615
1628
|
});
|
|
1616
1629
|
}
|
|
1630
|
+
// TODO(tracing): deprecate
|
|
1617
1631
|
unresolvedExternal(ctx, { path, projectId, versionUuid, conversationUuid, name, ...rest }) {
|
|
1618
1632
|
const attributes = {
|
|
1619
1633
|
[ATTRIBUTES.LATITUDE.promptPath]: path,
|
|
@@ -2062,7 +2076,22 @@ class LatitudeTelemetry {
|
|
|
2062
2076
|
if (!DOCUMENT_PATH_REGEXP.test(options.path)) {
|
|
2063
2077
|
throw new BadRequestError("Invalid path, no spaces. Only letters, numbers, '.', '-' and '_'");
|
|
2064
2078
|
}
|
|
2065
|
-
const
|
|
2079
|
+
const captureBaggageEntries = {
|
|
2080
|
+
[ATTRIBUTES.LATITUDE.promptPath]: { value: options.path },
|
|
2081
|
+
[ATTRIBUTES.LATITUDE.projectId]: { value: String(options.projectId) },
|
|
2082
|
+
};
|
|
2083
|
+
if (options.versionUuid) {
|
|
2084
|
+
captureBaggageEntries[ATTRIBUTES.LATITUDE.commitUuid] = {
|
|
2085
|
+
value: options.versionUuid,
|
|
2086
|
+
};
|
|
2087
|
+
}
|
|
2088
|
+
if (options.conversationUuid) {
|
|
2089
|
+
captureBaggageEntries[ATTRIBUTES.LATITUDE.documentLogUuid] = {
|
|
2090
|
+
value: options.conversationUuid,
|
|
2091
|
+
};
|
|
2092
|
+
}
|
|
2093
|
+
const captureContext = otel.propagation.setBaggage(BACKGROUND(), otel.propagation.createBaggage(captureBaggageEntries));
|
|
2094
|
+
const span = this.manualInstrumentation.unresolvedExternal(captureContext, options);
|
|
2066
2095
|
let result;
|
|
2067
2096
|
try {
|
|
2068
2097
|
result = await otel.context.with(span.context, async () => await fn(span.context));
|