langsmith 0.0.68 → 0.0.70-rc.0
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/client.cjs +36 -1
- package/dist/client.d.ts +2 -0
- package/dist/client.js +36 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/run_trees.cjs +5 -0
- package/dist/run_trees.d.ts +2 -2
- package/dist/run_trees.js +5 -0
- package/package.json +1 -1
package/dist/client.cjs
CHANGED
|
@@ -164,7 +164,13 @@ class Client {
|
|
|
164
164
|
enumerable: true,
|
|
165
165
|
configurable: true,
|
|
166
166
|
writable: true,
|
|
167
|
-
value:
|
|
167
|
+
value: true
|
|
168
|
+
});
|
|
169
|
+
Object.defineProperty(this, "batchEndpointSupported", {
|
|
170
|
+
enumerable: true,
|
|
171
|
+
configurable: true,
|
|
172
|
+
writable: true,
|
|
173
|
+
value: void 0
|
|
168
174
|
});
|
|
169
175
|
Object.defineProperty(this, "pendingAutoBatchedRuns", {
|
|
170
176
|
enumerable: true,
|
|
@@ -418,6 +424,20 @@ class Client {
|
|
|
418
424
|
}
|
|
419
425
|
}
|
|
420
426
|
}
|
|
427
|
+
async batchEndpointIsSupported() {
|
|
428
|
+
const response = await fetch(`${this.apiUrl}/info`, {
|
|
429
|
+
method: "GET",
|
|
430
|
+
headers: { Accept: "application/json" },
|
|
431
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
432
|
+
});
|
|
433
|
+
if (!response.ok) {
|
|
434
|
+
// consume the response body to release the connection
|
|
435
|
+
// https://undici.nodejs.org/#/?id=garbage-collection
|
|
436
|
+
await response.text();
|
|
437
|
+
return false;
|
|
438
|
+
}
|
|
439
|
+
return true;
|
|
440
|
+
}
|
|
421
441
|
async createRun(run) {
|
|
422
442
|
if (!this._filterForSampling([run]).length) {
|
|
423
443
|
return;
|
|
@@ -491,6 +511,21 @@ class Client {
|
|
|
491
511
|
return;
|
|
492
512
|
}
|
|
493
513
|
preparedCreateParams = await mergeRuntimeEnvIntoRunCreates(preparedCreateParams);
|
|
514
|
+
if (this.batchEndpointSupported === undefined) {
|
|
515
|
+
this.batchEndpointSupported = await this.batchEndpointIsSupported();
|
|
516
|
+
}
|
|
517
|
+
if (!this.batchEndpointSupported) {
|
|
518
|
+
this.autoBatchTracing = false;
|
|
519
|
+
for (const preparedCreateParam of body.post) {
|
|
520
|
+
await this.createRun(preparedCreateParam);
|
|
521
|
+
}
|
|
522
|
+
for (const preparedUpdateParam of body.patch) {
|
|
523
|
+
if (preparedUpdateParam.id !== undefined) {
|
|
524
|
+
await this.updateRun(preparedUpdateParam.id, preparedUpdateParam);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
494
529
|
const headers = {
|
|
495
530
|
...this.headers,
|
|
496
531
|
"Content-Type": "application/json",
|
package/dist/client.d.ts
CHANGED
|
@@ -77,6 +77,7 @@ export declare class Client {
|
|
|
77
77
|
private tracingSampleRate?;
|
|
78
78
|
private sampledPostUuids;
|
|
79
79
|
private autoBatchTracing;
|
|
80
|
+
private batchEndpointSupported?;
|
|
80
81
|
private pendingAutoBatchedRuns;
|
|
81
82
|
private pendingAutoBatchedRunLimit;
|
|
82
83
|
private autoBatchTimeout;
|
|
@@ -103,6 +104,7 @@ export declare class Client {
|
|
|
103
104
|
private _filterForSampling;
|
|
104
105
|
private triggerAutoBatchSend;
|
|
105
106
|
private appendRunCreateToAutoBatchQueue;
|
|
107
|
+
protected batchEndpointIsSupported(): Promise<boolean>;
|
|
106
108
|
createRun(run: CreateRunParams): Promise<void>;
|
|
107
109
|
/**
|
|
108
110
|
* Batch ingest/upsert multiple runs in the Langsmith system.
|
package/dist/client.js
CHANGED
|
@@ -138,7 +138,13 @@ export class Client {
|
|
|
138
138
|
enumerable: true,
|
|
139
139
|
configurable: true,
|
|
140
140
|
writable: true,
|
|
141
|
-
value:
|
|
141
|
+
value: true
|
|
142
|
+
});
|
|
143
|
+
Object.defineProperty(this, "batchEndpointSupported", {
|
|
144
|
+
enumerable: true,
|
|
145
|
+
configurable: true,
|
|
146
|
+
writable: true,
|
|
147
|
+
value: void 0
|
|
142
148
|
});
|
|
143
149
|
Object.defineProperty(this, "pendingAutoBatchedRuns", {
|
|
144
150
|
enumerable: true,
|
|
@@ -392,6 +398,20 @@ export class Client {
|
|
|
392
398
|
}
|
|
393
399
|
}
|
|
394
400
|
}
|
|
401
|
+
async batchEndpointIsSupported() {
|
|
402
|
+
const response = await fetch(`${this.apiUrl}/info`, {
|
|
403
|
+
method: "GET",
|
|
404
|
+
headers: { Accept: "application/json" },
|
|
405
|
+
signal: AbortSignal.timeout(this.timeout_ms),
|
|
406
|
+
});
|
|
407
|
+
if (!response.ok) {
|
|
408
|
+
// consume the response body to release the connection
|
|
409
|
+
// https://undici.nodejs.org/#/?id=garbage-collection
|
|
410
|
+
await response.text();
|
|
411
|
+
return false;
|
|
412
|
+
}
|
|
413
|
+
return true;
|
|
414
|
+
}
|
|
395
415
|
async createRun(run) {
|
|
396
416
|
if (!this._filterForSampling([run]).length) {
|
|
397
417
|
return;
|
|
@@ -465,6 +485,21 @@ export class Client {
|
|
|
465
485
|
return;
|
|
466
486
|
}
|
|
467
487
|
preparedCreateParams = await mergeRuntimeEnvIntoRunCreates(preparedCreateParams);
|
|
488
|
+
if (this.batchEndpointSupported === undefined) {
|
|
489
|
+
this.batchEndpointSupported = await this.batchEndpointIsSupported();
|
|
490
|
+
}
|
|
491
|
+
if (!this.batchEndpointSupported) {
|
|
492
|
+
this.autoBatchTracing = false;
|
|
493
|
+
for (const preparedCreateParam of body.post) {
|
|
494
|
+
await this.createRun(preparedCreateParam);
|
|
495
|
+
}
|
|
496
|
+
for (const preparedUpdateParam of body.patch) {
|
|
497
|
+
if (preparedUpdateParam.id !== undefined) {
|
|
498
|
+
await this.updateRun(preparedUpdateParam.id, preparedUpdateParam);
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
468
503
|
const headers = {
|
|
469
504
|
...this.headers,
|
|
470
505
|
"Content-Type": "application/json",
|
package/dist/index.cjs
CHANGED
|
@@ -6,4 +6,4 @@ Object.defineProperty(exports, "Client", { enumerable: true, get: function () {
|
|
|
6
6
|
var run_trees_js_1 = require("./run_trees.cjs");
|
|
7
7
|
Object.defineProperty(exports, "RunTree", { enumerable: true, get: function () { return run_trees_js_1.RunTree; } });
|
|
8
8
|
// Update using yarn bump-version
|
|
9
|
-
exports.__version__ = "0.0.
|
|
9
|
+
exports.__version__ = "0.0.70-rc.0";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { Client } from "./client.js";
|
|
2
2
|
export { Dataset, Example, TracerSession, Run, Feedback } from "./schemas.js";
|
|
3
3
|
export { RunTree, RunTreeConfig } from "./run_trees.js";
|
|
4
|
-
export declare const __version__ = "0.0.
|
|
4
|
+
export declare const __version__ = "0.0.70-rc.0";
|
package/dist/index.js
CHANGED
package/dist/run_trees.cjs
CHANGED
|
@@ -176,6 +176,7 @@ class RunTree {
|
|
|
176
176
|
static getDefaultConfig() {
|
|
177
177
|
return {
|
|
178
178
|
id: uuid.v4(),
|
|
179
|
+
run_type: "chain",
|
|
179
180
|
project_name: (0, env_js_1.getEnvironmentVariable)("LANGCHAIN_PROJECT") ??
|
|
180
181
|
(0, env_js_1.getEnvironmentVariable)("LANGCHAIN_SESSION") ?? // TODO: Deprecate
|
|
181
182
|
"default",
|
|
@@ -241,6 +242,8 @@ class RunTree {
|
|
|
241
242
|
session_name: run.project_name,
|
|
242
243
|
child_runs: child_runs,
|
|
243
244
|
parent_run_id: parent_run_id,
|
|
245
|
+
trace_id: run.trace_id,
|
|
246
|
+
dotted_order: run.dotted_order,
|
|
244
247
|
};
|
|
245
248
|
return persistedRun;
|
|
246
249
|
}
|
|
@@ -263,6 +266,8 @@ class RunTree {
|
|
|
263
266
|
reference_example_id: this.reference_example_id,
|
|
264
267
|
extra: this.extra,
|
|
265
268
|
events: this.events,
|
|
269
|
+
dotted_order: this.dotted_order,
|
|
270
|
+
trace_id: this.trace_id,
|
|
266
271
|
};
|
|
267
272
|
await this.client.updateRun(this.id, runUpdate);
|
|
268
273
|
}
|
package/dist/run_trees.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Client } from "./client.js";
|
|
|
3
3
|
export declare function convertToDottedOrderFormat(epoch: number, runId: string): string;
|
|
4
4
|
export interface RunTreeConfig {
|
|
5
5
|
name: string;
|
|
6
|
-
run_type
|
|
6
|
+
run_type?: string;
|
|
7
7
|
id?: string;
|
|
8
8
|
project_name?: string;
|
|
9
9
|
parent_run?: RunTree;
|
|
@@ -21,7 +21,7 @@ export interface RunTreeConfig {
|
|
|
21
21
|
export declare class RunTree implements BaseRun {
|
|
22
22
|
id: string;
|
|
23
23
|
name: RunTreeConfig["name"];
|
|
24
|
-
run_type:
|
|
24
|
+
run_type: string;
|
|
25
25
|
project_name: string;
|
|
26
26
|
parent_run?: RunTree;
|
|
27
27
|
child_runs: RunTree[];
|
package/dist/run_trees.js
CHANGED
|
@@ -149,6 +149,7 @@ export class RunTree {
|
|
|
149
149
|
static getDefaultConfig() {
|
|
150
150
|
return {
|
|
151
151
|
id: uuid.v4(),
|
|
152
|
+
run_type: "chain",
|
|
152
153
|
project_name: getEnvironmentVariable("LANGCHAIN_PROJECT") ??
|
|
153
154
|
getEnvironmentVariable("LANGCHAIN_SESSION") ?? // TODO: Deprecate
|
|
154
155
|
"default",
|
|
@@ -214,6 +215,8 @@ export class RunTree {
|
|
|
214
215
|
session_name: run.project_name,
|
|
215
216
|
child_runs: child_runs,
|
|
216
217
|
parent_run_id: parent_run_id,
|
|
218
|
+
trace_id: run.trace_id,
|
|
219
|
+
dotted_order: run.dotted_order,
|
|
217
220
|
};
|
|
218
221
|
return persistedRun;
|
|
219
222
|
}
|
|
@@ -236,6 +239,8 @@ export class RunTree {
|
|
|
236
239
|
reference_example_id: this.reference_example_id,
|
|
237
240
|
extra: this.extra,
|
|
238
241
|
events: this.events,
|
|
242
|
+
dotted_order: this.dotted_order,
|
|
243
|
+
trace_id: this.trace_id,
|
|
239
244
|
};
|
|
240
245
|
await this.client.updateRun(this.id, runUpdate);
|
|
241
246
|
}
|