langsmith 0.3.63 → 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 +29 -5
- package/dist/client.d.ts +10 -2
- package/dist/client.js +30 -6
- 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 +8 -4
- package/dist/run_trees.d.ts +1 -0
- package/dist/run_trees.js +8 -4
- package/dist/traceable.cjs +4 -1
- package/dist/traceable.js +4 -1
- package/dist/utils/env.cjs +5 -1
- package/dist/utils/env.js +5 -1
- 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/dist/wrappers/openai.cjs +11 -6
- package/dist/wrappers/openai.d.ts +1 -1
- package/dist/wrappers/openai.js +11 -6
- 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`, {
|
|
@@ -1193,8 +1206,10 @@ class Client {
|
|
|
1193
1206
|
try {
|
|
1194
1207
|
let res;
|
|
1195
1208
|
let streamedAttempt = false;
|
|
1196
|
-
// attempt stream only if not disabled and not using node-fetch
|
|
1197
|
-
if (!isNodeFetch &&
|
|
1209
|
+
// attempt stream only if not disabled and not using node-fetch or Bun
|
|
1210
|
+
if (!isNodeFetch &&
|
|
1211
|
+
!this.multipartStreamingDisabled &&
|
|
1212
|
+
(0, env_js_1.getEnv)() !== "bun") {
|
|
1198
1213
|
streamedAttempt = true;
|
|
1199
1214
|
res = await sendWithRetry(buildStream);
|
|
1200
1215
|
}
|
|
@@ -1269,6 +1284,9 @@ class Client {
|
|
|
1269
1284
|
if (options?.apiKey !== undefined) {
|
|
1270
1285
|
headers["x-api-key"] = options.apiKey;
|
|
1271
1286
|
}
|
|
1287
|
+
if (options?.workspaceId !== undefined) {
|
|
1288
|
+
headers["x-tenant-id"] = options.workspaceId;
|
|
1289
|
+
}
|
|
1272
1290
|
const body = (0, index_js_2.serialize)(run, `Serializing payload to update run with id: ${runId}`);
|
|
1273
1291
|
await this.caller.call(async () => {
|
|
1274
1292
|
const res = await this._fetch(`${options?.apiUrl ?? this.apiUrl}/runs/${runId}`, {
|
|
@@ -1595,7 +1613,7 @@ class Client {
|
|
|
1595
1613
|
const response = await this.caller.call(async () => {
|
|
1596
1614
|
const res = await this._fetch(`${this.apiUrl}/runs/stats`, {
|
|
1597
1615
|
method: "POST",
|
|
1598
|
-
headers: this.headers,
|
|
1616
|
+
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
1599
1617
|
signal: AbortSignal.timeout(this.timeout_ms),
|
|
1600
1618
|
...this.fetchOptions,
|
|
1601
1619
|
body,
|
|
@@ -1969,7 +1987,7 @@ class Client {
|
|
|
1969
1987
|
}
|
|
1970
1988
|
throw new Error("No projects found to resolve tenant.");
|
|
1971
1989
|
}
|
|
1972
|
-
async *listProjects({ projectIds, name, nameContains, referenceDatasetId, referenceDatasetName, referenceFree, metadata, } = {}) {
|
|
1990
|
+
async *listProjects({ projectIds, name, nameContains, referenceDatasetId, referenceDatasetName, datasetVersion, referenceFree, metadata, } = {}) {
|
|
1973
1991
|
const params = new URLSearchParams();
|
|
1974
1992
|
if (projectIds !== undefined) {
|
|
1975
1993
|
for (const projectId of projectIds) {
|
|
@@ -1991,6 +2009,9 @@ class Client {
|
|
|
1991
2009
|
});
|
|
1992
2010
|
params.append("reference_dataset", dataset.id);
|
|
1993
2011
|
}
|
|
2012
|
+
if (datasetVersion !== undefined) {
|
|
2013
|
+
params.append("dataset_version", datasetVersion);
|
|
2014
|
+
}
|
|
1994
2015
|
if (referenceFree !== undefined) {
|
|
1995
2016
|
params.append("reference_free", referenceFree.toString());
|
|
1996
2017
|
}
|
|
@@ -2863,7 +2884,10 @@ class Client {
|
|
|
2863
2884
|
async *listFeedback({ runIds, feedbackKeys, feedbackSourceTypes, } = {}) {
|
|
2864
2885
|
const queryParams = new URLSearchParams();
|
|
2865
2886
|
if (runIds) {
|
|
2866
|
-
|
|
2887
|
+
for (const runId of runIds) {
|
|
2888
|
+
(0, _uuid_js_1.assertUuid)(runId);
|
|
2889
|
+
queryParams.append("run", runId);
|
|
2890
|
+
}
|
|
2867
2891
|
}
|
|
2868
2892
|
if (feedbackKeys) {
|
|
2869
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
|
@@ -3,7 +3,7 @@ import { LangSmithToOTELTranslator, } from "./experimental/otel/translator.js";
|
|
|
3
3
|
import { getDefaultOTLPTracerComponents, getOTELTrace, getOTELContext, } from "./singletons/otel.js";
|
|
4
4
|
import { AsyncCaller } from "./utils/async_caller.js";
|
|
5
5
|
import { convertLangChainMessageToExample, isLangChainMessage, } from "./utils/messages.js";
|
|
6
|
-
import { getEnvironmentVariable, getLangChainEnvVarsMetadata, getLangSmithEnvironmentVariable, getRuntimeEnvironment, getOtelEnabled, } from "./utils/env.js";
|
|
6
|
+
import { getEnvironmentVariable, getLangChainEnvVarsMetadata, getLangSmithEnvironmentVariable, getRuntimeEnvironment, getOtelEnabled, getEnv, } from "./utils/env.js";
|
|
7
7
|
import { __version__ } from "./index.js";
|
|
8
8
|
import { assertUuid } from "./utils/_uuid.js";
|
|
9
9
|
import { warnOnce } from "./utils/warn.js";
|
|
@@ -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`, {
|
|
@@ -1155,8 +1168,10 @@ export class Client {
|
|
|
1155
1168
|
try {
|
|
1156
1169
|
let res;
|
|
1157
1170
|
let streamedAttempt = false;
|
|
1158
|
-
// attempt stream only if not disabled and not using node-fetch
|
|
1159
|
-
if (!isNodeFetch &&
|
|
1171
|
+
// attempt stream only if not disabled and not using node-fetch or Bun
|
|
1172
|
+
if (!isNodeFetch &&
|
|
1173
|
+
!this.multipartStreamingDisabled &&
|
|
1174
|
+
getEnv() !== "bun") {
|
|
1160
1175
|
streamedAttempt = true;
|
|
1161
1176
|
res = await sendWithRetry(buildStream);
|
|
1162
1177
|
}
|
|
@@ -1231,6 +1246,9 @@ export class Client {
|
|
|
1231
1246
|
if (options?.apiKey !== undefined) {
|
|
1232
1247
|
headers["x-api-key"] = options.apiKey;
|
|
1233
1248
|
}
|
|
1249
|
+
if (options?.workspaceId !== undefined) {
|
|
1250
|
+
headers["x-tenant-id"] = options.workspaceId;
|
|
1251
|
+
}
|
|
1234
1252
|
const body = serializePayloadForTracing(run, `Serializing payload to update run with id: ${runId}`);
|
|
1235
1253
|
await this.caller.call(async () => {
|
|
1236
1254
|
const res = await this._fetch(`${options?.apiUrl ?? this.apiUrl}/runs/${runId}`, {
|
|
@@ -1557,7 +1575,7 @@ export class Client {
|
|
|
1557
1575
|
const response = await this.caller.call(async () => {
|
|
1558
1576
|
const res = await this._fetch(`${this.apiUrl}/runs/stats`, {
|
|
1559
1577
|
method: "POST",
|
|
1560
|
-
headers: this.headers,
|
|
1578
|
+
headers: { ...this.headers, "Content-Type": "application/json" },
|
|
1561
1579
|
signal: AbortSignal.timeout(this.timeout_ms),
|
|
1562
1580
|
...this.fetchOptions,
|
|
1563
1581
|
body,
|
|
@@ -1931,7 +1949,7 @@ export class Client {
|
|
|
1931
1949
|
}
|
|
1932
1950
|
throw new Error("No projects found to resolve tenant.");
|
|
1933
1951
|
}
|
|
1934
|
-
async *listProjects({ projectIds, name, nameContains, referenceDatasetId, referenceDatasetName, referenceFree, metadata, } = {}) {
|
|
1952
|
+
async *listProjects({ projectIds, name, nameContains, referenceDatasetId, referenceDatasetName, datasetVersion, referenceFree, metadata, } = {}) {
|
|
1935
1953
|
const params = new URLSearchParams();
|
|
1936
1954
|
if (projectIds !== undefined) {
|
|
1937
1955
|
for (const projectId of projectIds) {
|
|
@@ -1953,6 +1971,9 @@ export class Client {
|
|
|
1953
1971
|
});
|
|
1954
1972
|
params.append("reference_dataset", dataset.id);
|
|
1955
1973
|
}
|
|
1974
|
+
if (datasetVersion !== undefined) {
|
|
1975
|
+
params.append("dataset_version", datasetVersion);
|
|
1976
|
+
}
|
|
1956
1977
|
if (referenceFree !== undefined) {
|
|
1957
1978
|
params.append("reference_free", referenceFree.toString());
|
|
1958
1979
|
}
|
|
@@ -2825,7 +2846,10 @@ export class Client {
|
|
|
2825
2846
|
async *listFeedback({ runIds, feedbackKeys, feedbackSourceTypes, } = {}) {
|
|
2826
2847
|
const queryParams = new URLSearchParams();
|
|
2827
2848
|
if (runIds) {
|
|
2828
|
-
|
|
2849
|
+
for (const runId of runIds) {
|
|
2850
|
+
assertUuid(runId);
|
|
2851
|
+
queryParams.append("run", runId);
|
|
2852
|
+
}
|
|
2829
2853
|
}
|
|
2830
2854
|
if (feedbackKeys) {
|
|
2831
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";
|