@langchain/core 0.1.48 → 0.1.49
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/runnables/base.cjs
CHANGED
|
@@ -730,28 +730,28 @@ class RunnableBinding extends Runnable {
|
|
|
730
730
|
});
|
|
731
731
|
}
|
|
732
732
|
async invoke(input, options) {
|
|
733
|
-
return this.bound.invoke(input, await this._mergeConfig(options, this.kwargs));
|
|
733
|
+
return this.bound.invoke(input, await this._mergeConfig((0, config_js_1.ensureConfig)(options), this.kwargs));
|
|
734
734
|
}
|
|
735
735
|
async batch(inputs, options, batchOptions) {
|
|
736
736
|
const mergedOptions = Array.isArray(options)
|
|
737
|
-
? await Promise.all(options.map(async (individualOption) => this._mergeConfig(individualOption, this.kwargs)))
|
|
738
|
-
: await this._mergeConfig(options, this.kwargs);
|
|
737
|
+
? await Promise.all(options.map(async (individualOption) => this._mergeConfig((0, config_js_1.ensureConfig)(individualOption), this.kwargs)))
|
|
738
|
+
: await this._mergeConfig((0, config_js_1.ensureConfig)(options), this.kwargs);
|
|
739
739
|
return this.bound.batch(inputs, mergedOptions, batchOptions);
|
|
740
740
|
}
|
|
741
741
|
async *_streamIterator(input, options) {
|
|
742
|
-
yield* this.bound._streamIterator(input, await this._mergeConfig(options, this.kwargs));
|
|
742
|
+
yield* this.bound._streamIterator(input, await this._mergeConfig((0, config_js_1.ensureConfig)(options), this.kwargs));
|
|
743
743
|
}
|
|
744
744
|
async stream(input, options) {
|
|
745
|
-
return this.bound.stream(input, await this._mergeConfig(options, this.kwargs));
|
|
745
|
+
return this.bound.stream(input, await this._mergeConfig((0, config_js_1.ensureConfig)(options), this.kwargs));
|
|
746
746
|
}
|
|
747
747
|
async *transform(
|
|
748
748
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
749
749
|
generator, options) {
|
|
750
|
-
yield* this.bound.transform(generator, await this._mergeConfig(options, this.kwargs));
|
|
750
|
+
yield* this.bound.transform(generator, await this._mergeConfig((0, config_js_1.ensureConfig)(options), this.kwargs));
|
|
751
751
|
}
|
|
752
752
|
async *streamEvents(input, options, streamOptions) {
|
|
753
753
|
yield* this.bound.streamEvents(input, {
|
|
754
|
-
...(await this._mergeConfig(options, this.kwargs)),
|
|
754
|
+
...(await this._mergeConfig((0, config_js_1.ensureConfig)(options), this.kwargs)),
|
|
755
755
|
version: options.version,
|
|
756
756
|
}, streamOptions);
|
|
757
757
|
}
|
package/dist/runnables/base.js
CHANGED
|
@@ -722,28 +722,28 @@ export class RunnableBinding extends Runnable {
|
|
|
722
722
|
});
|
|
723
723
|
}
|
|
724
724
|
async invoke(input, options) {
|
|
725
|
-
return this.bound.invoke(input, await this._mergeConfig(options, this.kwargs));
|
|
725
|
+
return this.bound.invoke(input, await this._mergeConfig(ensureConfig(options), this.kwargs));
|
|
726
726
|
}
|
|
727
727
|
async batch(inputs, options, batchOptions) {
|
|
728
728
|
const mergedOptions = Array.isArray(options)
|
|
729
|
-
? await Promise.all(options.map(async (individualOption) => this._mergeConfig(individualOption, this.kwargs)))
|
|
730
|
-
: await this._mergeConfig(options, this.kwargs);
|
|
729
|
+
? await Promise.all(options.map(async (individualOption) => this._mergeConfig(ensureConfig(individualOption), this.kwargs)))
|
|
730
|
+
: await this._mergeConfig(ensureConfig(options), this.kwargs);
|
|
731
731
|
return this.bound.batch(inputs, mergedOptions, batchOptions);
|
|
732
732
|
}
|
|
733
733
|
async *_streamIterator(input, options) {
|
|
734
|
-
yield* this.bound._streamIterator(input, await this._mergeConfig(options, this.kwargs));
|
|
734
|
+
yield* this.bound._streamIterator(input, await this._mergeConfig(ensureConfig(options), this.kwargs));
|
|
735
735
|
}
|
|
736
736
|
async stream(input, options) {
|
|
737
|
-
return this.bound.stream(input, await this._mergeConfig(options, this.kwargs));
|
|
737
|
+
return this.bound.stream(input, await this._mergeConfig(ensureConfig(options), this.kwargs));
|
|
738
738
|
}
|
|
739
739
|
async *transform(
|
|
740
740
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
741
741
|
generator, options) {
|
|
742
|
-
yield* this.bound.transform(generator, await this._mergeConfig(options, this.kwargs));
|
|
742
|
+
yield* this.bound.transform(generator, await this._mergeConfig(ensureConfig(options), this.kwargs));
|
|
743
743
|
}
|
|
744
744
|
async *streamEvents(input, options, streamOptions) {
|
|
745
745
|
yield* this.bound.streamEvents(input, {
|
|
746
|
-
...(await this._mergeConfig(options, this.kwargs)),
|
|
746
|
+
...(await this._mergeConfig(ensureConfig(options), this.kwargs)),
|
|
747
747
|
version: options.version,
|
|
748
748
|
}, streamOptions);
|
|
749
749
|
}
|
|
@@ -9,15 +9,17 @@ async function getCallbackManagerForConfig(config) {
|
|
|
9
9
|
}
|
|
10
10
|
exports.getCallbackManagerForConfig = getCallbackManagerForConfig;
|
|
11
11
|
function mergeConfigs(...configs) {
|
|
12
|
-
//
|
|
13
|
-
|
|
12
|
+
// We do not want to call ensureConfig on the empty state here as this may cause
|
|
13
|
+
// double loading of callbacks if async local storage is being used.
|
|
14
|
+
const copy = {};
|
|
14
15
|
for (const options of configs.filter((c) => !!c)) {
|
|
15
16
|
for (const key of Object.keys(options)) {
|
|
16
17
|
if (key === "metadata") {
|
|
17
18
|
copy[key] = { ...copy[key], ...options[key] };
|
|
18
19
|
}
|
|
19
20
|
else if (key === "tags") {
|
|
20
|
-
|
|
21
|
+
const baseKeys = copy[key] ?? [];
|
|
22
|
+
copy[key] = [...new Set(baseKeys.concat(options[key] ?? []))];
|
|
21
23
|
}
|
|
22
24
|
else if (key === "configurable") {
|
|
23
25
|
copy[key] = { ...copy[key], ...options[key] };
|
package/dist/runnables/config.js
CHANGED
|
@@ -5,15 +5,17 @@ export async function getCallbackManagerForConfig(config) {
|
|
|
5
5
|
return CallbackManager.configure(config?.callbacks, undefined, config?.tags, undefined, config?.metadata);
|
|
6
6
|
}
|
|
7
7
|
export function mergeConfigs(...configs) {
|
|
8
|
-
//
|
|
9
|
-
|
|
8
|
+
// We do not want to call ensureConfig on the empty state here as this may cause
|
|
9
|
+
// double loading of callbacks if async local storage is being used.
|
|
10
|
+
const copy = {};
|
|
10
11
|
for (const options of configs.filter((c) => !!c)) {
|
|
11
12
|
for (const key of Object.keys(options)) {
|
|
12
13
|
if (key === "metadata") {
|
|
13
14
|
copy[key] = { ...copy[key], ...options[key] };
|
|
14
15
|
}
|
|
15
16
|
else if (key === "tags") {
|
|
16
|
-
|
|
17
|
+
const baseKeys = copy[key] ?? [];
|
|
18
|
+
copy[key] = [...new Set(baseKeys.concat(options[key] ?? []))];
|
|
17
19
|
}
|
|
18
20
|
else if (key === "configurable") {
|
|
19
21
|
copy[key] = { ...copy[key], ...options[key] };
|