@langfuse/client 4.1.0-alpha.0 → 4.1.0-alpha.1
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 +28 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +99 -29
- package/dist/index.d.ts +99 -29
- package/dist/index.mjs +28 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -302,18 +302,16 @@ var ExperimentManager = class {
|
|
|
302
302
|
const itemResults = [];
|
|
303
303
|
for (let i = 0; i < data.length; i += batchSize) {
|
|
304
304
|
const batch = data.slice(i, i + batchSize);
|
|
305
|
-
const promises = batch.map(
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
}
|
|
316
|
-
);
|
|
305
|
+
const promises = batch.map(async (item) => {
|
|
306
|
+
return this.runItem({
|
|
307
|
+
item,
|
|
308
|
+
evaluators,
|
|
309
|
+
task,
|
|
310
|
+
experimentName: name,
|
|
311
|
+
experimentDescription: description,
|
|
312
|
+
experimentMetadata: metadata
|
|
313
|
+
});
|
|
314
|
+
});
|
|
317
315
|
const results = await Promise.all(promises);
|
|
318
316
|
itemResults.push(...results);
|
|
319
317
|
}
|
|
@@ -355,6 +353,7 @@ var ExperimentManager = class {
|
|
|
355
353
|
return {
|
|
356
354
|
itemResults,
|
|
357
355
|
datasetRunId,
|
|
356
|
+
datasetRunUrl,
|
|
358
357
|
runEvaluations,
|
|
359
358
|
prettyPrint: async (options) => {
|
|
360
359
|
var _a;
|
|
@@ -365,7 +364,7 @@ var ExperimentManager = class {
|
|
|
365
364
|
runEvaluations,
|
|
366
365
|
name: config.name,
|
|
367
366
|
description: config.description,
|
|
368
|
-
includeItemResults: (_a = options == null ? void 0 : options.includeItemResults) != null ? _a :
|
|
367
|
+
includeItemResults: (_a = options == null ? void 0 : options.includeItemResults) != null ? _a : false
|
|
369
368
|
});
|
|
370
369
|
}
|
|
371
370
|
};
|
|
@@ -395,14 +394,24 @@ var ExperimentManager = class {
|
|
|
395
394
|
* @internal
|
|
396
395
|
*/
|
|
397
396
|
async runItem(params) {
|
|
398
|
-
const { item, evaluators = [], task } = params;
|
|
397
|
+
const { item, evaluators = [], task, experimentMetadata = {} } = params;
|
|
399
398
|
const { output, traceId } = await (0, import_tracing.startActiveObservation)(
|
|
400
399
|
"experiment-item-run",
|
|
401
400
|
async (span) => {
|
|
401
|
+
var _a;
|
|
402
402
|
const output2 = await task(item);
|
|
403
403
|
span.update({
|
|
404
404
|
input: item.input,
|
|
405
|
-
output: output2
|
|
405
|
+
output: output2,
|
|
406
|
+
metadata: {
|
|
407
|
+
experimentName: params.experimentName,
|
|
408
|
+
...experimentMetadata,
|
|
409
|
+
...(_a = item.metadata) != null ? _a : {},
|
|
410
|
+
..."id" in item && "datasetId" in item ? {
|
|
411
|
+
datasetId: item["datasetId"],
|
|
412
|
+
datasetItemId: item["id"]
|
|
413
|
+
} : {}
|
|
414
|
+
}
|
|
406
415
|
});
|
|
407
416
|
return { output: output2, traceId: span.traceId };
|
|
408
417
|
}
|
|
@@ -465,7 +474,8 @@ ${JSON.stringify(params2)}
|
|
|
465
474
|
output,
|
|
466
475
|
evaluations: evals,
|
|
467
476
|
traceId,
|
|
468
|
-
datasetRunId
|
|
477
|
+
datasetRunId,
|
|
478
|
+
item
|
|
469
479
|
};
|
|
470
480
|
}
|
|
471
481
|
/**
|
|
@@ -486,7 +496,7 @@ ${JSON.stringify(params2)}
|
|
|
486
496
|
* @param params.runEvaluations - Results from run-level evaluators
|
|
487
497
|
* @param params.name - Name of the experiment
|
|
488
498
|
* @param params.description - Optional description of the experiment
|
|
489
|
-
* @param params.includeItemResults - Whether to include individual item details (default:
|
|
499
|
+
* @param params.includeItemResults - Whether to include individual item details (default: false)
|
|
490
500
|
*
|
|
491
501
|
* @returns Promise resolving to formatted string representation
|
|
492
502
|
*
|
|
@@ -536,7 +546,7 @@ ${JSON.stringify(params2)}
|
|
|
536
546
|
runEvaluations,
|
|
537
547
|
name,
|
|
538
548
|
description,
|
|
539
|
-
includeItemResults =
|
|
549
|
+
includeItemResults = false
|
|
540
550
|
} = params;
|
|
541
551
|
if (itemResults.length === 0) {
|
|
542
552
|
return "No experiment results to display.";
|