langsmith 0.1.64 → 0.1.65-rc.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/run_trees.cjs +12 -1
- package/dist/run_trees.d.ts +3 -0
- package/dist/run_trees.js +11 -0
- package/dist/traceable.cjs +6 -0
- package/dist/traceable.js +7 -1
- package/package.json +1 -1
package/dist/run_trees.cjs
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.isRunnableConfigLike = exports.isRunTree = exports.RunTree = exports.convertToDottedOrderFormat = void 0;
|
|
26
|
+
exports.isRunnableConfigLike = exports.isRunTree = exports.RunTree = exports._LC_CONTEXT_VARIABLES_KEY = exports.convertToDottedOrderFormat = void 0;
|
|
27
27
|
const uuid = __importStar(require("uuid"));
|
|
28
28
|
const env_js_1 = require("./utils/env.cjs");
|
|
29
29
|
const client_js_1 = require("./client.cjs");
|
|
@@ -39,6 +39,7 @@ function convertToDottedOrderFormat(epoch, runId, executionOrder = 1) {
|
|
|
39
39
|
return (stripNonAlphanumeric(`${new Date(epoch).toISOString().slice(0, -1)}${paddedOrder}Z`) + runId);
|
|
40
40
|
}
|
|
41
41
|
exports.convertToDottedOrderFormat = convertToDottedOrderFormat;
|
|
42
|
+
exports._LC_CONTEXT_VARIABLES_KEY = Symbol.for("lc:context_variables");
|
|
42
43
|
/**
|
|
43
44
|
* Baggage header information
|
|
44
45
|
*/
|
|
@@ -220,6 +221,11 @@ class RunTree {
|
|
|
220
221
|
writable: true,
|
|
221
222
|
value: void 0
|
|
222
223
|
});
|
|
224
|
+
if (originalConfig.__shallowClone) {
|
|
225
|
+
delete originalConfig.__shallowClone;
|
|
226
|
+
Object.assign(this, originalConfig);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
223
229
|
const defaultConfig = RunTree.getDefaultConfig();
|
|
224
230
|
const { metadata, ...config } = originalConfig;
|
|
225
231
|
const client = config.client ?? RunTree.getSharedClient();
|
|
@@ -284,6 +290,11 @@ class RunTree {
|
|
|
284
290
|
execution_order: child_execution_order,
|
|
285
291
|
child_execution_order: child_execution_order,
|
|
286
292
|
});
|
|
293
|
+
if (exports._LC_CONTEXT_VARIABLES_KEY in this) {
|
|
294
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
295
|
+
child[exports._LC_CONTEXT_VARIABLES_KEY] =
|
|
296
|
+
this[exports._LC_CONTEXT_VARIABLES_KEY];
|
|
297
|
+
}
|
|
287
298
|
const LC_CHILD = Symbol.for("lc:child_config");
|
|
288
299
|
const presentConfig = config.extra?.[LC_CHILD] ??
|
|
289
300
|
this.extra[LC_CHILD];
|
package/dist/run_trees.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BaseRun, KVMap, RunCreate } from "./schemas.js";
|
|
2
2
|
import { Client } from "./client.js";
|
|
3
3
|
export declare function convertToDottedOrderFormat(epoch: number, runId: string, executionOrder?: number): string;
|
|
4
|
+
export declare const _LC_CONTEXT_VARIABLES_KEY: unique symbol;
|
|
4
5
|
export interface RunTreeConfig {
|
|
5
6
|
name: string;
|
|
6
7
|
run_type?: string;
|
|
@@ -26,6 +27,8 @@ export interface RunTreeConfig {
|
|
|
26
27
|
child_execution_order?: number;
|
|
27
28
|
trace_id?: string;
|
|
28
29
|
dotted_order?: string;
|
|
30
|
+
/** @internal */
|
|
31
|
+
__shallowClone?: boolean;
|
|
29
32
|
}
|
|
30
33
|
export interface RunnableConfigLike {
|
|
31
34
|
/**
|
package/dist/run_trees.js
CHANGED
|
@@ -12,6 +12,7 @@ export function convertToDottedOrderFormat(epoch, runId, executionOrder = 1) {
|
|
|
12
12
|
const paddedOrder = executionOrder.toFixed(0).slice(0, 3).padStart(3, "0");
|
|
13
13
|
return (stripNonAlphanumeric(`${new Date(epoch).toISOString().slice(0, -1)}${paddedOrder}Z`) + runId);
|
|
14
14
|
}
|
|
15
|
+
export const _LC_CONTEXT_VARIABLES_KEY = Symbol.for("lc:context_variables");
|
|
15
16
|
/**
|
|
16
17
|
* Baggage header information
|
|
17
18
|
*/
|
|
@@ -193,6 +194,11 @@ export class RunTree {
|
|
|
193
194
|
writable: true,
|
|
194
195
|
value: void 0
|
|
195
196
|
});
|
|
197
|
+
if (originalConfig.__shallowClone) {
|
|
198
|
+
delete originalConfig.__shallowClone;
|
|
199
|
+
Object.assign(this, originalConfig);
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
196
202
|
const defaultConfig = RunTree.getDefaultConfig();
|
|
197
203
|
const { metadata, ...config } = originalConfig;
|
|
198
204
|
const client = config.client ?? RunTree.getSharedClient();
|
|
@@ -257,6 +263,11 @@ export class RunTree {
|
|
|
257
263
|
execution_order: child_execution_order,
|
|
258
264
|
child_execution_order: child_execution_order,
|
|
259
265
|
});
|
|
266
|
+
if (_LC_CONTEXT_VARIABLES_KEY in this) {
|
|
267
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
268
|
+
child[_LC_CONTEXT_VARIABLES_KEY] =
|
|
269
|
+
this[_LC_CONTEXT_VARIABLES_KEY];
|
|
270
|
+
}
|
|
260
271
|
const LC_CHILD = Symbol.for("lc:child_config");
|
|
261
272
|
const presentConfig = config.extra?.[LC_CHILD] ??
|
|
262
273
|
this.extra[LC_CHILD];
|
package/dist/traceable.cjs
CHANGED
|
@@ -279,6 +279,12 @@ function traceable(wrappedFunc, config) {
|
|
|
279
279
|
];
|
|
280
280
|
}
|
|
281
281
|
const currentRunTree = getTracingRunTree(new run_trees_js_1.RunTree(ensuredConfig), processedArgs, config?.getInvocationParams);
|
|
282
|
+
if (prevRunFromStore !== undefined &&
|
|
283
|
+
run_trees_js_1._LC_CONTEXT_VARIABLES_KEY in prevRunFromStore) {
|
|
284
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
285
|
+
currentRunTree[run_trees_js_1._LC_CONTEXT_VARIABLES_KEY] =
|
|
286
|
+
prevRunFromStore[run_trees_js_1._LC_CONTEXT_VARIABLES_KEY];
|
|
287
|
+
}
|
|
282
288
|
return [currentRunTree, processedArgs];
|
|
283
289
|
})();
|
|
284
290
|
return asyncLocalStorage.run(currentRunTree, () => {
|
package/dist/traceable.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
-
import { RunTree, isRunTree, isRunnableConfigLike, } from "./run_trees.js";
|
|
2
|
+
import { RunTree, _LC_CONTEXT_VARIABLES_KEY, isRunTree, isRunnableConfigLike, } from "./run_trees.js";
|
|
3
3
|
import { isTracingEnabled } from "./env.js";
|
|
4
4
|
import { ROOT, AsyncLocalStorageProviderSingleton, } from "./singletons/traceable.js";
|
|
5
5
|
import { isKVMap, isReadableStream, isAsyncIterable, isIteratorLike, isThenable, isGenerator, isPromiseMethod, } from "./utils/asserts.js";
|
|
@@ -276,6 +276,12 @@ export function traceable(wrappedFunc, config) {
|
|
|
276
276
|
];
|
|
277
277
|
}
|
|
278
278
|
const currentRunTree = getTracingRunTree(new RunTree(ensuredConfig), processedArgs, config?.getInvocationParams);
|
|
279
|
+
if (prevRunFromStore !== undefined &&
|
|
280
|
+
_LC_CONTEXT_VARIABLES_KEY in prevRunFromStore) {
|
|
281
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
282
|
+
currentRunTree[_LC_CONTEXT_VARIABLES_KEY] =
|
|
283
|
+
prevRunFromStore[_LC_CONTEXT_VARIABLES_KEY];
|
|
284
|
+
}
|
|
279
285
|
return [currentRunTree, processedArgs];
|
|
280
286
|
})();
|
|
281
287
|
return asyncLocalStorage.run(currentRunTree, () => {
|