langsmith 0.4.1 → 0.4.2
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/traceable.cjs +12 -9
- package/dist/traceable.js +12 -9
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -13,4 +13,4 @@ var uuid_js_1 = require("./uuid.cjs");
|
|
|
13
13
|
Object.defineProperty(exports, "uuid7", { enumerable: true, get: function () { return uuid_js_1.uuid7; } });
|
|
14
14
|
Object.defineProperty(exports, "uuid7FromTime", { enumerable: true, get: function () { return uuid_js_1.uuid7FromTime; } });
|
|
15
15
|
// Update using yarn bump-version
|
|
16
|
-
exports.__version__ = "0.4.
|
|
16
|
+
exports.__version__ = "0.4.2";
|
package/dist/index.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ export { RunTree, type RunTreeConfig } from "./run_trees.js";
|
|
|
4
4
|
export { overrideFetchImplementation } from "./singletons/fetch.js";
|
|
5
5
|
export { getDefaultProjectName } from "./utils/project.js";
|
|
6
6
|
export { uuid7, uuid7FromTime } from "./uuid.js";
|
|
7
|
-
export declare const __version__ = "0.4.
|
|
7
|
+
export declare const __version__ = "0.4.2";
|
package/dist/index.js
CHANGED
|
@@ -4,4 +4,4 @@ export { overrideFetchImplementation } from "./singletons/fetch.js";
|
|
|
4
4
|
export { getDefaultProjectName } from "./utils/project.js";
|
|
5
5
|
export { uuid7, uuid7FromTime } from "./uuid.js";
|
|
6
6
|
// Update using yarn bump-version
|
|
7
|
-
export const __version__ = "0.4.
|
|
7
|
+
export const __version__ = "0.4.2";
|
package/dist/traceable.cjs
CHANGED
|
@@ -108,12 +108,14 @@ const _extractUsage = (runData) => {
|
|
|
108
108
|
return runData.outputs?.usage_metadata ?? usageMetadataFromMetadata;
|
|
109
109
|
};
|
|
110
110
|
async function handleEnd(params) {
|
|
111
|
-
const { runTree, on_end, postRunPromise, deferredInputs } = params;
|
|
111
|
+
const { runTree, on_end, postRunPromise, deferredInputs, skipChildPromiseDelay, } = params;
|
|
112
112
|
const onEnd = on_end;
|
|
113
113
|
if (onEnd) {
|
|
114
114
|
onEnd(runTree);
|
|
115
115
|
}
|
|
116
|
-
|
|
116
|
+
if (!skipChildPromiseDelay) {
|
|
117
|
+
await postRunPromise;
|
|
118
|
+
}
|
|
117
119
|
if (deferredInputs) {
|
|
118
120
|
await runTree?.postRun();
|
|
119
121
|
}
|
|
@@ -148,7 +150,7 @@ function isAsyncFn(fn) {
|
|
|
148
150
|
}
|
|
149
151
|
// Note: This mutates the run tree
|
|
150
152
|
async function handleRunOutputs(params) {
|
|
151
|
-
const { runTree, rawOutputs, processOutputsFn, on_end, postRunPromise, deferredInputs, } = params;
|
|
153
|
+
const { runTree, rawOutputs, processOutputsFn, on_end, postRunPromise, deferredInputs, skipChildPromiseDelay, } = params;
|
|
152
154
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
153
155
|
let outputs;
|
|
154
156
|
if ((0, asserts_js_1.isKVMap)(rawOutputs)) {
|
|
@@ -157,7 +159,8 @@ async function handleRunOutputs(params) {
|
|
|
157
159
|
else {
|
|
158
160
|
outputs = { outputs: rawOutputs };
|
|
159
161
|
}
|
|
160
|
-
const childRunEndPromises =
|
|
162
|
+
const childRunEndPromises = !skipChildPromiseDelay &&
|
|
163
|
+
(0, run_trees_js_1.isRunTree)(runTree) &&
|
|
161
164
|
constants_js_1._LC_CHILD_RUN_END_PROMISES_KEY in runTree &&
|
|
162
165
|
Array.isArray(runTree[constants_js_1._LC_CHILD_RUN_END_PROMISES_KEY])
|
|
163
166
|
? Promise.all(runTree[constants_js_1._LC_CHILD_RUN_END_PROMISES_KEY] ?? [])
|
|
@@ -609,6 +612,7 @@ function traceable(wrappedFunc, config) {
|
|
|
609
612
|
}
|
|
610
613
|
async function* wrapAsyncIteratorForTracing(iterator, snapshot) {
|
|
611
614
|
let finished = false;
|
|
615
|
+
let hasError = false;
|
|
612
616
|
const chunks = [];
|
|
613
617
|
const capturedOtelContext = otel_context.active();
|
|
614
618
|
try {
|
|
@@ -632,6 +636,7 @@ function traceable(wrappedFunc, config) {
|
|
|
632
636
|
}
|
|
633
637
|
}
|
|
634
638
|
catch (e) {
|
|
639
|
+
hasError = true;
|
|
635
640
|
await currentRunTree?.end(undefined, String(e));
|
|
636
641
|
throw e;
|
|
637
642
|
}
|
|
@@ -650,6 +655,7 @@ function traceable(wrappedFunc, config) {
|
|
|
650
655
|
on_end,
|
|
651
656
|
postRunPromise,
|
|
652
657
|
deferredInputs,
|
|
658
|
+
skipChildPromiseDelay: hasError || !finished,
|
|
653
659
|
});
|
|
654
660
|
}
|
|
655
661
|
}
|
|
@@ -764,17 +770,14 @@ function traceable(wrappedFunc, config) {
|
|
|
764
770
|
return rawOutput;
|
|
765
771
|
}
|
|
766
772
|
}, async (error) => {
|
|
767
|
-
|
|
768
|
-
constants_js_1._LC_CHILD_RUN_END_PROMISES_KEY in currentRunTree &&
|
|
769
|
-
Array.isArray(currentRunTree[constants_js_1._LC_CHILD_RUN_END_PROMISES_KEY])) {
|
|
770
|
-
await Promise.all(currentRunTree[constants_js_1._LC_CHILD_RUN_END_PROMISES_KEY] ?? []);
|
|
771
|
-
}
|
|
773
|
+
// Don't wait for child runs on error - fail fast
|
|
772
774
|
await currentRunTree?.end(undefined, String(error));
|
|
773
775
|
await handleEnd({
|
|
774
776
|
runTree: currentRunTree,
|
|
775
777
|
postRunPromise,
|
|
776
778
|
on_end,
|
|
777
779
|
deferredInputs,
|
|
780
|
+
skipChildPromiseDelay: true,
|
|
778
781
|
});
|
|
779
782
|
throw error;
|
|
780
783
|
})
|
package/dist/traceable.js
CHANGED
|
@@ -104,12 +104,14 @@ const _extractUsage = (runData) => {
|
|
|
104
104
|
return runData.outputs?.usage_metadata ?? usageMetadataFromMetadata;
|
|
105
105
|
};
|
|
106
106
|
async function handleEnd(params) {
|
|
107
|
-
const { runTree, on_end, postRunPromise, deferredInputs } = params;
|
|
107
|
+
const { runTree, on_end, postRunPromise, deferredInputs, skipChildPromiseDelay, } = params;
|
|
108
108
|
const onEnd = on_end;
|
|
109
109
|
if (onEnd) {
|
|
110
110
|
onEnd(runTree);
|
|
111
111
|
}
|
|
112
|
-
|
|
112
|
+
if (!skipChildPromiseDelay) {
|
|
113
|
+
await postRunPromise;
|
|
114
|
+
}
|
|
113
115
|
if (deferredInputs) {
|
|
114
116
|
await runTree?.postRun();
|
|
115
117
|
}
|
|
@@ -144,7 +146,7 @@ function isAsyncFn(fn) {
|
|
|
144
146
|
}
|
|
145
147
|
// Note: This mutates the run tree
|
|
146
148
|
async function handleRunOutputs(params) {
|
|
147
|
-
const { runTree, rawOutputs, processOutputsFn, on_end, postRunPromise, deferredInputs, } = params;
|
|
149
|
+
const { runTree, rawOutputs, processOutputsFn, on_end, postRunPromise, deferredInputs, skipChildPromiseDelay, } = params;
|
|
148
150
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
149
151
|
let outputs;
|
|
150
152
|
if (isKVMap(rawOutputs)) {
|
|
@@ -153,7 +155,8 @@ async function handleRunOutputs(params) {
|
|
|
153
155
|
else {
|
|
154
156
|
outputs = { outputs: rawOutputs };
|
|
155
157
|
}
|
|
156
|
-
const childRunEndPromises =
|
|
158
|
+
const childRunEndPromises = !skipChildPromiseDelay &&
|
|
159
|
+
isRunTree(runTree) &&
|
|
157
160
|
_LC_CHILD_RUN_END_PROMISES_KEY in runTree &&
|
|
158
161
|
Array.isArray(runTree[_LC_CHILD_RUN_END_PROMISES_KEY])
|
|
159
162
|
? Promise.all(runTree[_LC_CHILD_RUN_END_PROMISES_KEY] ?? [])
|
|
@@ -605,6 +608,7 @@ export function traceable(wrappedFunc, config) {
|
|
|
605
608
|
}
|
|
606
609
|
async function* wrapAsyncIteratorForTracing(iterator, snapshot) {
|
|
607
610
|
let finished = false;
|
|
611
|
+
let hasError = false;
|
|
608
612
|
const chunks = [];
|
|
609
613
|
const capturedOtelContext = otel_context.active();
|
|
610
614
|
try {
|
|
@@ -628,6 +632,7 @@ export function traceable(wrappedFunc, config) {
|
|
|
628
632
|
}
|
|
629
633
|
}
|
|
630
634
|
catch (e) {
|
|
635
|
+
hasError = true;
|
|
631
636
|
await currentRunTree?.end(undefined, String(e));
|
|
632
637
|
throw e;
|
|
633
638
|
}
|
|
@@ -646,6 +651,7 @@ export function traceable(wrappedFunc, config) {
|
|
|
646
651
|
on_end,
|
|
647
652
|
postRunPromise,
|
|
648
653
|
deferredInputs,
|
|
654
|
+
skipChildPromiseDelay: hasError || !finished,
|
|
649
655
|
});
|
|
650
656
|
}
|
|
651
657
|
}
|
|
@@ -760,17 +766,14 @@ export function traceable(wrappedFunc, config) {
|
|
|
760
766
|
return rawOutput;
|
|
761
767
|
}
|
|
762
768
|
}, async (error) => {
|
|
763
|
-
|
|
764
|
-
_LC_CHILD_RUN_END_PROMISES_KEY in currentRunTree &&
|
|
765
|
-
Array.isArray(currentRunTree[_LC_CHILD_RUN_END_PROMISES_KEY])) {
|
|
766
|
-
await Promise.all(currentRunTree[_LC_CHILD_RUN_END_PROMISES_KEY] ?? []);
|
|
767
|
-
}
|
|
769
|
+
// Don't wait for child runs on error - fail fast
|
|
768
770
|
await currentRunTree?.end(undefined, String(error));
|
|
769
771
|
await handleEnd({
|
|
770
772
|
runTree: currentRunTree,
|
|
771
773
|
postRunPromise,
|
|
772
774
|
on_end,
|
|
773
775
|
deferredInputs,
|
|
776
|
+
skipChildPromiseDelay: true,
|
|
774
777
|
});
|
|
775
778
|
throw error;
|
|
776
779
|
})
|