langsmith 0.3.64 → 0.3.65
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 +25 -3
- package/dist/client.d.ts +10 -2
- package/dist/client.js +25 -3
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/jest/index.d.ts +72 -192
- package/dist/run_trees.cjs +6 -2
- package/dist/run_trees.d.ts +1 -0
- package/dist/run_trees.js +6 -2
- package/dist/utils/error.cjs +14 -0
- package/dist/utils/error.js +14 -0
- package/dist/utils/jestlike/index.cjs +17 -3
- package/dist/utils/jestlike/index.d.ts +37 -97
- package/dist/utils/jestlike/index.js +17 -3
- package/dist/utils/jestlike/types.d.ts +13 -0
- package/dist/vitest/index.d.mts +36 -96
- package/dist/vitest/index.d.ts +36 -96
- package/dist/vitest/utils/wrapper.d.ts +36 -96
- package/package.json +1 -1
package/dist/client.cjs
CHANGED
|
@@ -228,6 +228,12 @@ class Client {
|
|
|
228
228
|
writable: true,
|
|
229
229
|
value: void 0
|
|
230
230
|
});
|
|
231
|
+
Object.defineProperty(this, "workspaceId", {
|
|
232
|
+
enumerable: true,
|
|
233
|
+
configurable: true,
|
|
234
|
+
writable: true,
|
|
235
|
+
value: void 0
|
|
236
|
+
});
|
|
231
237
|
Object.defineProperty(this, "caller", {
|
|
232
238
|
enumerable: true,
|
|
233
239
|
configurable: true,
|
|
@@ -384,6 +390,7 @@ class Client {
|
|
|
384
390
|
if (this.webUrl?.endsWith("/")) {
|
|
385
391
|
this.webUrl = this.webUrl.slice(0, -1);
|
|
386
392
|
}
|
|
393
|
+
this.workspaceId = trimQuotes(config.workspaceId ?? (0, env_js_1.getLangSmithEnvironmentVariable)("WORKSPACE_ID"));
|
|
387
394
|
this.timeout_ms = config.timeout_ms ?? 90_000;
|
|
388
395
|
this.caller = new async_caller_js_1.AsyncCaller({
|
|
389
396
|
...(config.callerOptions ?? {}),
|
|
@@ -472,6 +479,9 @@ class Client {
|
|
|
472
479
|
if (this.apiKey) {
|
|
473
480
|
headers["x-api-key"] = `${this.apiKey}`;
|
|
474
481
|
}
|
|
482
|
+
if (this.workspaceId) {
|
|
483
|
+
headers["x-tenant-id"] = this.workspaceId;
|
|
484
|
+
}
|
|
475
485
|
return headers;
|
|
476
486
|
}
|
|
477
487
|
_getPlatformEndpointPath(path) {
|
|
@@ -863,6 +873,9 @@ class Client {
|
|
|
863
873
|
if (options?.apiKey !== undefined) {
|
|
864
874
|
headers["x-api-key"] = options.apiKey;
|
|
865
875
|
}
|
|
876
|
+
if (options?.workspaceId !== undefined) {
|
|
877
|
+
headers["x-tenant-id"] = options.workspaceId;
|
|
878
|
+
}
|
|
866
879
|
const body = (0, index_js_2.serialize)(mergedRunCreateParam, `Creating run with id: ${mergedRunCreateParam.id}`);
|
|
867
880
|
await this.caller.call(async () => {
|
|
868
881
|
const res = await this._fetch(`${options?.apiUrl ?? this.apiUrl}/runs`, {
|
|
@@ -1271,6 +1284,9 @@ class Client {
|
|
|
1271
1284
|
if (options?.apiKey !== undefined) {
|
|
1272
1285
|
headers["x-api-key"] = options.apiKey;
|
|
1273
1286
|
}
|
|
1287
|
+
if (options?.workspaceId !== undefined) {
|
|
1288
|
+
headers["x-tenant-id"] = options.workspaceId;
|
|
1289
|
+
}
|
|
1274
1290
|
const body = (0, index_js_2.serialize)(run, `Serializing payload to update run with id: ${runId}`);
|
|
1275
1291
|
await this.caller.call(async () => {
|
|
1276
1292
|
const res = await this._fetch(`${options?.apiUrl ?? this.apiUrl}/runs/${runId}`, {
|
|
@@ -1597,7 +1613,7 @@ class Client {
|
|
|
1597
1613
|
const response = await this.caller.call(async () => {
|
|
1598
1614
|
const res = await this._fetch(`${this.apiUrl}/runs/stats`, {
|
|
1599
1615
|
method: "POST",
|
|
1600
|
-
headers: this.headers,
|
|
1616
|
+
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
1601
1617
|
signal: AbortSignal.timeout(this.timeout_ms),
|
|
1602
1618
|
...this.fetchOptions,
|
|
1603
1619
|
body,
|
|
@@ -1971,7 +1987,7 @@ class Client {
|
|
|
1971
1987
|
}
|
|
1972
1988
|
throw new Error("No projects found to resolve tenant.");
|
|
1973
1989
|
}
|
|
1974
|
-
async *listProjects({ projectIds, name, nameContains, referenceDatasetId, referenceDatasetName, referenceFree, metadata, } = {}) {
|
|
1990
|
+
async *listProjects({ projectIds, name, nameContains, referenceDatasetId, referenceDatasetName, datasetVersion, referenceFree, metadata, } = {}) {
|
|
1975
1991
|
const params = new URLSearchParams();
|
|
1976
1992
|
if (projectIds !== undefined) {
|
|
1977
1993
|
for (const projectId of projectIds) {
|
|
@@ -1993,6 +2009,9 @@ class Client {
|
|
|
1993
2009
|
});
|
|
1994
2010
|
params.append("reference_dataset", dataset.id);
|
|
1995
2011
|
}
|
|
2012
|
+
if (datasetVersion !== undefined) {
|
|
2013
|
+
params.append("dataset_version", datasetVersion);
|
|
2014
|
+
}
|
|
1996
2015
|
if (referenceFree !== undefined) {
|
|
1997
2016
|
params.append("reference_free", referenceFree.toString());
|
|
1998
2017
|
}
|
|
@@ -2865,7 +2884,10 @@ class Client {
|
|
|
2865
2884
|
async *listFeedback({ runIds, feedbackKeys, feedbackSourceTypes, } = {}) {
|
|
2866
2885
|
const queryParams = new URLSearchParams();
|
|
2867
2886
|
if (runIds) {
|
|
2868
|
-
|
|
2887
|
+
for (const runId of runIds) {
|
|
2888
|
+
(0, _uuid_js_1.assertUuid)(runId);
|
|
2889
|
+
queryParams.append("run", runId);
|
|
2890
|
+
}
|
|
2869
2891
|
}
|
|
2870
2892
|
if (feedbackKeys) {
|
|
2871
2893
|
for (const key of feedbackKeys) {
|
package/dist/client.d.ts
CHANGED
|
@@ -26,6 +26,10 @@ export interface ClientConfig {
|
|
|
26
26
|
* Enable debug mode for the client. If set, all sent HTTP requests will be logged.
|
|
27
27
|
*/
|
|
28
28
|
debug?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The workspace ID. Required for org-scoped API keys.
|
|
31
|
+
*/
|
|
32
|
+
workspaceId?: string;
|
|
29
33
|
/**
|
|
30
34
|
* Custom fetch implementation. Useful for testing.
|
|
31
35
|
*/
|
|
@@ -295,6 +299,7 @@ export declare class Client implements LangSmithTracingClientInterface {
|
|
|
295
299
|
private apiKey?;
|
|
296
300
|
private apiUrl;
|
|
297
301
|
private webUrl?;
|
|
302
|
+
private workspaceId?;
|
|
298
303
|
private caller;
|
|
299
304
|
private batchIngestCaller;
|
|
300
305
|
private timeout_ms;
|
|
@@ -357,6 +362,7 @@ export declare class Client implements LangSmithTracingClientInterface {
|
|
|
357
362
|
createRun(run: CreateRunParams, options?: {
|
|
358
363
|
apiKey?: string;
|
|
359
364
|
apiUrl?: string;
|
|
365
|
+
workspaceId?: string;
|
|
360
366
|
}): Promise<void>;
|
|
361
367
|
/**
|
|
362
368
|
* Batch ingest/upsert multiple runs in the Langsmith system.
|
|
@@ -388,6 +394,7 @@ export declare class Client implements LangSmithTracingClientInterface {
|
|
|
388
394
|
updateRun(runId: string, run: RunUpdate, options?: {
|
|
389
395
|
apiKey?: string;
|
|
390
396
|
apiUrl?: string;
|
|
397
|
+
workspaceId?: string;
|
|
391
398
|
}): Promise<void>;
|
|
392
399
|
readRun(runId: string, { loadChildRuns }?: {
|
|
393
400
|
loadChildRuns: boolean;
|
|
@@ -549,15 +556,16 @@ export declare class Client implements LangSmithTracingClientInterface {
|
|
|
549
556
|
datasetName?: string;
|
|
550
557
|
}): Promise<string>;
|
|
551
558
|
private _getTenantId;
|
|
552
|
-
listProjects({ projectIds, name, nameContains, referenceDatasetId, referenceDatasetName, referenceFree, metadata, }?: {
|
|
559
|
+
listProjects({ projectIds, name, nameContains, referenceDatasetId, referenceDatasetName, datasetVersion, referenceFree, metadata, }?: {
|
|
553
560
|
projectIds?: string[];
|
|
554
561
|
name?: string;
|
|
555
562
|
nameContains?: string;
|
|
556
563
|
referenceDatasetId?: string;
|
|
557
564
|
referenceDatasetName?: string;
|
|
565
|
+
datasetVersion?: string;
|
|
558
566
|
referenceFree?: boolean;
|
|
559
567
|
metadata?: RecordStringAny;
|
|
560
|
-
}): AsyncIterable<
|
|
568
|
+
}): AsyncIterable<TracerSessionResult>;
|
|
561
569
|
deleteProject({ projectId, projectName, }: {
|
|
562
570
|
projectId?: string;
|
|
563
571
|
projectName?: string;
|
package/dist/client.js
CHANGED
|
@@ -190,6 +190,12 @@ export class Client {
|
|
|
190
190
|
writable: true,
|
|
191
191
|
value: void 0
|
|
192
192
|
});
|
|
193
|
+
Object.defineProperty(this, "workspaceId", {
|
|
194
|
+
enumerable: true,
|
|
195
|
+
configurable: true,
|
|
196
|
+
writable: true,
|
|
197
|
+
value: void 0
|
|
198
|
+
});
|
|
193
199
|
Object.defineProperty(this, "caller", {
|
|
194
200
|
enumerable: true,
|
|
195
201
|
configurable: true,
|
|
@@ -346,6 +352,7 @@ export class Client {
|
|
|
346
352
|
if (this.webUrl?.endsWith("/")) {
|
|
347
353
|
this.webUrl = this.webUrl.slice(0, -1);
|
|
348
354
|
}
|
|
355
|
+
this.workspaceId = trimQuotes(config.workspaceId ?? getLangSmithEnvironmentVariable("WORKSPACE_ID"));
|
|
349
356
|
this.timeout_ms = config.timeout_ms ?? 90_000;
|
|
350
357
|
this.caller = new AsyncCaller({
|
|
351
358
|
...(config.callerOptions ?? {}),
|
|
@@ -434,6 +441,9 @@ export class Client {
|
|
|
434
441
|
if (this.apiKey) {
|
|
435
442
|
headers["x-api-key"] = `${this.apiKey}`;
|
|
436
443
|
}
|
|
444
|
+
if (this.workspaceId) {
|
|
445
|
+
headers["x-tenant-id"] = this.workspaceId;
|
|
446
|
+
}
|
|
437
447
|
return headers;
|
|
438
448
|
}
|
|
439
449
|
_getPlatformEndpointPath(path) {
|
|
@@ -825,6 +835,9 @@ export class Client {
|
|
|
825
835
|
if (options?.apiKey !== undefined) {
|
|
826
836
|
headers["x-api-key"] = options.apiKey;
|
|
827
837
|
}
|
|
838
|
+
if (options?.workspaceId !== undefined) {
|
|
839
|
+
headers["x-tenant-id"] = options.workspaceId;
|
|
840
|
+
}
|
|
828
841
|
const body = serializePayloadForTracing(mergedRunCreateParam, `Creating run with id: ${mergedRunCreateParam.id}`);
|
|
829
842
|
await this.caller.call(async () => {
|
|
830
843
|
const res = await this._fetch(`${options?.apiUrl ?? this.apiUrl}/runs`, {
|
|
@@ -1233,6 +1246,9 @@ export class Client {
|
|
|
1233
1246
|
if (options?.apiKey !== undefined) {
|
|
1234
1247
|
headers["x-api-key"] = options.apiKey;
|
|
1235
1248
|
}
|
|
1249
|
+
if (options?.workspaceId !== undefined) {
|
|
1250
|
+
headers["x-tenant-id"] = options.workspaceId;
|
|
1251
|
+
}
|
|
1236
1252
|
const body = serializePayloadForTracing(run, `Serializing payload to update run with id: ${runId}`);
|
|
1237
1253
|
await this.caller.call(async () => {
|
|
1238
1254
|
const res = await this._fetch(`${options?.apiUrl ?? this.apiUrl}/runs/${runId}`, {
|
|
@@ -1559,7 +1575,7 @@ export class Client {
|
|
|
1559
1575
|
const response = await this.caller.call(async () => {
|
|
1560
1576
|
const res = await this._fetch(`${this.apiUrl}/runs/stats`, {
|
|
1561
1577
|
method: "POST",
|
|
1562
|
-
headers: this.headers,
|
|
1578
|
+
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
1563
1579
|
signal: AbortSignal.timeout(this.timeout_ms),
|
|
1564
1580
|
...this.fetchOptions,
|
|
1565
1581
|
body,
|
|
@@ -1933,7 +1949,7 @@ export class Client {
|
|
|
1933
1949
|
}
|
|
1934
1950
|
throw new Error("No projects found to resolve tenant.");
|
|
1935
1951
|
}
|
|
1936
|
-
async *listProjects({ projectIds, name, nameContains, referenceDatasetId, referenceDatasetName, referenceFree, metadata, } = {}) {
|
|
1952
|
+
async *listProjects({ projectIds, name, nameContains, referenceDatasetId, referenceDatasetName, datasetVersion, referenceFree, metadata, } = {}) {
|
|
1937
1953
|
const params = new URLSearchParams();
|
|
1938
1954
|
if (projectIds !== undefined) {
|
|
1939
1955
|
for (const projectId of projectIds) {
|
|
@@ -1955,6 +1971,9 @@ export class Client {
|
|
|
1955
1971
|
});
|
|
1956
1972
|
params.append("reference_dataset", dataset.id);
|
|
1957
1973
|
}
|
|
1974
|
+
if (datasetVersion !== undefined) {
|
|
1975
|
+
params.append("dataset_version", datasetVersion);
|
|
1976
|
+
}
|
|
1958
1977
|
if (referenceFree !== undefined) {
|
|
1959
1978
|
params.append("reference_free", referenceFree.toString());
|
|
1960
1979
|
}
|
|
@@ -2827,7 +2846,10 @@ export class Client {
|
|
|
2827
2846
|
async *listFeedback({ runIds, feedbackKeys, feedbackSourceTypes, } = {}) {
|
|
2828
2847
|
const queryParams = new URLSearchParams();
|
|
2829
2848
|
if (runIds) {
|
|
2830
|
-
|
|
2849
|
+
for (const runId of runIds) {
|
|
2850
|
+
assertUuid(runId);
|
|
2851
|
+
queryParams.append("run", runId);
|
|
2852
|
+
}
|
|
2831
2853
|
}
|
|
2832
2854
|
if (feedbackKeys) {
|
|
2833
2855
|
for (const key of feedbackKeys) {
|
package/dist/index.cjs
CHANGED
|
@@ -10,4 +10,4 @@ Object.defineProperty(exports, "overrideFetchImplementation", { enumerable: true
|
|
|
10
10
|
var project_js_1 = require("./utils/project.cjs");
|
|
11
11
|
Object.defineProperty(exports, "getDefaultProjectName", { enumerable: true, get: function () { return project_js_1.getDefaultProjectName; } });
|
|
12
12
|
// Update using yarn bump-version
|
|
13
|
-
exports.__version__ = "0.3.
|
|
13
|
+
exports.__version__ = "0.3.65";
|
package/dist/index.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ export type { Dataset, Example, TracerSession, Run, Feedback, RetrieverOutput, }
|
|
|
3
3
|
export { RunTree, type RunTreeConfig } from "./run_trees.js";
|
|
4
4
|
export { overrideFetchImplementation } from "./singletons/fetch.js";
|
|
5
5
|
export { getDefaultProjectName } from "./utils/project.js";
|
|
6
|
-
export declare const __version__ = "0.3.
|
|
6
|
+
export declare const __version__ = "0.3.65";
|
package/dist/index.js
CHANGED
|
@@ -3,4 +3,4 @@ export { RunTree } from "./run_trees.js";
|
|
|
3
3
|
export { overrideFetchImplementation } from "./singletons/fetch.js";
|
|
4
4
|
export { getDefaultProjectName } from "./utils/project.js";
|
|
5
5
|
// Update using yarn bump-version
|
|
6
|
-
export const __version__ = "0.3.
|
|
6
|
+
export const __version__ = "0.3.65";
|