@latitude-data/telemetry 2.0.2 → 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 +4 -4
package/dist/index.js
CHANGED
|
@@ -198,17 +198,23 @@ const expectedOutputConfiguration = z.object({
|
|
|
198
198
|
fieldAccessor: z.string().optional(), // Field accessor to get the output from if it's a key-value format
|
|
199
199
|
});
|
|
200
200
|
const EVALUATION_TRIGGER_TARGETS = ['first', 'every', 'last'];
|
|
201
|
-
const DEFAULT_LAST_INTERACTION_DEBOUNCE_SECONDS = 120;
|
|
202
201
|
const LAST_INTERACTION_DEBOUNCE_MIN_SECONDS = 30;
|
|
203
202
|
const LAST_INTERACTION_DEBOUNCE_MAX_SECONDS = 60 * 60 * 24; // 1 day
|
|
203
|
+
const MIN_EVALUATION_SAMPLE_RATE = 0; // 0%
|
|
204
|
+
const MAX_EVALUATION_SAMPLE_RATE = 100; // 100%
|
|
204
205
|
const triggerConfiguration = z.object({
|
|
205
206
|
target: z.enum(EVALUATION_TRIGGER_TARGETS),
|
|
206
207
|
lastInteractionDebounce: z
|
|
207
208
|
.number()
|
|
208
209
|
.min(LAST_INTERACTION_DEBOUNCE_MIN_SECONDS)
|
|
209
210
|
.max(LAST_INTERACTION_DEBOUNCE_MAX_SECONDS)
|
|
210
|
-
.optional()
|
|
211
|
-
|
|
211
|
+
.optional(),
|
|
212
|
+
sampleRate: z
|
|
213
|
+
.number()
|
|
214
|
+
.int()
|
|
215
|
+
.min(MIN_EVALUATION_SAMPLE_RATE)
|
|
216
|
+
.max(MAX_EVALUATION_SAMPLE_RATE)
|
|
217
|
+
.optional(),
|
|
212
218
|
});
|
|
213
219
|
const baseEvaluationConfiguration = z.object({
|
|
214
220
|
reverseScale: z.boolean(), // If true, lower is better, otherwise, higher is better
|
|
@@ -239,6 +245,7 @@ const compositeEvaluationResultMetadata = baseEvaluationResultMetadata.extend({
|
|
|
239
245
|
score: z.number(), // Normalized score
|
|
240
246
|
reason: z.string(),
|
|
241
247
|
passed: z.boolean(),
|
|
248
|
+
tokens: z.number().optional(), // Optional llm evaluation usage
|
|
242
249
|
})),
|
|
243
250
|
});
|
|
244
251
|
const compositeEvaluationResultError = baseEvaluationResultError.extend({
|
|
@@ -1151,6 +1158,12 @@ const OptimizationBudgetSchema = z.object({
|
|
|
1151
1158
|
tokens: z.number().min(0).optional(),
|
|
1152
1159
|
});
|
|
1153
1160
|
z.object({
|
|
1161
|
+
dataset: z
|
|
1162
|
+
.object({
|
|
1163
|
+
target: z.number().min(0).optional(), // Note: number of rows to curate when not provided by the user
|
|
1164
|
+
label: z.string().optional(), // Note: expected output column when using a labeled evaluation
|
|
1165
|
+
})
|
|
1166
|
+
.optional(),
|
|
1154
1167
|
parameters: z
|
|
1155
1168
|
.record(z.string(), z.object({
|
|
1156
1169
|
column: z.string().optional(), // Note: corresponding column in the user-provided trainset and testset
|
|
@@ -1594,6 +1607,7 @@ class ManualInstrumentation {
|
|
|
1594
1607
|
attributes,
|
|
1595
1608
|
});
|
|
1596
1609
|
}
|
|
1610
|
+
// TODO(tracing): deprecate
|
|
1597
1611
|
unresolvedExternal(ctx, { path, projectId, versionUuid, conversationUuid, name, ...rest }) {
|
|
1598
1612
|
const attributes = {
|
|
1599
1613
|
[ATTRIBUTES.LATITUDE.promptPath]: path,
|
|
@@ -2042,7 +2056,22 @@ class LatitudeTelemetry {
|
|
|
2042
2056
|
if (!DOCUMENT_PATH_REGEXP.test(options.path)) {
|
|
2043
2057
|
throw new BadRequestError("Invalid path, no spaces. Only letters, numbers, '.', '-' and '_'");
|
|
2044
2058
|
}
|
|
2045
|
-
const
|
|
2059
|
+
const captureBaggageEntries = {
|
|
2060
|
+
[ATTRIBUTES.LATITUDE.promptPath]: { value: options.path },
|
|
2061
|
+
[ATTRIBUTES.LATITUDE.projectId]: { value: String(options.projectId) },
|
|
2062
|
+
};
|
|
2063
|
+
if (options.versionUuid) {
|
|
2064
|
+
captureBaggageEntries[ATTRIBUTES.LATITUDE.commitUuid] = {
|
|
2065
|
+
value: options.versionUuid,
|
|
2066
|
+
};
|
|
2067
|
+
}
|
|
2068
|
+
if (options.conversationUuid) {
|
|
2069
|
+
captureBaggageEntries[ATTRIBUTES.LATITUDE.documentLogUuid] = {
|
|
2070
|
+
value: options.conversationUuid,
|
|
2071
|
+
};
|
|
2072
|
+
}
|
|
2073
|
+
const captureContext = propagation.setBaggage(BACKGROUND(), propagation.createBaggage(captureBaggageEntries));
|
|
2074
|
+
const span = this.manualInstrumentation.unresolvedExternal(captureContext, options);
|
|
2046
2075
|
let result;
|
|
2047
2076
|
try {
|
|
2048
2077
|
result = await context.with(span.context, async () => await fn(span.context));
|