@langchain/core 0.1.33-rc.1 → 0.1.33-rc.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.
@@ -1321,33 +1321,35 @@ class RunnableLambda extends Runnable {
1321
1321
  }
1322
1322
  }
1323
1323
  }
1324
- // eslint-disable-next-line prefer-destructuring
1325
- const func = this.func;
1326
- async function* generatorWrapper() {
1327
- const output = await func(finalChunk, { ...config, config });
1328
- if (output && Runnable.isRunnable(output)) {
1329
- if (config?.recursionLimit === 0) {
1330
- throw new Error("Recursion limit reached.");
1324
+ const output = await new Promise((resolve, reject) => {
1325
+ void index_js_1.AsyncLocalStorageProviderSingleton.getInstance().run(config, async () => {
1326
+ try {
1327
+ const res = await this.func(finalChunk, {
1328
+ ...config,
1329
+ config,
1330
+ });
1331
+ resolve(res);
1331
1332
  }
1332
- const stream = await output.stream(finalChunk, (0, config_js_1.patchConfig)(config, {
1333
- callbacks: runManager?.getChild(),
1334
- recursionLimit: (config?.recursionLimit ?? config_js_1.DEFAULT_RECURSION_LIMIT) - 1,
1335
- }));
1336
- for await (const chunk of stream) {
1337
- yield chunk;
1333
+ catch (e) {
1334
+ reject(e);
1338
1335
  }
1336
+ });
1337
+ });
1338
+ if (output && Runnable.isRunnable(output)) {
1339
+ if (config?.recursionLimit === 0) {
1340
+ throw new Error("Recursion limit reached.");
1339
1341
  }
1340
- else {
1341
- yield output;
1342
+ const stream = await output.stream(finalChunk, (0, config_js_1.patchConfig)(config, {
1343
+ callbacks: runManager?.getChild(),
1344
+ recursionLimit: (config?.recursionLimit ?? config_js_1.DEFAULT_RECURSION_LIMIT) - 1,
1345
+ }));
1346
+ for await (const chunk of stream) {
1347
+ yield chunk;
1342
1348
  }
1343
1349
  }
1344
- const finalGenerator = await new Promise((resolve) => {
1345
- void index_js_1.AsyncLocalStorageProviderSingleton.getInstance().run(config, async () => {
1346
- const wrappedGenerator = generatorWrapper();
1347
- resolve(wrappedGenerator);
1348
- });
1349
- });
1350
- yield* finalGenerator;
1350
+ else {
1351
+ yield output;
1352
+ }
1351
1353
  }
1352
1354
  transform(generator, options) {
1353
1355
  return this._transformStreamWithConfig(generator, this._transform.bind(this), options ?? index_js_1.AsyncLocalStorageProviderSingleton.getInstance().getStore());
@@ -1308,33 +1308,35 @@ export class RunnableLambda extends Runnable {
1308
1308
  }
1309
1309
  }
1310
1310
  }
1311
- // eslint-disable-next-line prefer-destructuring
1312
- const func = this.func;
1313
- async function* generatorWrapper() {
1314
- const output = await func(finalChunk, { ...config, config });
1315
- if (output && Runnable.isRunnable(output)) {
1316
- if (config?.recursionLimit === 0) {
1317
- throw new Error("Recursion limit reached.");
1311
+ const output = await new Promise((resolve, reject) => {
1312
+ void AsyncLocalStorageProviderSingleton.getInstance().run(config, async () => {
1313
+ try {
1314
+ const res = await this.func(finalChunk, {
1315
+ ...config,
1316
+ config,
1317
+ });
1318
+ resolve(res);
1318
1319
  }
1319
- const stream = await output.stream(finalChunk, patchConfig(config, {
1320
- callbacks: runManager?.getChild(),
1321
- recursionLimit: (config?.recursionLimit ?? DEFAULT_RECURSION_LIMIT) - 1,
1322
- }));
1323
- for await (const chunk of stream) {
1324
- yield chunk;
1320
+ catch (e) {
1321
+ reject(e);
1325
1322
  }
1323
+ });
1324
+ });
1325
+ if (output && Runnable.isRunnable(output)) {
1326
+ if (config?.recursionLimit === 0) {
1327
+ throw new Error("Recursion limit reached.");
1326
1328
  }
1327
- else {
1328
- yield output;
1329
+ const stream = await output.stream(finalChunk, patchConfig(config, {
1330
+ callbacks: runManager?.getChild(),
1331
+ recursionLimit: (config?.recursionLimit ?? DEFAULT_RECURSION_LIMIT) - 1,
1332
+ }));
1333
+ for await (const chunk of stream) {
1334
+ yield chunk;
1329
1335
  }
1330
1336
  }
1331
- const finalGenerator = await new Promise((resolve) => {
1332
- void AsyncLocalStorageProviderSingleton.getInstance().run(config, async () => {
1333
- const wrappedGenerator = generatorWrapper();
1334
- resolve(wrappedGenerator);
1335
- });
1336
- });
1337
- yield* finalGenerator;
1337
+ else {
1338
+ yield output;
1339
+ }
1338
1340
  }
1339
1341
  transform(generator, options) {
1340
1342
  return this._transformStreamWithConfig(generator, this._transform.bind(this), options ?? AsyncLocalStorageProviderSingleton.getInstance().getStore());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/core",
3
- "version": "0.1.33-rc.1",
3
+ "version": "0.1.33-rc.2",
4
4
  "description": "Core LangChain.js abstractions and schemas",
5
5
  "type": "module",
6
6
  "engines": {