langsmith 0.5.19 → 0.6.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/dist/client.cjs +460 -22
- package/dist/client.d.ts +165 -1
- package/dist/client.js +464 -26
- package/dist/evaluation/_runner.cjs +4 -7
- package/dist/evaluation/_runner.js +2 -5
- package/dist/evaluation/evaluate_comparative.cjs +10 -10
- package/dist/evaluation/evaluate_comparative.js +1 -1
- package/dist/evaluation/evaluator.cjs +2 -2
- package/dist/evaluation/evaluator.js +1 -1
- package/dist/experimental/anthropic/context.cjs +419 -49
- package/dist/experimental/anthropic/context.js +420 -50
- package/dist/experimental/anthropic/index.cjs +78 -10
- package/dist/experimental/anthropic/index.js +80 -12
- package/dist/experimental/anthropic/messages.cjs +53 -0
- package/dist/experimental/anthropic/messages.d.ts +6 -0
- package/dist/experimental/anthropic/messages.js +52 -0
- package/dist/experimental/anthropic/transcripts.cjs +144 -0
- package/dist/experimental/anthropic/transcripts.d.ts +22 -0
- package/dist/experimental/anthropic/transcripts.js +141 -0
- package/dist/experimental/anthropic/types.d.ts +1 -0
- package/dist/experimental/anthropic/usage.cjs +19 -20
- package/dist/experimental/anthropic/usage.d.ts +2 -1
- package/dist/experimental/anthropic/usage.js +18 -20
- package/dist/experimental/opencode/index.cjs +36 -0
- package/dist/experimental/opencode/index.d.ts +3 -0
- package/dist/experimental/opencode/index.js +32 -0
- package/dist/experimental/opencode/tracer.cjs +389 -0
- package/dist/experimental/opencode/tracer.d.ts +30 -0
- package/dist/experimental/opencode/tracer.js +385 -0
- package/dist/experimental/otel/setup.cjs +1 -1
- package/dist/experimental/otel/setup.js +1 -1
- package/dist/experimental/sandbox/client.cjs +308 -409
- package/dist/experimental/sandbox/client.d.ts +136 -157
- package/dist/experimental/sandbox/client.js +310 -411
- package/dist/experimental/sandbox/errors.cjs +1 -2
- package/dist/experimental/sandbox/errors.d.ts +1 -2
- package/dist/experimental/sandbox/errors.js +1 -2
- package/dist/experimental/sandbox/helpers.cjs +8 -98
- package/dist/experimental/sandbox/helpers.d.ts +0 -29
- package/dist/experimental/sandbox/helpers.js +9 -95
- package/dist/experimental/sandbox/index.cjs +6 -1
- package/dist/experimental/sandbox/index.d.ts +7 -2
- package/dist/experimental/sandbox/index.js +6 -1
- package/dist/experimental/sandbox/sandbox.cjs +71 -13
- package/dist/experimental/sandbox/sandbox.d.ts +39 -9
- package/dist/experimental/sandbox/sandbox.js +71 -13
- package/dist/experimental/sandbox/types.d.ts +147 -137
- package/dist/experimental/vercel/index.cjs +1 -1
- package/dist/experimental/vercel/index.js +1 -1
- package/dist/experimental/vercel/middleware.cjs +2 -1
- package/dist/experimental/vercel/middleware.js +2 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/run_trees.cjs +8 -7
- package/dist/run_trees.d.ts +7 -0
- package/dist/run_trees.js +7 -6
- package/dist/schemas.d.ts +58 -0
- package/dist/singletons/otel.cjs +3 -2
- package/dist/singletons/otel.js +4 -3
- package/dist/singletons/traceable.cjs +1 -3
- package/dist/singletons/traceable.js +1 -3
- package/dist/traceable.cjs +2 -5
- package/dist/traceable.js +2 -5
- package/dist/utils/_git.cjs +2 -2
- package/dist/utils/_git.js +2 -2
- package/dist/utils/_uuid.cjs +2 -2
- package/dist/utils/_uuid.js +1 -1
- package/dist/utils/env.cjs +35 -2
- package/dist/utils/env.d.ts +9 -0
- package/dist/utils/env.js +34 -2
- package/dist/utils/error.cjs +9 -2
- package/dist/utils/error.d.ts +1 -0
- package/dist/utils/error.js +8 -2
- package/dist/utils/fast-safe-stringify/index.cjs +203 -0
- package/dist/utils/fast-safe-stringify/index.d.ts +46 -0
- package/dist/utils/fast-safe-stringify/index.js +202 -0
- package/dist/utils/jestlike/index.cjs +5 -5
- package/dist/utils/jestlike/index.js +1 -1
- package/dist/utils/jestlike/reporter.cjs +1 -1
- package/dist/utils/jestlike/reporter.js +1 -1
- package/dist/utils/jestlike/vendor/chain.cjs +2 -3
- package/dist/utils/jestlike/vendor/chain.js +2 -3
- package/dist/utils/jestlike/vendor/evaluatedBy.cjs +3 -3
- package/dist/utils/jestlike/vendor/evaluatedBy.js +1 -1
- package/dist/utils/prompts.cjs +7 -2
- package/dist/utils/prompts.d.ts +6 -1
- package/dist/utils/prompts.js +6 -1
- package/dist/utils/serialize_worker.cjs +388 -0
- package/dist/utils/serialize_worker.d.ts +66 -0
- package/dist/utils/serialize_worker.js +382 -0
- package/dist/utils/uuid/src/index.cjs +24 -0
- package/dist/utils/uuid/src/index.d.ts +10 -0
- package/dist/utils/uuid/src/index.js +9 -0
- package/dist/utils/uuid/src/max.cjs +3 -0
- package/dist/utils/uuid/src/max.d.ts +2 -0
- package/dist/utils/uuid/src/max.js +1 -0
- package/dist/utils/uuid/src/nil.cjs +3 -0
- package/dist/utils/uuid/src/nil.d.ts +2 -0
- package/dist/utils/uuid/src/nil.js +1 -0
- package/dist/utils/uuid/src/parse.cjs +23 -0
- package/dist/utils/uuid/src/parse.d.ts +3 -0
- package/dist/utils/uuid/src/parse.js +18 -0
- package/dist/utils/uuid/src/regex.cjs +3 -0
- package/dist/utils/uuid/src/regex.d.ts +2 -0
- package/dist/utils/uuid/src/regex.js +1 -0
- package/dist/utils/uuid/src/rng.cjs +10 -0
- package/dist/utils/uuid/src/rng.d.ts +1 -0
- package/dist/utils/uuid/src/rng.js +7 -0
- package/dist/utils/uuid/src/sha1.cjs +75 -0
- package/dist/utils/uuid/src/sha1.d.ts +2 -0
- package/dist/utils/uuid/src/sha1.js +73 -0
- package/dist/utils/uuid/src/stringify.cjs +55 -0
- package/dist/utils/uuid/src/stringify.d.ts +3 -0
- package/dist/utils/uuid/src/stringify.js +49 -0
- package/dist/utils/uuid/src/types.cjs +2 -0
- package/dist/utils/uuid/src/types.d.ts +22 -0
- package/dist/utils/uuid/src/types.js +1 -0
- package/dist/utils/uuid/src/v35.cjs +52 -0
- package/dist/utils/uuid/src/v35.d.ts +7 -0
- package/dist/utils/uuid/src/v35.js +44 -0
- package/dist/utils/uuid/src/v4.cjs +40 -0
- package/dist/utils/uuid/src/v4.d.ts +4 -0
- package/dist/utils/uuid/src/v4.js +35 -0
- package/dist/utils/uuid/src/v5.cjs +50 -0
- package/dist/utils/uuid/src/v5.d.ts +9 -0
- package/dist/utils/uuid/src/v5.js +9 -0
- package/dist/utils/uuid/src/v7.cjs +88 -0
- package/dist/utils/uuid/src/v7.d.ts +9 -0
- package/dist/utils/uuid/src/v7.js +82 -0
- package/dist/utils/uuid/src/validate.cjs +10 -0
- package/dist/utils/uuid/src/validate.d.ts +2 -0
- package/dist/utils/uuid/src/validate.js +5 -0
- package/dist/utils/uuid/src/version.cjs +13 -0
- package/dist/utils/uuid/src/version.d.ts +2 -0
- package/dist/utils/uuid/src/version.js +8 -0
- package/dist/utils/worker_threads.browser.cjs +16 -0
- package/dist/utils/worker_threads.browser.d.ts +14 -0
- package/dist/utils/worker_threads.browser.js +13 -0
- package/dist/utils/worker_threads.cjs +16 -0
- package/dist/utils/worker_threads.d.ts +13 -0
- package/dist/utils/worker_threads.js +13 -0
- package/dist/uuid.cjs +2 -2
- package/dist/uuid.js +1 -1
- package/dist/vitest/utils/esm.mjs +4 -4
- package/dist/wrappers/gemini.cjs +1 -1
- package/dist/wrappers/gemini.js +1 -1
- package/dist/wrappers/openai.cjs +2 -6
- package/dist/wrappers/openai.js +2 -6
- package/dist/wrappers/openai_agents.cjs +849 -0
- package/dist/wrappers/openai_agents.d.ts +92 -0
- package/dist/wrappers/openai_agents.js +845 -0
- package/experimental/opencode.cjs +1 -0
- package/experimental/opencode.d.cts +1 -0
- package/experimental/opencode.d.ts +1 -0
- package/experimental/opencode.js +1 -0
- package/package.json +47 -25
- package/wrappers/openai_agents.cjs +1 -0
- package/wrappers/openai_agents.d.cts +1 -0
- package/wrappers/openai_agents.d.ts +1 -0
- package/wrappers/openai_agents.js +1 -0
|
@@ -13,7 +13,7 @@ const env_js_1 = require("../utils/env.cjs");
|
|
|
13
13
|
const error_js_1 = require("../utils/error.cjs");
|
|
14
14
|
const _random_name_js_1 = require("./_random_name.cjs");
|
|
15
15
|
const evaluator_js_1 = require("./evaluator.cjs");
|
|
16
|
-
const
|
|
16
|
+
const index_js_2 = require("../utils/uuid/src/index.cjs");
|
|
17
17
|
const evaluate_comparative_js_1 = require("./evaluate_comparative.cjs");
|
|
18
18
|
const p_queue_js_1 = require("../utils/p-queue.cjs");
|
|
19
19
|
// Implementation signature
|
|
@@ -202,7 +202,7 @@ class _ExperimentManager {
|
|
|
202
202
|
this._experimentName = (0, _random_name_js_1.randomName)();
|
|
203
203
|
}
|
|
204
204
|
else if (typeof args.experiment === "string") {
|
|
205
|
-
this._experimentName = `${args.experiment}-${(0,
|
|
205
|
+
this._experimentName = `${args.experiment}-${(0, index_js_2.v4)().slice(0, 8)}`;
|
|
206
206
|
}
|
|
207
207
|
else {
|
|
208
208
|
if (!args.experiment.name) {
|
|
@@ -276,7 +276,7 @@ class _ExperimentManager {
|
|
|
276
276
|
catch (e) {
|
|
277
277
|
// Naming collision
|
|
278
278
|
if (e?.name === "LangSmithConflictError") {
|
|
279
|
-
const ent = (0,
|
|
279
|
+
const ent = (0, index_js_2.v4)().slice(0, 6);
|
|
280
280
|
this._experimentName = `${originalExperimentName}-${ent}`;
|
|
281
281
|
}
|
|
282
282
|
else {
|
|
@@ -726,10 +726,7 @@ async function _evaluate(target, fields) {
|
|
|
726
726
|
const standardFields = fields;
|
|
727
727
|
const [experiment_, newRuns] = await _resolveExperiment(fields.experiment ?? null, runs, client);
|
|
728
728
|
let manager = await new _ExperimentManager({
|
|
729
|
-
data:
|
|
730
|
-
examples: Array.isArray(standardFields.data)
|
|
731
|
-
? standardFields.data
|
|
732
|
-
: undefined,
|
|
729
|
+
data: standardFields.data,
|
|
733
730
|
client,
|
|
734
731
|
metadata: fields.metadata,
|
|
735
732
|
experiment: experiment_ ?? fields.experimentPrefix,
|
|
@@ -7,7 +7,7 @@ import { getLangSmithEnvVarsMetadata } from "../utils/env.js";
|
|
|
7
7
|
import { printErrorStackTrace } from "../utils/error.js";
|
|
8
8
|
import { randomName } from "./_random_name.js";
|
|
9
9
|
import { runEvaluator, } from "./evaluator.js";
|
|
10
|
-
import { v4 as uuidv4 } from "uuid";
|
|
10
|
+
import { v4 as uuidv4 } from "../utils/uuid/src/index.js";
|
|
11
11
|
import { evaluateComparative, } from "./evaluate_comparative.js";
|
|
12
12
|
import { PQueue } from "../utils/p-queue.js";
|
|
13
13
|
// Implementation signature
|
|
@@ -719,10 +719,7 @@ async function _evaluate(target, fields) {
|
|
|
719
719
|
const standardFields = fields;
|
|
720
720
|
const [experiment_, newRuns] = await _resolveExperiment(fields.experiment ?? null, runs, client);
|
|
721
721
|
let manager = await new _ExperimentManager({
|
|
722
|
-
data:
|
|
723
|
-
examples: Array.isArray(standardFields.data)
|
|
724
|
-
? standardFields.data
|
|
725
|
-
: undefined,
|
|
722
|
+
data: standardFields.data,
|
|
726
723
|
client,
|
|
727
724
|
metadata: fields.metadata,
|
|
728
725
|
experiment: experiment_ ?? fields.experimentPrefix,
|
|
@@ -4,22 +4,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.evaluateComparative = evaluateComparative;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
7
|
+
const index_js_1 = require("../utils/uuid/src/index.cjs");
|
|
8
|
+
const index_js_2 = require("../index.cjs");
|
|
9
9
|
const shuffle_js_1 = require("../utils/shuffle.cjs");
|
|
10
10
|
const async_caller_js_1 = require("../utils/async_caller.cjs");
|
|
11
|
-
const
|
|
11
|
+
const index_js_3 = __importDefault(require("../utils/p-retry/index.cjs"));
|
|
12
12
|
const traceable_js_1 = require("../traceable.cjs");
|
|
13
13
|
function isExperimentResultsList(value) {
|
|
14
14
|
return value.some((x) => typeof x !== "string");
|
|
15
15
|
}
|
|
16
16
|
async function loadExperiment(client, experiment) {
|
|
17
17
|
const value = typeof experiment === "string" ? experiment : experiment.experimentName;
|
|
18
|
-
return client.readProject((0,
|
|
18
|
+
return client.readProject((0, index_js_1.validate)(value) ? { projectId: value } : { projectName: value });
|
|
19
19
|
}
|
|
20
20
|
async function loadTraces(client, experiment, options) {
|
|
21
21
|
const executionOrder = options.loadNested ? undefined : 1;
|
|
22
|
-
const runs = await client.listRuns((0,
|
|
22
|
+
const runs = await client.listRuns((0, index_js_1.validate)(experiment)
|
|
23
23
|
? { projectId: experiment, executionOrder }
|
|
24
24
|
: { projectName: experiment, executionOrder });
|
|
25
25
|
const treeMap = {};
|
|
@@ -56,7 +56,7 @@ async function evaluateComparative(experiments, options) {
|
|
|
56
56
|
if (options.maxConcurrency && options.maxConcurrency < 0) {
|
|
57
57
|
throw new Error("maxConcurrency must be a positive number.");
|
|
58
58
|
}
|
|
59
|
-
const client = options.client ?? new
|
|
59
|
+
const client = options.client ?? new index_js_2.Client();
|
|
60
60
|
const resolvedExperiments = await Promise.all(experiments);
|
|
61
61
|
const projects = await (() => {
|
|
62
62
|
if (!isExperimentResultsList(resolvedExperiments)) {
|
|
@@ -64,7 +64,7 @@ async function evaluateComparative(experiments, options) {
|
|
|
64
64
|
}
|
|
65
65
|
// if we know the number of runs beforehand, check if the
|
|
66
66
|
// number of runs in the project matches the expected number of runs
|
|
67
|
-
return Promise.all(resolvedExperiments.map((experiment) => (0,
|
|
67
|
+
return Promise.all(resolvedExperiments.map((experiment) => (0, index_js_3.default)(async () => {
|
|
68
68
|
const project = await loadExperiment(client, experiment);
|
|
69
69
|
if (project.run_count !== experiment?.results.length) {
|
|
70
70
|
throw new Error("Experiment is missing runs. Retrying.");
|
|
@@ -83,16 +83,16 @@ async function evaluateComparative(experiments, options) {
|
|
|
83
83
|
console.warn("Detected multiple dataset versions used by experiments, which may lead to inaccurate results.");
|
|
84
84
|
}
|
|
85
85
|
const datasetVersion = projects.at(0)?.extra?.metadata?.dataset_version;
|
|
86
|
-
const id = (0,
|
|
86
|
+
const id = (0, index_js_1.v4)();
|
|
87
87
|
const experimentName = (() => {
|
|
88
88
|
if (!options.experimentPrefix) {
|
|
89
89
|
const names = projects
|
|
90
90
|
.map((p) => p.name)
|
|
91
91
|
.filter(Boolean)
|
|
92
92
|
.join(" vs. ");
|
|
93
|
-
return `${names}-${(0,
|
|
93
|
+
return `${names}-${(0, index_js_1.v4)().slice(0, 4)}`;
|
|
94
94
|
}
|
|
95
|
-
return `${options.experimentPrefix}-${(0,
|
|
95
|
+
return `${options.experimentPrefix}-${(0, index_js_1.v4)().slice(0, 4)}`;
|
|
96
96
|
})();
|
|
97
97
|
// TODO: add URL to the comparative experiment
|
|
98
98
|
console.log(`Starting pairwise evaluation of: ${experimentName}`);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DynamicRunEvaluator = void 0;
|
|
4
4
|
exports.runEvaluator = runEvaluator;
|
|
5
|
-
const
|
|
5
|
+
const index_js_1 = require("../utils/uuid/src/index.cjs");
|
|
6
6
|
const traceable_js_1 = require("../traceable.cjs");
|
|
7
7
|
/**
|
|
8
8
|
* Wraps an evaluator function + implements the RunEvaluator interface.
|
|
@@ -67,7 +67,7 @@ class DynamicRunEvaluator {
|
|
|
67
67
|
* @returns A promise that extracts to the evaluation result.
|
|
68
68
|
*/
|
|
69
69
|
async evaluateRun(run, example, options) {
|
|
70
|
-
let sourceRunId = (0,
|
|
70
|
+
let sourceRunId = (0, index_js_1.v7)();
|
|
71
71
|
const metadata = {
|
|
72
72
|
targetRunId: run.id,
|
|
73
73
|
};
|