@langchain/core 0.3.59-rc.0 → 0.3.59-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.
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.awaitAllCallbacks = exports.consumeCallback = exports.getQueue = void 0;
8
8
  const p_queue_1 = __importDefault(require("p-queue"));
9
9
  const globals_js_1 = require("./async_local_storage/globals.cjs");
10
+ const tracer_js_1 = require("./tracer.cjs");
10
11
  let queue;
11
12
  /**
12
13
  * Creates a queue using the p-queue library. The queue is configured to
@@ -62,7 +63,11 @@ exports.consumeCallback = consumeCallback;
62
63
  * Waits for all promises in the queue to resolve. If the queue is
63
64
  * undefined, it immediately resolves a promise.
64
65
  */
65
- function awaitAllCallbacks() {
66
- return typeof queue !== "undefined" ? queue.onIdle() : Promise.resolve();
66
+ async function awaitAllCallbacks() {
67
+ const defaultClient = (0, tracer_js_1.getDefaultLangChainClientSingleton)();
68
+ await Promise.all([
69
+ typeof queue !== "undefined" ? queue.onIdle() : Promise.resolve(),
70
+ defaultClient.awaitPendingTraceBatches(),
71
+ ]);
67
72
  }
68
73
  exports.awaitAllCallbacks = awaitAllCallbacks;
@@ -1,6 +1,7 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  import PQueueMod from "p-queue";
3
3
  import { getGlobalAsyncLocalStorageInstance } from "./async_local_storage/globals.js";
4
+ import { getDefaultLangChainClientSingleton } from "./tracer.js";
4
5
  let queue;
5
6
  /**
6
7
  * Creates a queue using the p-queue library. The queue is configured to
@@ -54,6 +55,10 @@ export async function consumeCallback(promiseFn, wait) {
54
55
  * Waits for all promises in the queue to resolve. If the queue is
55
56
  * undefined, it immediately resolves a promise.
56
57
  */
57
- export function awaitAllCallbacks() {
58
- return typeof queue !== "undefined" ? queue.onIdle() : Promise.resolve();
58
+ export async function awaitAllCallbacks() {
59
+ const defaultClient = getDefaultLangChainClientSingleton();
60
+ await Promise.all([
61
+ typeof queue !== "undefined" ? queue.onIdle() : Promise.resolve(),
62
+ defaultClient.awaitPendingTraceBatches(),
63
+ ]);
59
64
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/core",
3
- "version": "0.3.59-rc.0",
3
+ "version": "0.3.59-rc.1",
4
4
  "description": "Core LangChain.js abstractions and schemas",
5
5
  "type": "module",
6
6
  "engines": {