langsmith 0.3.17 → 0.3.18
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/utils/jestlike/globals.d.ts +1 -0
- package/dist/utils/jestlike/index.cjs +49 -42
- package/dist/utils/jestlike/index.js +49 -42
- 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.18";
|
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.18";
|
package/dist/index.js
CHANGED
|
@@ -18,6 +18,7 @@ export type TestWrapperAsyncLocalStorageData = {
|
|
|
18
18
|
client: Client;
|
|
19
19
|
suiteUuid: string;
|
|
20
20
|
suiteName: string;
|
|
21
|
+
testRootRunTree?: RunTree;
|
|
21
22
|
};
|
|
22
23
|
export declare const testWrapperAsyncLocalStorageInstance: AsyncLocalStorage<TestWrapperAsyncLocalStorageData>;
|
|
23
24
|
export declare function trackingEnabled(context: TestWrapperAsyncLocalStorageData): boolean;
|
|
@@ -79,7 +79,7 @@ function logFeedback(feedback, config) {
|
|
|
79
79
|
exampleId: context.currentExample.id,
|
|
80
80
|
feedback: feedback,
|
|
81
81
|
context,
|
|
82
|
-
runTree:
|
|
82
|
+
runTree: context.testRootRunTree,
|
|
83
83
|
client: context.client,
|
|
84
84
|
});
|
|
85
85
|
}
|
|
@@ -399,52 +399,59 @@ function generateWrapperFromJestlikeMethods(methods, testRunnerName) {
|
|
|
399
399
|
};
|
|
400
400
|
let exampleId;
|
|
401
401
|
const runTestFn = async () => {
|
|
402
|
-
|
|
402
|
+
let testContext = globals_js_1.testWrapperAsyncLocalStorageInstance.getStore();
|
|
403
403
|
if (testContext === undefined) {
|
|
404
404
|
throw new Error("Could not identify test context. Please contact us for help.");
|
|
405
405
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
406
|
+
return globals_js_1.testWrapperAsyncLocalStorageInstance.run({
|
|
407
|
+
...testContext,
|
|
408
|
+
testRootRunTree: (0, globals_js_1.trackingEnabled)(testContext)
|
|
409
|
+
? (0, traceable_js_1.getCurrentRunTree)()
|
|
410
|
+
: undefined,
|
|
411
|
+
}, async () => {
|
|
412
|
+
testContext = globals_js_1.testWrapperAsyncLocalStorageInstance.getStore();
|
|
413
|
+
if (testContext === undefined) {
|
|
414
|
+
throw new Error("Could not identify test context after setting test root run tree. Please contact us for help.");
|
|
415
|
+
}
|
|
416
|
+
try {
|
|
417
|
+
const res = await testFn({
|
|
418
|
+
...rest,
|
|
419
|
+
inputs: testInput,
|
|
420
|
+
referenceOutputs: testOutput,
|
|
421
|
+
});
|
|
422
|
+
(0, globals_js_1._logTestFeedback)({
|
|
423
|
+
exampleId,
|
|
424
|
+
feedback: { key: "pass", score: true },
|
|
425
|
+
context: testContext,
|
|
426
|
+
runTree: testContext.testRootRunTree,
|
|
427
|
+
client: testContext.client,
|
|
428
|
+
});
|
|
429
|
+
if (res != null) {
|
|
430
|
+
if (loggedOutput !== undefined) {
|
|
431
|
+
console.warn(`[WARN]: Returned value from test function will override output set by previous "logOutputs()" call.`);
|
|
432
|
+
}
|
|
433
|
+
loggedOutput =
|
|
434
|
+
typeof res === "object"
|
|
435
|
+
? res
|
|
436
|
+
: { result: res };
|
|
424
437
|
}
|
|
425
|
-
loggedOutput
|
|
426
|
-
typeof res === "object"
|
|
427
|
-
? res
|
|
428
|
-
: { result: res };
|
|
438
|
+
return loggedOutput;
|
|
429
439
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
langsmithFriendlyError.rawJestError = rawError;
|
|
446
|
-
throw langsmithFriendlyError;
|
|
447
|
-
}
|
|
440
|
+
catch (e) {
|
|
441
|
+
(0, globals_js_1._logTestFeedback)({
|
|
442
|
+
exampleId,
|
|
443
|
+
feedback: { key: "pass", score: false },
|
|
444
|
+
context: testContext,
|
|
445
|
+
runTree: testContext.testRootRunTree,
|
|
446
|
+
client: testContext.client,
|
|
447
|
+
});
|
|
448
|
+
const rawError = e;
|
|
449
|
+
const strippedErrorMessage = e.message.replace(constants_js_1.STRIP_ANSI_REGEX, "");
|
|
450
|
+
const langsmithFriendlyError = new Error(strippedErrorMessage);
|
|
451
|
+
langsmithFriendlyError.rawJestError = rawError;
|
|
452
|
+
throw langsmithFriendlyError;
|
|
453
|
+
}
|
|
454
|
+
});
|
|
448
455
|
};
|
|
449
456
|
try {
|
|
450
457
|
if ((0, globals_js_1.trackingEnabled)(context)) {
|
|
@@ -32,7 +32,7 @@ export function logFeedback(feedback, config) {
|
|
|
32
32
|
exampleId: context.currentExample.id,
|
|
33
33
|
feedback: feedback,
|
|
34
34
|
context,
|
|
35
|
-
runTree:
|
|
35
|
+
runTree: context.testRootRunTree,
|
|
36
36
|
client: context.client,
|
|
37
37
|
});
|
|
38
38
|
}
|
|
@@ -352,52 +352,59 @@ export function generateWrapperFromJestlikeMethods(methods, testRunnerName) {
|
|
|
352
352
|
};
|
|
353
353
|
let exampleId;
|
|
354
354
|
const runTestFn = async () => {
|
|
355
|
-
|
|
355
|
+
let testContext = testWrapperAsyncLocalStorageInstance.getStore();
|
|
356
356
|
if (testContext === undefined) {
|
|
357
357
|
throw new Error("Could not identify test context. Please contact us for help.");
|
|
358
358
|
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
359
|
+
return testWrapperAsyncLocalStorageInstance.run({
|
|
360
|
+
...testContext,
|
|
361
|
+
testRootRunTree: trackingEnabled(testContext)
|
|
362
|
+
? getCurrentRunTree()
|
|
363
|
+
: undefined,
|
|
364
|
+
}, async () => {
|
|
365
|
+
testContext = testWrapperAsyncLocalStorageInstance.getStore();
|
|
366
|
+
if (testContext === undefined) {
|
|
367
|
+
throw new Error("Could not identify test context after setting test root run tree. Please contact us for help.");
|
|
368
|
+
}
|
|
369
|
+
try {
|
|
370
|
+
const res = await testFn({
|
|
371
|
+
...rest,
|
|
372
|
+
inputs: testInput,
|
|
373
|
+
referenceOutputs: testOutput,
|
|
374
|
+
});
|
|
375
|
+
_logTestFeedback({
|
|
376
|
+
exampleId,
|
|
377
|
+
feedback: { key: "pass", score: true },
|
|
378
|
+
context: testContext,
|
|
379
|
+
runTree: testContext.testRootRunTree,
|
|
380
|
+
client: testContext.client,
|
|
381
|
+
});
|
|
382
|
+
if (res != null) {
|
|
383
|
+
if (loggedOutput !== undefined) {
|
|
384
|
+
console.warn(`[WARN]: Returned value from test function will override output set by previous "logOutputs()" call.`);
|
|
385
|
+
}
|
|
386
|
+
loggedOutput =
|
|
387
|
+
typeof res === "object"
|
|
388
|
+
? res
|
|
389
|
+
: { result: res };
|
|
377
390
|
}
|
|
378
|
-
loggedOutput
|
|
379
|
-
typeof res === "object"
|
|
380
|
-
? res
|
|
381
|
-
: { result: res };
|
|
391
|
+
return loggedOutput;
|
|
382
392
|
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
langsmithFriendlyError.rawJestError = rawError;
|
|
399
|
-
throw langsmithFriendlyError;
|
|
400
|
-
}
|
|
393
|
+
catch (e) {
|
|
394
|
+
_logTestFeedback({
|
|
395
|
+
exampleId,
|
|
396
|
+
feedback: { key: "pass", score: false },
|
|
397
|
+
context: testContext,
|
|
398
|
+
runTree: testContext.testRootRunTree,
|
|
399
|
+
client: testContext.client,
|
|
400
|
+
});
|
|
401
|
+
const rawError = e;
|
|
402
|
+
const strippedErrorMessage = e.message.replace(STRIP_ANSI_REGEX, "");
|
|
403
|
+
const langsmithFriendlyError = new Error(strippedErrorMessage);
|
|
404
|
+
langsmithFriendlyError.rawJestError = rawError;
|
|
405
|
+
throw langsmithFriendlyError;
|
|
406
|
+
}
|
|
407
|
+
});
|
|
401
408
|
};
|
|
402
409
|
try {
|
|
403
410
|
if (trackingEnabled(context)) {
|