@langchain/core 0.3.59-rc.0 → 0.3.59-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.
|
@@ -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
|
-
|
|
66
|
+
async function awaitAllCallbacks() {
|
|
67
|
+
const defaultClient = (0, tracer_js_1.getDefaultLangChainClientSingleton)();
|
|
68
|
+
await Promise.allSettled([
|
|
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
|
-
|
|
58
|
+
export async function awaitAllCallbacks() {
|
|
59
|
+
const defaultClient = getDefaultLangChainClientSingleton();
|
|
60
|
+
await Promise.allSettled([
|
|
61
|
+
typeof queue !== "undefined" ? queue.onIdle() : Promise.resolve(),
|
|
62
|
+
defaultClient.awaitPendingTraceBatches(),
|
|
63
|
+
]);
|
|
59
64
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LangChainTracer = void 0;
|
|
4
|
+
const langsmith_1 = require("langsmith");
|
|
4
5
|
const run_trees_1 = require("langsmith/run_trees");
|
|
5
6
|
const traceable_1 = require("langsmith/singletons/traceable");
|
|
6
|
-
const env_js_1 = require("../utils/env.cjs");
|
|
7
7
|
const base_js_1 = require("./base.cjs");
|
|
8
8
|
const tracer_js_1 = require("../singletons/tracer.cjs");
|
|
9
9
|
class LangChainTracer extends base_js_1.BaseTracer {
|
|
@@ -46,10 +46,7 @@ class LangChainTracer extends base_js_1.BaseTracer {
|
|
|
46
46
|
value: true
|
|
47
47
|
});
|
|
48
48
|
const { exampleId, projectName, client, replicas } = fields;
|
|
49
|
-
this.projectName =
|
|
50
|
-
projectName ??
|
|
51
|
-
(0, env_js_1.getEnvironmentVariable)("LANGCHAIN_PROJECT") ??
|
|
52
|
-
(0, env_js_1.getEnvironmentVariable)("LANGCHAIN_SESSION");
|
|
49
|
+
this.projectName = projectName ?? (0, langsmith_1.getDefaultProjectName)();
|
|
53
50
|
this.replicas = replicas;
|
|
54
51
|
this.exampleId = exampleId;
|
|
55
52
|
this.client = client ?? (0, tracer_js_1.getDefaultLangChainClientSingleton)();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type LangSmithTracingClientInterface } from "langsmith";
|
|
2
2
|
import { RunTree } from "langsmith/run_trees";
|
|
3
3
|
import { BaseRun, RunCreate, RunUpdate as BaseRunUpdate, KVMap } from "langsmith/schemas";
|
|
4
4
|
import { BaseTracer } from "./base.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { getDefaultProjectName, } from "langsmith";
|
|
1
2
|
import { RunTree } from "langsmith/run_trees";
|
|
2
3
|
import { getCurrentRunTree } from "langsmith/singletons/traceable";
|
|
3
|
-
import { getEnvironmentVariable } from "../utils/env.js";
|
|
4
4
|
import { BaseTracer } from "./base.js";
|
|
5
5
|
import { getDefaultLangChainClientSingleton } from "../singletons/tracer.js";
|
|
6
6
|
export class LangChainTracer extends BaseTracer {
|
|
@@ -43,10 +43,7 @@ export class LangChainTracer extends BaseTracer {
|
|
|
43
43
|
value: true
|
|
44
44
|
});
|
|
45
45
|
const { exampleId, projectName, client, replicas } = fields;
|
|
46
|
-
this.projectName =
|
|
47
|
-
projectName ??
|
|
48
|
-
getEnvironmentVariable("LANGCHAIN_PROJECT") ??
|
|
49
|
-
getEnvironmentVariable("LANGCHAIN_SESSION");
|
|
46
|
+
this.projectName = projectName ?? getDefaultProjectName();
|
|
50
47
|
this.replicas = replicas;
|
|
51
48
|
this.exampleId = exampleId;
|
|
52
49
|
this.client = client ?? getDefaultLangChainClientSingleton();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@langchain/core",
|
|
3
|
-
"version": "0.3.59-rc.
|
|
3
|
+
"version": "0.3.59-rc.2",
|
|
4
4
|
"description": "Core LangChain.js abstractions and schemas",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"camelcase": "6",
|
|
39
39
|
"decamelize": "1.2.0",
|
|
40
40
|
"js-tiktoken": "^1.0.12",
|
|
41
|
-
"langsmith": "^0.3.
|
|
41
|
+
"langsmith": "^0.3.33",
|
|
42
42
|
"mustache": "^4.2.0",
|
|
43
43
|
"p-queue": "^6.6.2",
|
|
44
44
|
"p-retry": "4",
|