langsmith 0.1.65-rc.2 → 0.1.65
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 +11 -6
- package/dist/run_trees.d.ts +1 -2
- package/dist/run_trees.js +7 -2
- package/dist/singletons/constants.cjs +4 -0
- package/dist/singletons/constants.d.ts +1 -0
- package/dist/singletons/constants.js +1 -0
- package/dist/traceable.cjs +4 -3
- package/dist/traceable.js +2 -1
- package/package.json +1 -1
package/dist/run_trees.cjs
CHANGED
|
@@ -23,12 +23,13 @@ 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.
|
|
26
|
+
exports.isRunnableConfigLike = exports.isRunTree = exports.RunTree = 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");
|
|
30
30
|
const env_js_2 = require("./env.cjs");
|
|
31
31
|
const warn_js_1 = require("./utils/warn.cjs");
|
|
32
|
+
const constants_js_1 = require("./singletons/constants.cjs");
|
|
32
33
|
function stripNonAlphanumeric(input) {
|
|
33
34
|
return input.replace(/[-:.]/g, "");
|
|
34
35
|
}
|
|
@@ -39,7 +40,6 @@ function convertToDottedOrderFormat(epoch, runId, executionOrder = 1) {
|
|
|
39
40
|
return (stripNonAlphanumeric(`${new Date(epoch).toISOString().slice(0, -1)}${paddedOrder}Z`) + runId);
|
|
40
41
|
}
|
|
41
42
|
exports.convertToDottedOrderFormat = convertToDottedOrderFormat;
|
|
42
|
-
exports._LC_CONTEXT_VARIABLES_KEY = Symbol.for("lc:context_variables");
|
|
43
43
|
/**
|
|
44
44
|
* Baggage header information
|
|
45
45
|
*/
|
|
@@ -291,10 +291,10 @@ class RunTree {
|
|
|
291
291
|
child_execution_order: child_execution_order,
|
|
292
292
|
});
|
|
293
293
|
// Copy context vars over into the new run tree.
|
|
294
|
-
if (
|
|
294
|
+
if (constants_js_1._LC_CONTEXT_VARIABLES_KEY in this) {
|
|
295
295
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
296
|
-
child[
|
|
297
|
-
this[
|
|
296
|
+
child[constants_js_1._LC_CONTEXT_VARIABLES_KEY] =
|
|
297
|
+
this[constants_js_1._LC_CONTEXT_VARIABLES_KEY];
|
|
298
298
|
}
|
|
299
299
|
const LC_CHILD = Symbol.for("lc:child_config");
|
|
300
300
|
const presentConfig = config.extra?.[LC_CHILD] ??
|
|
@@ -327,10 +327,15 @@ class RunTree {
|
|
|
327
327
|
this.child_runs.push(child);
|
|
328
328
|
return child;
|
|
329
329
|
}
|
|
330
|
-
async end(outputs, error, endTime = Date.now()) {
|
|
330
|
+
async end(outputs, error, endTime = Date.now(), metadata) {
|
|
331
331
|
this.outputs = this.outputs ?? outputs;
|
|
332
332
|
this.error = this.error ?? error;
|
|
333
333
|
this.end_time = this.end_time ?? endTime;
|
|
334
|
+
if (metadata && Object.keys(metadata).length > 0) {
|
|
335
|
+
this.extra = this.extra
|
|
336
|
+
? { ...this.extra, metadata: { ...this.extra.metadata, ...metadata } }
|
|
337
|
+
: { metadata };
|
|
338
|
+
}
|
|
334
339
|
}
|
|
335
340
|
_convertToCreate(run, runtimeEnv, excludeChildRuns = true) {
|
|
336
341
|
const runExtra = run.extra ?? {};
|
package/dist/run_trees.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
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;
|
|
5
4
|
export interface RunTreeConfig {
|
|
6
5
|
name: string;
|
|
7
6
|
run_type?: string;
|
|
@@ -77,7 +76,7 @@ export declare class RunTree implements BaseRun {
|
|
|
77
76
|
private static getDefaultConfig;
|
|
78
77
|
private static getSharedClient;
|
|
79
78
|
createChild(config: RunTreeConfig): RunTree;
|
|
80
|
-
end(outputs?: KVMap, error?: string, endTime?: number): Promise<void>;
|
|
79
|
+
end(outputs?: KVMap, error?: string, endTime?: number, metadata?: KVMap): Promise<void>;
|
|
81
80
|
private _convertToCreate;
|
|
82
81
|
postRun(excludeChildRuns?: boolean): Promise<void>;
|
|
83
82
|
patchRun(): Promise<void>;
|
package/dist/run_trees.js
CHANGED
|
@@ -3,6 +3,7 @@ import { getEnvironmentVariable, getRuntimeEnvironment, } from "./utils/env.js";
|
|
|
3
3
|
import { Client } from "./client.js";
|
|
4
4
|
import { isTracingEnabled } from "./env.js";
|
|
5
5
|
import { warnOnce } from "./utils/warn.js";
|
|
6
|
+
import { _LC_CONTEXT_VARIABLES_KEY } from "./singletons/constants.js";
|
|
6
7
|
function stripNonAlphanumeric(input) {
|
|
7
8
|
return input.replace(/[-:.]/g, "");
|
|
8
9
|
}
|
|
@@ -12,7 +13,6 @@ export function convertToDottedOrderFormat(epoch, runId, executionOrder = 1) {
|
|
|
12
13
|
const paddedOrder = executionOrder.toFixed(0).slice(0, 3).padStart(3, "0");
|
|
13
14
|
return (stripNonAlphanumeric(`${new Date(epoch).toISOString().slice(0, -1)}${paddedOrder}Z`) + runId);
|
|
14
15
|
}
|
|
15
|
-
export const _LC_CONTEXT_VARIABLES_KEY = Symbol.for("lc:context_variables");
|
|
16
16
|
/**
|
|
17
17
|
* Baggage header information
|
|
18
18
|
*/
|
|
@@ -300,10 +300,15 @@ export class RunTree {
|
|
|
300
300
|
this.child_runs.push(child);
|
|
301
301
|
return child;
|
|
302
302
|
}
|
|
303
|
-
async end(outputs, error, endTime = Date.now()) {
|
|
303
|
+
async end(outputs, error, endTime = Date.now(), metadata) {
|
|
304
304
|
this.outputs = this.outputs ?? outputs;
|
|
305
305
|
this.error = this.error ?? error;
|
|
306
306
|
this.end_time = this.end_time ?? endTime;
|
|
307
|
+
if (metadata && Object.keys(metadata).length > 0) {
|
|
308
|
+
this.extra = this.extra
|
|
309
|
+
? { ...this.extra, metadata: { ...this.extra.metadata, ...metadata } }
|
|
310
|
+
: { metadata };
|
|
311
|
+
}
|
|
307
312
|
}
|
|
308
313
|
_convertToCreate(run, runtimeEnv, excludeChildRuns = true) {
|
|
309
314
|
const runExtra = run.extra ?? {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const _LC_CONTEXT_VARIABLES_KEY: unique symbol;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const _LC_CONTEXT_VARIABLES_KEY = Symbol.for("lc:context_variables");
|
package/dist/traceable.cjs
CHANGED
|
@@ -5,6 +5,7 @@ const node_async_hooks_1 = require("node:async_hooks");
|
|
|
5
5
|
const run_trees_js_1 = require("./run_trees.cjs");
|
|
6
6
|
const env_js_1 = require("./env.cjs");
|
|
7
7
|
const traceable_js_1 = require("./singletons/traceable.cjs");
|
|
8
|
+
const constants_js_1 = require("./singletons/constants.cjs");
|
|
8
9
|
const asserts_js_1 = require("./utils/asserts.cjs");
|
|
9
10
|
traceable_js_1.AsyncLocalStorageProviderSingleton.initializeGlobalInstance(new node_async_hooks_1.AsyncLocalStorage());
|
|
10
11
|
const handleRunInputs = (rawInputs) => {
|
|
@@ -283,10 +284,10 @@ function traceable(wrappedFunc, config) {
|
|
|
283
284
|
// it will be an object with a single property and we should copy
|
|
284
285
|
// context vars over into the new run tree.
|
|
285
286
|
if (prevRunFromStore !== undefined &&
|
|
286
|
-
|
|
287
|
+
constants_js_1._LC_CONTEXT_VARIABLES_KEY in prevRunFromStore) {
|
|
287
288
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
288
|
-
currentRunTree[
|
|
289
|
-
prevRunFromStore[
|
|
289
|
+
currentRunTree[constants_js_1._LC_CONTEXT_VARIABLES_KEY] =
|
|
290
|
+
prevRunFromStore[constants_js_1._LC_CONTEXT_VARIABLES_KEY];
|
|
290
291
|
}
|
|
291
292
|
return [currentRunTree, processedArgs];
|
|
292
293
|
})();
|
package/dist/traceable.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
-
import { RunTree,
|
|
2
|
+
import { RunTree, isRunTree, isRunnableConfigLike, } from "./run_trees.js";
|
|
3
3
|
import { isTracingEnabled } from "./env.js";
|
|
4
4
|
import { ROOT, AsyncLocalStorageProviderSingleton, } from "./singletons/traceable.js";
|
|
5
|
+
import { _LC_CONTEXT_VARIABLES_KEY } from "./singletons/constants.js";
|
|
5
6
|
import { isKVMap, isReadableStream, isAsyncIterable, isIteratorLike, isThenable, isGenerator, isPromiseMethod, } from "./utils/asserts.js";
|
|
6
7
|
AsyncLocalStorageProviderSingleton.initializeGlobalInstance(new AsyncLocalStorage());
|
|
7
8
|
const handleRunInputs = (rawInputs) => {
|