langsmith 0.3.5 → 0.3.6
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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/jest/index.cjs +1 -4
- package/dist/jest/index.d.ts +4 -10
- package/dist/jest/index.js +0 -6
- package/dist/utils/jestlike/index.cjs +27 -8
- package/dist/utils/jestlike/index.d.ts +4 -4
- package/dist/utils/jestlike/index.js +27 -8
- package/dist/utils/jestlike/types.d.ts +10 -1
- package/dist/vitest/index.cjs +1 -4
- package/dist/vitest/index.d.ts +4 -10
- package/dist/vitest/index.js +0 -6
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -8,4 +8,4 @@ Object.defineProperty(exports, "RunTree", { enumerable: true, get: function () {
|
|
|
8
8
|
var fetch_js_1 = require("./singletons/fetch.cjs");
|
|
9
9
|
Object.defineProperty(exports, "overrideFetchImplementation", { enumerable: true, get: function () { return fetch_js_1.overrideFetchImplementation; } });
|
|
10
10
|
// Update using yarn bump-version
|
|
11
|
-
exports.__version__ = "0.3.
|
|
11
|
+
exports.__version__ = "0.3.6";
|
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ export { Client, type ClientConfig, type LangSmithTracingClientInterface, } from
|
|
|
2
2
|
export type { Dataset, Example, TracerSession, Run, Feedback, RetrieverOutput, } from "./schemas.js";
|
|
3
3
|
export { RunTree, type RunTreeConfig } from "./run_trees.js";
|
|
4
4
|
export { overrideFetchImplementation } from "./singletons/fetch.js";
|
|
5
|
-
export declare const __version__ = "0.3.
|
|
5
|
+
export declare const __version__ = "0.3.6";
|
package/dist/index.js
CHANGED
package/dist/jest/index.cjs
CHANGED
|
@@ -16,12 +16,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
17
|
};
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.wrapEvaluator = exports.logOutputs = exports.logFeedback = exports.
|
|
19
|
+
exports.wrapEvaluator = exports.logOutputs = exports.logFeedback = exports.expect = exports.describe = exports.it = exports.test = void 0;
|
|
20
20
|
const globals_1 = require("@jest/globals");
|
|
21
21
|
const matchers_js_1 = require("../utils/jestlike/matchers.cjs");
|
|
22
|
-
Object.defineProperty(exports, "toBeRelativeCloseTo", { enumerable: true, get: function () { return matchers_js_1.toBeRelativeCloseTo; } });
|
|
23
|
-
Object.defineProperty(exports, "toBeAbsoluteCloseTo", { enumerable: true, get: function () { return matchers_js_1.toBeAbsoluteCloseTo; } });
|
|
24
|
-
Object.defineProperty(exports, "toBeSemanticCloseTo", { enumerable: true, get: function () { return matchers_js_1.toBeSemanticCloseTo; } });
|
|
25
22
|
const evaluatedBy_js_1 = require("../utils/jestlike/vendor/evaluatedBy.cjs");
|
|
26
23
|
Object.defineProperty(exports, "wrapEvaluator", { enumerable: true, get: function () { return evaluatedBy_js_1.wrapEvaluator; } });
|
|
27
24
|
const index_js_1 = require("../utils/jestlike/index.cjs");
|
package/dist/jest/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="jest" />
|
|
2
|
-
import {
|
|
2
|
+
import { type AbsoluteCloseToMatcherOptions, type SemanticCloseToMatcherOptions, type RelativeCloseToMatcherOptions } from "../utils/jestlike/matchers.js";
|
|
3
3
|
import type { SimpleEvaluator } from "../utils/jestlike/vendor/evaluatedBy.js";
|
|
4
4
|
import { wrapEvaluator } from "../utils/jestlike/vendor/evaluatedBy.js";
|
|
5
5
|
import { logFeedback, logOutputs } from "../utils/jestlike/index.js";
|
|
@@ -128,9 +128,9 @@ declare const test: (<I extends Record<string, any> = Record<string, any>, O ext
|
|
|
128
128
|
inputs: I;
|
|
129
129
|
referenceOutputs?: O | undefined;
|
|
130
130
|
} & Record<string, any>) => unknown, timeout?: number | undefined) => void;
|
|
131
|
-
}, describe: import("../utils/jestlike/types.js").
|
|
132
|
-
only: import("../utils/jestlike/types.js").
|
|
133
|
-
skip: import("../utils/jestlike/types.js").
|
|
131
|
+
}, describe: import("../utils/jestlike/types.js").LangSmithJestlikeDescribeWrapper & {
|
|
132
|
+
only: import("../utils/jestlike/types.js").LangSmithJestlikeDescribeWrapper;
|
|
133
|
+
skip: import("../utils/jestlike/types.js").LangSmithJestlikeDescribeWrapper;
|
|
134
134
|
}, expect: jest.Expect;
|
|
135
135
|
export {
|
|
136
136
|
/**
|
|
@@ -324,12 +324,6 @@ describe,
|
|
|
324
324
|
* ```
|
|
325
325
|
*/
|
|
326
326
|
expect,
|
|
327
|
-
/** Whether the actual string value is close to the expected value in relative terms. */
|
|
328
|
-
toBeRelativeCloseTo,
|
|
329
|
-
/** Whether the actual string value is close to the expected value in absolute terms. */
|
|
330
|
-
toBeAbsoluteCloseTo,
|
|
331
|
-
/** Whether the actual string value is close to the expected value as scored by an embeddings model. */
|
|
332
|
-
toBeSemanticCloseTo,
|
|
333
327
|
/**
|
|
334
328
|
* Log feedback associated with the current test, usually generated by some kind of
|
|
335
329
|
* evaluator.
|
package/dist/jest/index.js
CHANGED
|
@@ -209,12 +209,6 @@ describe,
|
|
|
209
209
|
* ```
|
|
210
210
|
*/
|
|
211
211
|
expect,
|
|
212
|
-
/** Whether the actual string value is close to the expected value in relative terms. */
|
|
213
|
-
toBeRelativeCloseTo,
|
|
214
|
-
/** Whether the actual string value is close to the expected value in absolute terms. */
|
|
215
|
-
toBeAbsoluteCloseTo,
|
|
216
|
-
/** Whether the actual string value is close to the expected value as scored by an embeddings model. */
|
|
217
|
-
toBeSemanticCloseTo,
|
|
218
212
|
/**
|
|
219
213
|
* Log feedback associated with the current test, usually generated by some kind of
|
|
220
214
|
* evaluator.
|
|
@@ -40,6 +40,7 @@ const _random_name_js_1 = require("../../evaluation/_random_name.cjs");
|
|
|
40
40
|
const matchers_js_1 = require("./matchers.cjs");
|
|
41
41
|
const globals_js_1 = require("./globals.cjs");
|
|
42
42
|
const chain_js_1 = require("./vendor/chain.cjs");
|
|
43
|
+
const env_js_1 = require("../env.cjs");
|
|
43
44
|
const DEFAULT_TEST_TIMEOUT = 30_000;
|
|
44
45
|
const UUID5_NAMESPACE = "6ba7b810-9dad-11d1-80b4-00c04fd430c8";
|
|
45
46
|
// From https://stackoverflow.com/a/29497680
|
|
@@ -209,7 +210,7 @@ function generateWrapperFromJestlikeMethods(methods, testRunnerName) {
|
|
|
209
210
|
datasetId: dataset.id,
|
|
210
211
|
});
|
|
211
212
|
const experimentUrl = `${datasetUrl}/compare?selectedSessions=${project.id}`;
|
|
212
|
-
console.log(`[LANGSMITH]: Experiment starting
|
|
213
|
+
console.log(`[LANGSMITH]: Experiment starting for dataset "${datasetName}"!\n[LANGSMITH]: View results at ${experimentUrl}`);
|
|
213
214
|
storageValue = {
|
|
214
215
|
dataset,
|
|
215
216
|
project,
|
|
@@ -220,22 +221,40 @@ function generateWrapperFromJestlikeMethods(methods, testRunnerName) {
|
|
|
220
221
|
return storageValue;
|
|
221
222
|
}
|
|
222
223
|
function wrapDescribeMethod(method) {
|
|
223
|
-
return function (
|
|
224
|
+
return function (testSuiteName, fn, experimentConfig) {
|
|
224
225
|
const client = experimentConfig?.client ?? globals_js_1.DEFAULT_TEST_CLIENT;
|
|
225
|
-
|
|
226
|
+
const suiteName = experimentConfig?.testSuiteName ?? testSuiteName;
|
|
227
|
+
return method(suiteName, () => {
|
|
226
228
|
const startTime = new Date();
|
|
227
229
|
const suiteUuid = (0, uuid_1.v4)();
|
|
230
|
+
const environment = experimentConfig?.metadata?.ENVIRONMENT ??
|
|
231
|
+
(0, env_js_1.getEnvironmentVariable)("ENVIRONMENT");
|
|
232
|
+
const nodeEnv = experimentConfig?.metadata?.NODE_ENV ??
|
|
233
|
+
(0, env_js_1.getEnvironmentVariable)("NODE_ENV");
|
|
234
|
+
const langsmithEnvironment = experimentConfig?.metadata?.LANGSMITH_ENVIRONMENT ??
|
|
235
|
+
(0, env_js_1.getEnvironmentVariable)("LANGSMITH_ENVIRONMENT");
|
|
236
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
237
|
+
const metadata = {
|
|
238
|
+
...experimentConfig?.metadata,
|
|
239
|
+
__ls_runner: testRunnerName,
|
|
240
|
+
};
|
|
241
|
+
if (environment !== undefined) {
|
|
242
|
+
metadata.ENVIRONMENT = environment;
|
|
243
|
+
}
|
|
244
|
+
if (nodeEnv !== undefined) {
|
|
245
|
+
metadata.NODE_ENV = nodeEnv;
|
|
246
|
+
}
|
|
247
|
+
if (langsmithEnvironment !== undefined) {
|
|
248
|
+
metadata.LANGSMITH_ENVIRONMENT = langsmithEnvironment;
|
|
249
|
+
}
|
|
228
250
|
const context = {
|
|
229
251
|
suiteUuid,
|
|
230
|
-
suiteName
|
|
252
|
+
suiteName,
|
|
231
253
|
client,
|
|
232
254
|
createdAt: new Date().toISOString(),
|
|
233
255
|
projectConfig: {
|
|
234
256
|
...experimentConfig,
|
|
235
|
-
metadata
|
|
236
|
-
...experimentConfig?.metadata,
|
|
237
|
-
__ls_runner: testRunnerName,
|
|
238
|
-
},
|
|
257
|
+
metadata,
|
|
239
258
|
},
|
|
240
259
|
enableTestTracking: experimentConfig?.enableTestTracking,
|
|
241
260
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { KVMap } from "../../schemas.js";
|
|
3
3
|
import { toBeRelativeCloseTo, toBeAbsoluteCloseTo, toBeSemanticCloseTo } from "./matchers.js";
|
|
4
4
|
import { SimpleEvaluationResult } from "./types.js";
|
|
5
|
-
import type { LangSmithJestlikeWrapperConfig, LangSmithJestlikeWrapperParams,
|
|
5
|
+
import type { LangSmithJestlikeWrapperConfig, LangSmithJestlikeWrapperParams, LangSmithJestlikeDescribeWrapper } from "./types.js";
|
|
6
6
|
export declare const STRIP_ANSI_REGEX: RegExp;
|
|
7
7
|
export declare const TEST_ID_DELIMITER = ", test_id=";
|
|
8
8
|
export declare function logFeedback(feedback: SimpleEvaluationResult, config?: {
|
|
@@ -83,9 +83,9 @@ export declare function generateWrapperFromJestlikeMethods(methods: Record<strin
|
|
|
83
83
|
referenceOutputs?: O_1 | undefined;
|
|
84
84
|
} & Record<string, any>) => unknown | Promise<unknown>, timeout?: number) => void;
|
|
85
85
|
};
|
|
86
|
-
describe:
|
|
87
|
-
only:
|
|
88
|
-
skip:
|
|
86
|
+
describe: LangSmithJestlikeDescribeWrapper & {
|
|
87
|
+
only: LangSmithJestlikeDescribeWrapper;
|
|
88
|
+
skip: LangSmithJestlikeDescribeWrapper;
|
|
89
89
|
};
|
|
90
90
|
expect: jest.Expect;
|
|
91
91
|
toBeRelativeCloseTo: typeof toBeRelativeCloseTo;
|
|
@@ -11,6 +11,7 @@ import { randomName } from "../../evaluation/_random_name.js";
|
|
|
11
11
|
import { toBeRelativeCloseTo, toBeAbsoluteCloseTo, toBeSemanticCloseTo, } from "./matchers.js";
|
|
12
12
|
import { evaluatorLogFeedbackPromises, testWrapperAsyncLocalStorageInstance, _logTestFeedback, syncExamplePromises, trackingEnabled, DEFAULT_TEST_CLIENT, } from "./globals.js";
|
|
13
13
|
import { wrapExpect } from "./vendor/chain.js";
|
|
14
|
+
import { getEnvironmentVariable } from "../env.js";
|
|
14
15
|
const DEFAULT_TEST_TIMEOUT = 30_000;
|
|
15
16
|
const UUID5_NAMESPACE = "6ba7b810-9dad-11d1-80b4-00c04fd430c8";
|
|
16
17
|
// From https://stackoverflow.com/a/29497680
|
|
@@ -177,7 +178,7 @@ export function generateWrapperFromJestlikeMethods(methods, testRunnerName) {
|
|
|
177
178
|
datasetId: dataset.id,
|
|
178
179
|
});
|
|
179
180
|
const experimentUrl = `${datasetUrl}/compare?selectedSessions=${project.id}`;
|
|
180
|
-
console.log(`[LANGSMITH]: Experiment starting
|
|
181
|
+
console.log(`[LANGSMITH]: Experiment starting for dataset "${datasetName}"!\n[LANGSMITH]: View results at ${experimentUrl}`);
|
|
181
182
|
storageValue = {
|
|
182
183
|
dataset,
|
|
183
184
|
project,
|
|
@@ -188,22 +189,40 @@ export function generateWrapperFromJestlikeMethods(methods, testRunnerName) {
|
|
|
188
189
|
return storageValue;
|
|
189
190
|
}
|
|
190
191
|
function wrapDescribeMethod(method) {
|
|
191
|
-
return function (
|
|
192
|
+
return function (testSuiteName, fn, experimentConfig) {
|
|
192
193
|
const client = experimentConfig?.client ?? DEFAULT_TEST_CLIENT;
|
|
193
|
-
|
|
194
|
+
const suiteName = experimentConfig?.testSuiteName ?? testSuiteName;
|
|
195
|
+
return method(suiteName, () => {
|
|
194
196
|
const startTime = new Date();
|
|
195
197
|
const suiteUuid = v4();
|
|
198
|
+
const environment = experimentConfig?.metadata?.ENVIRONMENT ??
|
|
199
|
+
getEnvironmentVariable("ENVIRONMENT");
|
|
200
|
+
const nodeEnv = experimentConfig?.metadata?.NODE_ENV ??
|
|
201
|
+
getEnvironmentVariable("NODE_ENV");
|
|
202
|
+
const langsmithEnvironment = experimentConfig?.metadata?.LANGSMITH_ENVIRONMENT ??
|
|
203
|
+
getEnvironmentVariable("LANGSMITH_ENVIRONMENT");
|
|
204
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
205
|
+
const metadata = {
|
|
206
|
+
...experimentConfig?.metadata,
|
|
207
|
+
__ls_runner: testRunnerName,
|
|
208
|
+
};
|
|
209
|
+
if (environment !== undefined) {
|
|
210
|
+
metadata.ENVIRONMENT = environment;
|
|
211
|
+
}
|
|
212
|
+
if (nodeEnv !== undefined) {
|
|
213
|
+
metadata.NODE_ENV = nodeEnv;
|
|
214
|
+
}
|
|
215
|
+
if (langsmithEnvironment !== undefined) {
|
|
216
|
+
metadata.LANGSMITH_ENVIRONMENT = langsmithEnvironment;
|
|
217
|
+
}
|
|
196
218
|
const context = {
|
|
197
219
|
suiteUuid,
|
|
198
|
-
suiteName
|
|
220
|
+
suiteName,
|
|
199
221
|
client,
|
|
200
222
|
createdAt: new Date().toISOString(),
|
|
201
223
|
projectConfig: {
|
|
202
224
|
...experimentConfig,
|
|
203
|
-
metadata
|
|
204
|
-
...experimentConfig?.metadata,
|
|
205
|
-
__ls_runner: testRunnerName,
|
|
206
|
-
},
|
|
225
|
+
metadata,
|
|
207
226
|
},
|
|
208
227
|
enableTestTracking: experimentConfig?.enableTestTracking,
|
|
209
228
|
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { CreateProjectParams } from "../../client.js";
|
|
1
2
|
import { EvaluationResult } from "../../evaluation/evaluator.js";
|
|
3
|
+
import { Client } from "../../index.js";
|
|
2
4
|
import type { RunTreeConfig } from "../../run_trees.js";
|
|
3
5
|
import type { SimpleEvaluator } from "./vendor/evaluatedBy.js";
|
|
4
6
|
export { type SimpleEvaluator };
|
|
@@ -11,7 +13,14 @@ export type LangSmithJestlikeWrapperParams<I, O> = {
|
|
|
11
13
|
referenceOutputs: O;
|
|
12
14
|
config?: LangSmithJestlikeWrapperConfig;
|
|
13
15
|
};
|
|
14
|
-
export type
|
|
16
|
+
export type LangSmithJestlikeDescribeWrapperConfig = {
|
|
17
|
+
client?: Client;
|
|
18
|
+
enableTestTracking?: boolean;
|
|
19
|
+
testSuiteName?: string;
|
|
20
|
+
} & Partial<Omit<CreateProjectParams, "referenceDatasetId">>;
|
|
21
|
+
export type LangSmithJestlikeDescribeWrapper = (name: string, fn: () => void | Promise<void>, config?: LangSmithJestlikeDescribeWrapperConfig) => void;
|
|
22
|
+
/** @deprecated Import as `LangSmithJestlikeDescribeWrapper` instead. */
|
|
23
|
+
export type LangSmithJestDescribeWrapper = LangSmithJestlikeDescribeWrapper;
|
|
15
24
|
export type SimpleEvaluationResult = {
|
|
16
25
|
key: EvaluationResult["key"];
|
|
17
26
|
score: NonNullable<EvaluationResult["score"]>;
|
package/dist/vitest/index.cjs
CHANGED
|
@@ -16,12 +16,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
17
|
};
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.wrapEvaluator = exports.logOutputs = exports.logFeedback = exports.
|
|
19
|
+
exports.wrapEvaluator = exports.logOutputs = exports.logFeedback = exports.expect = exports.describe = exports.it = exports.test = void 0;
|
|
20
20
|
const vitest_1 = require("vitest");
|
|
21
21
|
const matchers_js_1 = require("../utils/jestlike/matchers.cjs");
|
|
22
|
-
Object.defineProperty(exports, "toBeRelativeCloseTo", { enumerable: true, get: function () { return matchers_js_1.toBeRelativeCloseTo; } });
|
|
23
|
-
Object.defineProperty(exports, "toBeAbsoluteCloseTo", { enumerable: true, get: function () { return matchers_js_1.toBeAbsoluteCloseTo; } });
|
|
24
|
-
Object.defineProperty(exports, "toBeSemanticCloseTo", { enumerable: true, get: function () { return matchers_js_1.toBeSemanticCloseTo; } });
|
|
25
22
|
const evaluatedBy_js_1 = require("../utils/jestlike/vendor/evaluatedBy.cjs");
|
|
26
23
|
Object.defineProperty(exports, "wrapEvaluator", { enumerable: true, get: function () { return evaluatedBy_js_1.wrapEvaluator; } });
|
|
27
24
|
const index_js_1 = require("../utils/jestlike/index.cjs");
|
package/dist/vitest/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="jest" />
|
|
2
2
|
import { Assertion } from "vitest";
|
|
3
|
-
import {
|
|
3
|
+
import { type AbsoluteCloseToMatcherOptions, type SemanticCloseToMatcherOptions, type RelativeCloseToMatcherOptions } from "../utils/jestlike/matchers.js";
|
|
4
4
|
import type { SimpleEvaluator } from "../utils/jestlike/vendor/evaluatedBy.js";
|
|
5
5
|
import { wrapEvaluator } from "../utils/jestlike/vendor/evaluatedBy.js";
|
|
6
6
|
import { logFeedback, logOutputs } from "../utils/jestlike/index.js";
|
|
@@ -126,9 +126,9 @@ declare const test: (<I extends Record<string, any> = Record<string, any>, O ext
|
|
|
126
126
|
inputs: I;
|
|
127
127
|
referenceOutputs?: O | undefined;
|
|
128
128
|
} & Record<string, any>) => unknown, timeout?: number | undefined) => void;
|
|
129
|
-
}, describe: import("../utils/jestlike/types.js").
|
|
130
|
-
only: import("../utils/jestlike/types.js").
|
|
131
|
-
skip: import("../utils/jestlike/types.js").
|
|
129
|
+
}, describe: import("../utils/jestlike/types.js").LangSmithJestlikeDescribeWrapper & {
|
|
130
|
+
only: import("../utils/jestlike/types.js").LangSmithJestlikeDescribeWrapper;
|
|
131
|
+
skip: import("../utils/jestlike/types.js").LangSmithJestlikeDescribeWrapper;
|
|
132
132
|
}, expect: jest.Expect;
|
|
133
133
|
export {
|
|
134
134
|
/**
|
|
@@ -322,12 +322,6 @@ describe,
|
|
|
322
322
|
* ```
|
|
323
323
|
*/
|
|
324
324
|
expect,
|
|
325
|
-
/** Whether the actual string value is close to the expected value in relative terms. */
|
|
326
|
-
toBeRelativeCloseTo,
|
|
327
|
-
/** Whether the actual string value is close to the expected value in absolute terms. */
|
|
328
|
-
toBeAbsoluteCloseTo,
|
|
329
|
-
/** Whether the actual string value is close to the expected value as scored by an embeddings model. */
|
|
330
|
-
toBeSemanticCloseTo,
|
|
331
325
|
/**
|
|
332
326
|
* Log feedback associated with the current test, usually generated by some kind of
|
|
333
327
|
* evaluator.
|
package/dist/vitest/index.js
CHANGED
|
@@ -209,12 +209,6 @@ describe,
|
|
|
209
209
|
* ```
|
|
210
210
|
*/
|
|
211
211
|
expect,
|
|
212
|
-
/** Whether the actual string value is close to the expected value in relative terms. */
|
|
213
|
-
toBeRelativeCloseTo,
|
|
214
|
-
/** Whether the actual string value is close to the expected value in absolute terms. */
|
|
215
|
-
toBeAbsoluteCloseTo,
|
|
216
|
-
/** Whether the actual string value is close to the expected value as scored by an embeddings model. */
|
|
217
|
-
toBeSemanticCloseTo,
|
|
218
212
|
/**
|
|
219
213
|
* Log feedback associated with the current test, usually generated by some kind of
|
|
220
214
|
* evaluator.
|