langsmith 0.3.13 → 0.3.15
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/anonymizer/index.cjs +1 -2
- package/dist/client.cjs +49 -19
- package/dist/client.d.ts +2 -0
- package/dist/client.js +30 -10
- package/dist/evaluation/_random_name.cjs +1 -2
- package/dist/evaluation/_runner.cjs +2 -2
- package/dist/evaluation/evaluate_comparative.cjs +1 -2
- package/dist/evaluation/evaluator.cjs +2 -2
- package/dist/evaluation/langchain.cjs +1 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/jest/index.d.ts +45 -46
- package/dist/langchain.cjs +2 -2
- package/dist/run_trees.cjs +21 -11
- package/dist/singletons/traceable.cjs +3 -3
- package/dist/traceable.cjs +2 -3
- package/dist/traceable.js +0 -1
- package/dist/utils/_uuid.cjs +18 -9
- package/dist/utils/asserts.cjs +3 -3
- package/dist/utils/asserts.d.ts +3 -3
- package/dist/utils/atee.cjs +1 -2
- package/dist/utils/env.cjs +9 -9
- package/dist/utils/error.cjs +3 -3
- package/dist/utils/fast-safe-stringify/index.cjs +1 -2
- package/dist/utils/fast-safe-stringify/index.d.ts +1 -1
- package/dist/utils/jestlike/globals.cjs +3 -3
- package/dist/utils/jestlike/globals.d.ts +0 -1
- package/dist/utils/jestlike/index.cjs +23 -13
- package/dist/utils/jestlike/index.d.ts +30 -31
- package/dist/utils/jestlike/matchers.cjs +3 -4
- package/dist/utils/jestlike/reporter.cjs +18 -9
- package/dist/utils/jestlike/vendor/chain.cjs +1 -2
- package/dist/utils/jestlike/vendor/chain.d.ts +0 -1
- package/dist/utils/jestlike/vendor/evaluatedBy.cjs +2 -3
- package/dist/utils/messages.cjs +2 -3
- package/dist/utils/prompts.cjs +2 -3
- package/dist/utils/shuffle.cjs +1 -2
- package/dist/utils/warn.cjs +1 -2
- package/dist/vercel.cjs +17 -0
- package/dist/vercel.d.ts +4 -4
- package/dist/vercel.js +17 -0
- package/dist/vitest/index.d.ts +45 -46
- package/package.json +1 -1
package/dist/utils/asserts.cjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isReadableStream = exports.isThenable = exports.isGenerator = exports.isIteratorLike = exports.isAsyncIterable =
|
|
3
|
+
exports.isReadableStream = exports.isThenable = exports.isGenerator = exports.isIteratorLike = exports.isAsyncIterable = void 0;
|
|
4
|
+
exports.isPromiseMethod = isPromiseMethod;
|
|
5
|
+
exports.isKVMap = isKVMap;
|
|
4
6
|
function isPromiseMethod(x) {
|
|
5
7
|
if (x === "then" || x === "catch" || x === "finally") {
|
|
6
8
|
return true;
|
|
7
9
|
}
|
|
8
10
|
return false;
|
|
9
11
|
}
|
|
10
|
-
exports.isPromiseMethod = isPromiseMethod;
|
|
11
12
|
function isKVMap(x) {
|
|
12
13
|
if (typeof x !== "object" || x == null) {
|
|
13
14
|
return false;
|
|
@@ -19,7 +20,6 @@ function isKVMap(x) {
|
|
|
19
20
|
!(Symbol.toStringTag in x) &&
|
|
20
21
|
!(Symbol.iterator in x));
|
|
21
22
|
}
|
|
22
|
-
exports.isKVMap = isKVMap;
|
|
23
23
|
const isAsyncIterable = (x) => x != null &&
|
|
24
24
|
typeof x === "object" &&
|
|
25
25
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
package/dist/utils/asserts.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare function isPromiseMethod(x: string | symbol): x is "then" | "catch" | "finally";
|
|
2
2
|
export declare function isKVMap(x: unknown): x is Record<string, unknown>;
|
|
3
3
|
export declare const isAsyncIterable: (x: unknown) => x is AsyncIterable<unknown>;
|
|
4
|
-
export declare const isIteratorLike: (x: unknown) => x is Iterator<unknown
|
|
5
|
-
export declare const isGenerator: (x: unknown) => x is Generator
|
|
4
|
+
export declare const isIteratorLike: (x: unknown) => x is Iterator<unknown>;
|
|
5
|
+
export declare const isGenerator: (x: unknown) => x is Generator;
|
|
6
6
|
export declare const isThenable: (x: unknown) => x is Promise<unknown>;
|
|
7
|
-
export declare const isReadableStream: (x: unknown) => x is ReadableStream
|
|
7
|
+
export declare const isReadableStream: (x: unknown) => x is ReadableStream;
|
package/dist/utils/atee.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.atee =
|
|
3
|
+
exports.atee = atee;
|
|
4
4
|
function atee(iter, length = 2) {
|
|
5
5
|
const buffers = Array.from({ length }, () => []);
|
|
6
6
|
return buffers.map(async function* makeIter(buffer) {
|
|
@@ -21,4 +21,3 @@ function atee(iter, length = 2) {
|
|
|
21
21
|
}
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
exports.atee = atee;
|
package/dist/utils/env.cjs
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getEnv = exports.isNode = exports.isDeno = exports.isJsDom = exports.isWebWorker = exports.isBrowser = void 0;
|
|
4
|
+
exports.getRuntimeEnvironment = getRuntimeEnvironment;
|
|
5
|
+
exports.getLangChainEnvVars = getLangChainEnvVars;
|
|
6
|
+
exports.getLangChainEnvVarsMetadata = getLangChainEnvVarsMetadata;
|
|
7
|
+
exports.getEnvironmentVariables = getEnvironmentVariables;
|
|
8
|
+
exports.getEnvironmentVariable = getEnvironmentVariable;
|
|
9
|
+
exports.getLangSmithEnvironmentVariable = getLangSmithEnvironmentVariable;
|
|
10
|
+
exports.setEnvironmentVariable = setEnvironmentVariable;
|
|
11
|
+
exports.getShas = getShas;
|
|
4
12
|
// Inlined from https://github.com/flexdinesh/browser-or-node
|
|
5
13
|
const index_js_1 = require("../index.cjs");
|
|
6
14
|
let globalEnv;
|
|
@@ -65,7 +73,6 @@ function getRuntimeEnvironment() {
|
|
|
65
73
|
}
|
|
66
74
|
return runtimeEnvironment;
|
|
67
75
|
}
|
|
68
|
-
exports.getRuntimeEnvironment = getRuntimeEnvironment;
|
|
69
76
|
/**
|
|
70
77
|
* Retrieves the LangChain-specific environment variables from the current runtime environment.
|
|
71
78
|
* Sensitive keys (containing the word "key", "token", or "secret") have their values redacted for security.
|
|
@@ -93,7 +100,6 @@ function getLangChainEnvVars() {
|
|
|
93
100
|
}
|
|
94
101
|
return envVars;
|
|
95
102
|
}
|
|
96
|
-
exports.getLangChainEnvVars = getLangChainEnvVars;
|
|
97
103
|
/**
|
|
98
104
|
* Retrieves the LangChain-specific metadata from the current runtime environment.
|
|
99
105
|
*
|
|
@@ -132,7 +138,6 @@ function getLangChainEnvVarsMetadata() {
|
|
|
132
138
|
}
|
|
133
139
|
return envVars;
|
|
134
140
|
}
|
|
135
|
-
exports.getLangChainEnvVarsMetadata = getLangChainEnvVarsMetadata;
|
|
136
141
|
/**
|
|
137
142
|
* Retrieves the environment variables from the current runtime environment.
|
|
138
143
|
*
|
|
@@ -163,7 +168,6 @@ function getEnvironmentVariables() {
|
|
|
163
168
|
return undefined;
|
|
164
169
|
}
|
|
165
170
|
}
|
|
166
|
-
exports.getEnvironmentVariables = getEnvironmentVariables;
|
|
167
171
|
function getEnvironmentVariable(name) {
|
|
168
172
|
// Certain Deno setups will throw an error if you try to access environment variables
|
|
169
173
|
// https://github.com/hwchase17/langchainjs/issues/1412
|
|
@@ -177,19 +181,16 @@ function getEnvironmentVariable(name) {
|
|
|
177
181
|
return undefined;
|
|
178
182
|
}
|
|
179
183
|
}
|
|
180
|
-
exports.getEnvironmentVariable = getEnvironmentVariable;
|
|
181
184
|
function getLangSmithEnvironmentVariable(name) {
|
|
182
185
|
return (getEnvironmentVariable(`LANGSMITH_${name}`) ||
|
|
183
186
|
getEnvironmentVariable(`LANGCHAIN_${name}`));
|
|
184
187
|
}
|
|
185
|
-
exports.getLangSmithEnvironmentVariable = getLangSmithEnvironmentVariable;
|
|
186
188
|
function setEnvironmentVariable(name, value) {
|
|
187
189
|
if (typeof process !== "undefined") {
|
|
188
190
|
// eslint-disable-next-line no-process-env
|
|
189
191
|
process.env[name] = value;
|
|
190
192
|
}
|
|
191
193
|
}
|
|
192
|
-
exports.setEnvironmentVariable = setEnvironmentVariable;
|
|
193
194
|
let cachedCommitSHAs;
|
|
194
195
|
/**
|
|
195
196
|
* Get the Git commit SHA from common environment variables
|
|
@@ -231,4 +232,3 @@ function getShas() {
|
|
|
231
232
|
cachedCommitSHAs = shas;
|
|
232
233
|
return shas;
|
|
233
234
|
}
|
|
234
|
-
exports.getShas = getShas;
|
package/dist/utils/error.cjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.LangSmithConflictError = void 0;
|
|
4
|
+
exports.printErrorStackTrace = printErrorStackTrace;
|
|
5
|
+
exports.raiseForStatus = raiseForStatus;
|
|
4
6
|
function getErrorStackTrace(e) {
|
|
5
7
|
if (typeof e !== "object" || e == null)
|
|
6
8
|
return undefined;
|
|
@@ -22,7 +24,6 @@ function printErrorStackTrace(e) {
|
|
|
22
24
|
return;
|
|
23
25
|
console.error(stack);
|
|
24
26
|
}
|
|
25
|
-
exports.printErrorStackTrace = printErrorStackTrace;
|
|
26
27
|
/**
|
|
27
28
|
* LangSmithConflictError
|
|
28
29
|
*
|
|
@@ -86,4 +87,3 @@ async function raiseForStatus(response, context, consume) {
|
|
|
86
87
|
}
|
|
87
88
|
throw new Error(fullMessage);
|
|
88
89
|
}
|
|
89
|
-
exports.raiseForStatus = raiseForStatus;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.serialize =
|
|
3
|
+
exports.serialize = serialize;
|
|
4
4
|
/* eslint-disable */
|
|
5
5
|
// @ts-nocheck
|
|
6
6
|
var LIMIT_REPLACE_NODE = "[...]";
|
|
@@ -60,7 +60,6 @@ function serialize(obj, replacer, spacer, options) {
|
|
|
60
60
|
return encodeString(res);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
exports.serialize = serialize;
|
|
64
63
|
function setReplace(replace, val, k, parent) {
|
|
65
64
|
var propertyDescriptor = Object.getOwnPropertyDescriptor(parent, k);
|
|
66
65
|
if (propertyDescriptor.get !== undefined) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function serialize(obj: any, replacer?: any, spacer?: any, options?: any): Uint8Array
|
|
1
|
+
export declare function serialize(obj: any, replacer?: any, spacer?: any, options?: any): Uint8Array<ArrayBufferLike>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.syncExamplePromises = exports.evaluatorLogFeedbackPromises = exports.testWrapperAsyncLocalStorageInstance = exports.DEFAULT_TEST_CLIENT = void 0;
|
|
4
|
+
exports.trackingEnabled = trackingEnabled;
|
|
5
|
+
exports._logTestFeedback = _logTestFeedback;
|
|
4
6
|
const node_async_hooks_1 = require("node:async_hooks");
|
|
5
7
|
const client_js_1 = require("../../client.cjs");
|
|
6
8
|
const env_js_1 = require("../env.cjs");
|
|
@@ -16,7 +18,6 @@ function trackingEnabled(context) {
|
|
|
16
18
|
}
|
|
17
19
|
return (0, env_js_2.isTracingEnabled)();
|
|
18
20
|
}
|
|
19
|
-
exports.trackingEnabled = trackingEnabled;
|
|
20
21
|
exports.evaluatorLogFeedbackPromises = new Set();
|
|
21
22
|
exports.syncExamplePromises = new Map();
|
|
22
23
|
function _logTestFeedback(params) {
|
|
@@ -37,4 +38,3 @@ function _logTestFeedback(params) {
|
|
|
37
38
|
}
|
|
38
39
|
context.onFeedbackLogged?.(feedback);
|
|
39
40
|
}
|
|
40
|
-
exports._logTestFeedback = _logTestFeedback;
|
|
@@ -17,13 +17,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
17
17
|
}) : function(o, v) {
|
|
18
18
|
o["default"] = v;
|
|
19
19
|
});
|
|
20
|
-
var __importStar = (this && this.__importStar) || function (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
20
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
21
|
+
var ownKeys = function(o) {
|
|
22
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
23
|
+
var ar = [];
|
|
24
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
25
|
+
return ar;
|
|
26
|
+
};
|
|
27
|
+
return ownKeys(o);
|
|
28
|
+
};
|
|
29
|
+
return function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
})();
|
|
27
37
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
28
38
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
29
39
|
};
|
|
@@ -31,7 +41,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
31
41
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
42
|
};
|
|
33
43
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
-
exports.wrapEvaluator =
|
|
44
|
+
exports.wrapEvaluator = void 0;
|
|
45
|
+
exports.logFeedback = logFeedback;
|
|
46
|
+
exports.logOutputs = logOutputs;
|
|
47
|
+
exports._objectHash = _objectHash;
|
|
48
|
+
exports.generateWrapperFromJestlikeMethods = generateWrapperFromJestlikeMethods;
|
|
49
|
+
exports.isInTestContext = isInTestContext;
|
|
35
50
|
const crypto_1 = __importDefault(require("crypto"));
|
|
36
51
|
const uuid_1 = require("uuid");
|
|
37
52
|
const os = __importStar(require("node:os"));
|
|
@@ -68,7 +83,6 @@ function logFeedback(feedback, config) {
|
|
|
68
83
|
client: context.client,
|
|
69
84
|
});
|
|
70
85
|
}
|
|
71
|
-
exports.logFeedback = logFeedback;
|
|
72
86
|
function logOutputs(output) {
|
|
73
87
|
const context = globals_js_1.testWrapperAsyncLocalStorageInstance.getStore();
|
|
74
88
|
if (context === undefined) {
|
|
@@ -83,7 +97,6 @@ function logOutputs(output) {
|
|
|
83
97
|
}
|
|
84
98
|
context.setLoggedOutput(output);
|
|
85
99
|
}
|
|
86
|
-
exports.logOutputs = logOutputs;
|
|
87
100
|
function _objectHash(obj, depth = 0) {
|
|
88
101
|
// Prevent infinite recursion
|
|
89
102
|
if (depth > 50) {
|
|
@@ -106,7 +119,6 @@ function _objectHash(obj, depth = 0) {
|
|
|
106
119
|
.update(JSON.stringify(obj ?? null))
|
|
107
120
|
.digest("hex"));
|
|
108
121
|
}
|
|
109
|
-
exports._objectHash = _objectHash;
|
|
110
122
|
function generateWrapperFromJestlikeMethods(methods, testRunnerName) {
|
|
111
123
|
const { expect, test, describe, beforeAll, afterAll } = methods;
|
|
112
124
|
async function _createProject(client, datasetId, projectConfig) {
|
|
@@ -580,12 +592,10 @@ function generateWrapperFromJestlikeMethods(methods, testRunnerName) {
|
|
|
580
592
|
toBeSemanticCloseTo: matchers_js_1.toBeSemanticCloseTo,
|
|
581
593
|
};
|
|
582
594
|
}
|
|
583
|
-
exports.generateWrapperFromJestlikeMethods = generateWrapperFromJestlikeMethods;
|
|
584
595
|
function isInTestContext() {
|
|
585
596
|
const context = globals_js_1.testWrapperAsyncLocalStorageInstance.getStore();
|
|
586
597
|
return context !== undefined;
|
|
587
598
|
}
|
|
588
|
-
exports.isInTestContext = isInTestContext;
|
|
589
599
|
var evaluatedBy_js_1 = require("./vendor/evaluatedBy.cjs");
|
|
590
600
|
Object.defineProperty(exports, "wrapEvaluator", { enumerable: true, get: function () { return evaluatedBy_js_1.wrapEvaluator; } });
|
|
591
601
|
__exportStar(require("./types.cjs"), exports);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="jest" />
|
|
2
1
|
import { KVMap } from "../../schemas.js";
|
|
3
2
|
import { toBeRelativeCloseTo, toBeAbsoluteCloseTo, toBeSemanticCloseTo } from "./matchers.js";
|
|
4
3
|
import { SimpleEvaluationResult } from "./types.js";
|
|
@@ -17,32 +16,32 @@ export declare function generateWrapperFromJestlikeMethods(methods: Record<strin
|
|
|
17
16
|
inputs: I;
|
|
18
17
|
referenceOutputs?: O;
|
|
19
18
|
} & Record<string, any>) => unknown | Promise<unknown>, timeout?: number) => void) & {
|
|
20
|
-
each: <
|
|
21
|
-
inputs:
|
|
22
|
-
referenceOutputs?:
|
|
19
|
+
each: <I extends KVMap, O extends KVMap>(table: ({
|
|
20
|
+
inputs: I;
|
|
21
|
+
referenceOutputs?: O;
|
|
23
22
|
} & Record<string, any>)[], config?: LangSmithJestlikeWrapperConfig) => (name: string, fn: (params: {
|
|
24
|
-
inputs:
|
|
25
|
-
referenceOutputs?:
|
|
23
|
+
inputs: I;
|
|
24
|
+
referenceOutputs?: O;
|
|
26
25
|
} & Record<string, any>) => unknown | Promise<unknown>, timeout?: number) => void;
|
|
27
26
|
};
|
|
28
27
|
skip: (<I extends Record<string, any> = Record<string, any>, O extends Record<string, any> = Record<string, any>>(name: string, lsParams: LangSmithJestlikeWrapperParams<I, O>, testFn: (data: {
|
|
29
28
|
inputs: I;
|
|
30
29
|
referenceOutputs?: O;
|
|
31
30
|
} & Record<string, any>) => unknown | Promise<unknown>, timeout?: number) => void) & {
|
|
32
|
-
each: <
|
|
33
|
-
inputs:
|
|
34
|
-
referenceOutputs?:
|
|
31
|
+
each: <I extends KVMap, O extends KVMap>(table: ({
|
|
32
|
+
inputs: I;
|
|
33
|
+
referenceOutputs?: O;
|
|
35
34
|
} & Record<string, any>)[], config?: LangSmithJestlikeWrapperConfig) => (name: string, fn: (params: {
|
|
36
|
-
inputs:
|
|
37
|
-
referenceOutputs?:
|
|
35
|
+
inputs: I;
|
|
36
|
+
referenceOutputs?: O;
|
|
38
37
|
} & Record<string, any>) => unknown | Promise<unknown>, timeout?: number) => void;
|
|
39
38
|
};
|
|
40
|
-
each: <
|
|
41
|
-
inputs:
|
|
42
|
-
referenceOutputs?:
|
|
39
|
+
each: <I extends KVMap, O extends KVMap>(table: ({
|
|
40
|
+
inputs: I;
|
|
41
|
+
referenceOutputs?: O;
|
|
43
42
|
} & Record<string, any>)[], config?: LangSmithJestlikeWrapperConfig) => (name: string, fn: (params: {
|
|
44
|
-
inputs:
|
|
45
|
-
referenceOutputs?:
|
|
43
|
+
inputs: I;
|
|
44
|
+
referenceOutputs?: O;
|
|
46
45
|
} & Record<string, any>) => unknown | Promise<unknown>, timeout?: number) => void;
|
|
47
46
|
};
|
|
48
47
|
it: (<I extends Record<string, any> = Record<string, any>, O extends Record<string, any> = Record<string, any>>(name: string, lsParams: LangSmithJestlikeWrapperParams<I, O>, testFn: (data: {
|
|
@@ -53,32 +52,32 @@ export declare function generateWrapperFromJestlikeMethods(methods: Record<strin
|
|
|
53
52
|
inputs: I;
|
|
54
53
|
referenceOutputs?: O;
|
|
55
54
|
} & Record<string, any>) => unknown | Promise<unknown>, timeout?: number) => void) & {
|
|
56
|
-
each: <
|
|
57
|
-
inputs:
|
|
58
|
-
referenceOutputs?:
|
|
55
|
+
each: <I extends KVMap, O extends KVMap>(table: ({
|
|
56
|
+
inputs: I;
|
|
57
|
+
referenceOutputs?: O;
|
|
59
58
|
} & Record<string, any>)[], config?: LangSmithJestlikeWrapperConfig) => (name: string, fn: (params: {
|
|
60
|
-
inputs:
|
|
61
|
-
referenceOutputs?:
|
|
59
|
+
inputs: I;
|
|
60
|
+
referenceOutputs?: O;
|
|
62
61
|
} & Record<string, any>) => unknown | Promise<unknown>, timeout?: number) => void;
|
|
63
62
|
};
|
|
64
63
|
skip: (<I extends Record<string, any> = Record<string, any>, O extends Record<string, any> = Record<string, any>>(name: string, lsParams: LangSmithJestlikeWrapperParams<I, O>, testFn: (data: {
|
|
65
64
|
inputs: I;
|
|
66
65
|
referenceOutputs?: O;
|
|
67
66
|
} & Record<string, any>) => unknown | Promise<unknown>, timeout?: number) => void) & {
|
|
68
|
-
each: <
|
|
69
|
-
inputs:
|
|
70
|
-
referenceOutputs?:
|
|
67
|
+
each: <I extends KVMap, O extends KVMap>(table: ({
|
|
68
|
+
inputs: I;
|
|
69
|
+
referenceOutputs?: O;
|
|
71
70
|
} & Record<string, any>)[], config?: LangSmithJestlikeWrapperConfig) => (name: string, fn: (params: {
|
|
72
|
-
inputs:
|
|
73
|
-
referenceOutputs?:
|
|
71
|
+
inputs: I;
|
|
72
|
+
referenceOutputs?: O;
|
|
74
73
|
} & Record<string, any>) => unknown | Promise<unknown>, timeout?: number) => void;
|
|
75
74
|
};
|
|
76
|
-
each: <
|
|
77
|
-
inputs:
|
|
78
|
-
referenceOutputs?:
|
|
75
|
+
each: <I extends KVMap, O extends KVMap>(table: ({
|
|
76
|
+
inputs: I;
|
|
77
|
+
referenceOutputs?: O;
|
|
79
78
|
} & Record<string, any>)[], config?: LangSmithJestlikeWrapperConfig) => (name: string, fn: (params: {
|
|
80
|
-
inputs:
|
|
81
|
-
referenceOutputs?:
|
|
79
|
+
inputs: I;
|
|
80
|
+
referenceOutputs?: O;
|
|
82
81
|
} & Record<string, any>) => unknown | Promise<unknown>, timeout?: number) => void;
|
|
83
82
|
};
|
|
84
83
|
describe: LangSmithJestlikeDescribeWrapper & {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.toBeRelativeCloseTo = toBeRelativeCloseTo;
|
|
4
|
+
exports.toBeAbsoluteCloseTo = toBeAbsoluteCloseTo;
|
|
5
|
+
exports.toBeSemanticCloseTo = toBeSemanticCloseTo;
|
|
4
6
|
// Levenshtein distance implementation
|
|
5
7
|
function levenshteinDistance(a, b) {
|
|
6
8
|
if (a.length === 0)
|
|
@@ -47,7 +49,6 @@ async function toBeRelativeCloseTo(received, expected, options = {}) {
|
|
|
47
49
|
: `Expected "${received}" to be relatively close to "${expected}" (threshold: ${threshold}, actual distance: ${relativeDistance})`,
|
|
48
50
|
};
|
|
49
51
|
}
|
|
50
|
-
exports.toBeRelativeCloseTo = toBeRelativeCloseTo;
|
|
51
52
|
async function toBeAbsoluteCloseTo(received, expected, options = {}) {
|
|
52
53
|
const { threshold = 3, algorithm = "levenshtein" } = options;
|
|
53
54
|
let distance;
|
|
@@ -66,7 +67,6 @@ async function toBeAbsoluteCloseTo(received, expected, options = {}) {
|
|
|
66
67
|
: `Expected "${received}" to be absolutely close to "${expected}" (threshold: ${threshold}, actual distance: ${distance})`,
|
|
67
68
|
};
|
|
68
69
|
}
|
|
69
|
-
exports.toBeAbsoluteCloseTo = toBeAbsoluteCloseTo;
|
|
70
70
|
async function toBeSemanticCloseTo(received, expected, options) {
|
|
71
71
|
const { threshold = 0.2, embeddings, algorithm = "cosine" } = options;
|
|
72
72
|
// Get embeddings for both strings
|
|
@@ -101,4 +101,3 @@ async function toBeSemanticCloseTo(received, expected, options) {
|
|
|
101
101
|
: `Expected "${received}" to be semantically close to "${expected}" (threshold: ${threshold}, similarity: ${similarity})`,
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
|
-
exports.toBeSemanticCloseTo = toBeSemanticCloseTo;
|
|
@@ -15,18 +15,28 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
28
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.printReporterTable =
|
|
39
|
+
exports.printReporterTable = printReporterTable;
|
|
30
40
|
const console_table_printer_1 = require("console-table-printer");
|
|
31
41
|
const chalk_1 = __importDefault(require("chalk"));
|
|
32
42
|
const os = __importStar(require("node:os"));
|
|
@@ -283,4 +293,3 @@ async function printReporterTable(testSuiteName, results, testStatus, failureMes
|
|
|
283
293
|
console.log();
|
|
284
294
|
}
|
|
285
295
|
}
|
|
286
|
-
exports.printReporterTable = printReporterTable;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.wrapExpect =
|
|
3
|
+
exports.wrapExpect = wrapExpect;
|
|
4
4
|
/**
|
|
5
5
|
* Adapted from https://github.com/mattphillips/jest-chain/blob/main/src/chain.js
|
|
6
6
|
*/
|
|
@@ -89,5 +89,4 @@ function wrapExpect(originalExpect) {
|
|
|
89
89
|
);
|
|
90
90
|
return expectProxy;
|
|
91
91
|
}
|
|
92
|
-
exports.wrapExpect = wrapExpect;
|
|
93
92
|
globalThis.expect = wrapExpect(globalThis.expect);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.wrapEvaluator = wrapEvaluator;
|
|
4
|
+
exports.evaluatedBy = evaluatedBy;
|
|
4
5
|
const traceable_js_1 = require("../../../traceable.cjs");
|
|
5
6
|
const globals_js_1 = require("../globals.cjs");
|
|
6
7
|
const uuid_1 = require("uuid");
|
|
@@ -65,7 +66,6 @@ function wrapEvaluator(evaluator) {
|
|
|
65
66
|
return evalResult;
|
|
66
67
|
};
|
|
67
68
|
}
|
|
68
|
-
exports.wrapEvaluator = wrapEvaluator;
|
|
69
69
|
async function evaluatedBy(outputs, evaluator) {
|
|
70
70
|
const context = globals_js_1.testWrapperAsyncLocalStorageInstance.getStore();
|
|
71
71
|
if (context === undefined || context.currentExample === undefined) {
|
|
@@ -87,4 +87,3 @@ async function evaluatedBy(outputs, evaluator) {
|
|
|
87
87
|
}
|
|
88
88
|
return evalResult.score;
|
|
89
89
|
}
|
|
90
|
-
exports.evaluatedBy = evaluatedBy;
|
package/dist/utils/messages.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isLangChainMessage = isLangChainMessage;
|
|
4
|
+
exports.convertLangChainMessageToExample = convertLangChainMessageToExample;
|
|
4
5
|
function isLangChainMessage(
|
|
5
6
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
7
|
message) {
|
|
7
8
|
return typeof message?._getType === "function";
|
|
8
9
|
}
|
|
9
|
-
exports.isLangChainMessage = isLangChainMessage;
|
|
10
10
|
function convertLangChainMessageToExample(message) {
|
|
11
11
|
const converted = {
|
|
12
12
|
type: message._getType(),
|
|
@@ -19,4 +19,3 @@ function convertLangChainMessageToExample(message) {
|
|
|
19
19
|
}
|
|
20
20
|
return converted;
|
|
21
21
|
}
|
|
22
|
-
exports.convertLangChainMessageToExample = convertLangChainMessageToExample;
|
package/dist/utils/prompts.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isVersionGreaterOrEqual = isVersionGreaterOrEqual;
|
|
4
|
+
exports.parsePromptIdentifier = parsePromptIdentifier;
|
|
4
5
|
const semver_1 = require("semver");
|
|
5
6
|
function isVersionGreaterOrEqual(current_version, target_version) {
|
|
6
7
|
const current = (0, semver_1.parse)(current_version);
|
|
@@ -10,7 +11,6 @@ function isVersionGreaterOrEqual(current_version, target_version) {
|
|
|
10
11
|
}
|
|
11
12
|
return current.compare(target) >= 0;
|
|
12
13
|
}
|
|
13
|
-
exports.isVersionGreaterOrEqual = isVersionGreaterOrEqual;
|
|
14
14
|
function parsePromptIdentifier(identifier) {
|
|
15
15
|
if (!identifier ||
|
|
16
16
|
identifier.split("/").length > 2 ||
|
|
@@ -35,4 +35,3 @@ function parsePromptIdentifier(identifier) {
|
|
|
35
35
|
return ["-", ownerNamePart, commit];
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
exports.parsePromptIdentifier = parsePromptIdentifier;
|
package/dist/utils/shuffle.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.shuffle =
|
|
3
|
+
exports.shuffle = shuffle;
|
|
4
4
|
function shuffle(array) {
|
|
5
5
|
let currentIndex = array.length;
|
|
6
6
|
while (currentIndex !== 0) {
|
|
@@ -12,4 +12,3 @@ function shuffle(array) {
|
|
|
12
12
|
}
|
|
13
13
|
return array;
|
|
14
14
|
}
|
|
15
|
-
exports.shuffle = shuffle;
|
package/dist/utils/warn.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.warnOnce =
|
|
3
|
+
exports.warnOnce = warnOnce;
|
|
4
4
|
const warnedMessages = {};
|
|
5
5
|
function warnOnce(message) {
|
|
6
6
|
if (!warnedMessages[message]) {
|
|
@@ -8,4 +8,3 @@ function warnOnce(message) {
|
|
|
8
8
|
warnedMessages[message] = true;
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
exports.warnOnce = warnOnce;
|
package/dist/vercel.cjs
CHANGED
|
@@ -421,6 +421,22 @@ class AISDKExporter {
|
|
|
421
421
|
}
|
|
422
422
|
return result;
|
|
423
423
|
})();
|
|
424
|
+
const invocationParams = (() => {
|
|
425
|
+
if ("ai.prompt.tools" in span.attributes) {
|
|
426
|
+
return {
|
|
427
|
+
tools: span.attributes["ai.prompt.tools"].flatMap((tool) => {
|
|
428
|
+
try {
|
|
429
|
+
return JSON.parse(tool);
|
|
430
|
+
}
|
|
431
|
+
catch {
|
|
432
|
+
// pass
|
|
433
|
+
}
|
|
434
|
+
return [];
|
|
435
|
+
}),
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
return {};
|
|
439
|
+
})();
|
|
424
440
|
const events = [];
|
|
425
441
|
const firstChunkEvent = span.events.find((i) => i.name === "ai.stream.firstChunk");
|
|
426
442
|
if (firstChunkEvent) {
|
|
@@ -437,6 +453,7 @@ class AISDKExporter {
|
|
|
437
453
|
outputs,
|
|
438
454
|
events,
|
|
439
455
|
extra: {
|
|
456
|
+
invocation_params: invocationParams,
|
|
440
457
|
batch_size: 1,
|
|
441
458
|
metadata: {
|
|
442
459
|
ls_provider: span.attributes["ai.model.provider"]
|
package/dist/vercel.d.ts
CHANGED
|
@@ -60,10 +60,10 @@ export declare class AISDKExporter {
|
|
|
60
60
|
metadata: {
|
|
61
61
|
[x: string]: import("@opentelemetry/api").AttributeValue;
|
|
62
62
|
};
|
|
63
|
-
recordInputs?: boolean
|
|
64
|
-
recordOutputs?: boolean
|
|
65
|
-
functionId?: string
|
|
66
|
-
tracer?: import("@opentelemetry/api").Tracer
|
|
63
|
+
recordInputs?: boolean;
|
|
64
|
+
recordOutputs?: boolean;
|
|
65
|
+
functionId?: string;
|
|
66
|
+
tracer?: import("@opentelemetry/api").Tracer;
|
|
67
67
|
};
|
|
68
68
|
export(spans: unknown[], resultCallback: (result: {
|
|
69
69
|
code: 0 | 1;
|
package/dist/vercel.js
CHANGED
|
@@ -418,6 +418,22 @@ export class AISDKExporter {
|
|
|
418
418
|
}
|
|
419
419
|
return result;
|
|
420
420
|
})();
|
|
421
|
+
const invocationParams = (() => {
|
|
422
|
+
if ("ai.prompt.tools" in span.attributes) {
|
|
423
|
+
return {
|
|
424
|
+
tools: span.attributes["ai.prompt.tools"].flatMap((tool) => {
|
|
425
|
+
try {
|
|
426
|
+
return JSON.parse(tool);
|
|
427
|
+
}
|
|
428
|
+
catch {
|
|
429
|
+
// pass
|
|
430
|
+
}
|
|
431
|
+
return [];
|
|
432
|
+
}),
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
return {};
|
|
436
|
+
})();
|
|
421
437
|
const events = [];
|
|
422
438
|
const firstChunkEvent = span.events.find((i) => i.name === "ai.stream.firstChunk");
|
|
423
439
|
if (firstChunkEvent) {
|
|
@@ -434,6 +450,7 @@ export class AISDKExporter {
|
|
|
434
450
|
outputs,
|
|
435
451
|
events,
|
|
436
452
|
extra: {
|
|
453
|
+
invocation_params: invocationParams,
|
|
437
454
|
batch_size: 1,
|
|
438
455
|
metadata: {
|
|
439
456
|
ls_provider: span.attributes["ai.model.provider"]
|