langsmith 0.8.1 → 0.8.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.
package/dist/client.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { OTELContext } from "./experimental/otel/types.js";
2
2
  import { AsyncCallerParams } from "./utils/async_caller.js";
3
- import { ComparativeExperiment, DataType, Dataset, DatasetDiffInfo, DatasetShareSchema, Example, ExampleCreate, ExampleUpdate, ExampleUpdateWithoutId, Feedback, FeedbackConfig, FeedbackIngestToken, KVMap, LangChainBaseMessage, LangSmithSettings, LikePromptResponse, Prompt, PromptCommit, PromptSortField, Run, RunCreate, RunUpdate, ScoreType, TimeDelta, TracerSession, TracerSessionResult, ValueType, AnnotationQueue, RunWithAnnotationQueueInfo, Attachments, UploadExamplesResponse, UpdateExamplesResponse, DatasetVersion, AnnotationQueueWithDetails, AnnotationQueueRubricItem, FeedbackConfigSchema, AgentContext, SkillContext, Entry } from "./schemas.js";
3
+ import { ComparativeExperiment, DataType, Dataset, DatasetDiffInfo, DatasetShareSchema, Example, ExampleCreate, ExampleUpdate, ExampleUpdateWithoutId, Feedback, FeedbackConfig, FeedbackIngestToken, KVMap, LangChainBaseMessage, LangSmithSettings, LikePromptResponse, Prompt, PromptCommit, PromptSortField, Run, RunCreate, RunUpdate, ScoreType, TimeDelta, TracerSession, TracerSessionResult, ValueType, AnnotationQueue, RunWithAnnotationQueueInfo, Attachments, UploadExamplesResponse, UpdateExamplesResponse, DatasetVersion, AnnotationQueueWithDetails, AnnotationQueueRubricItem, RunKey, FeedbackConfigSchema, AgentContext, SkillContext, Entry } from "./schemas.js";
4
4
  import { type TracingMode } from "./utils/env.js";
5
5
  import { EvaluationResult, EvaluationResults } from "./evaluation/evaluator.js";
6
6
  import { OnlineEvaluators as Evaluators } from "./_openapi_client/resources/online-evaluators.js";
@@ -373,6 +373,7 @@ type AutoBatchQueueItem = {
373
373
  otelContext?: OTELContext;
374
374
  apiKey?: string;
375
375
  apiUrl?: string;
376
+ workspaceId?: string;
376
377
  size?: number;
377
378
  };
378
379
  type Thread = {
@@ -409,6 +410,7 @@ export declare class AutoBatchQueue {
409
410
  size: number;
410
411
  apiKey?: string;
411
412
  apiUrl?: string;
413
+ workspaceId?: string;
412
414
  }[];
413
415
  sizeBytes: number;
414
416
  private maxSizeBytes;
@@ -422,6 +424,7 @@ export declare class AutoBatchQueue {
422
424
  size: number;
423
425
  apiKey?: string;
424
426
  apiUrl?: string;
427
+ workspaceId?: string;
425
428
  };
426
429
  push(item: AutoBatchQueueItem): Promise<void>;
427
430
  pop({ upToSizeBytes, upToSize, }: {
@@ -599,6 +602,7 @@ export declare class Client implements LangSmithTracingClientInterface {
599
602
  }, options?: {
600
603
  apiKey?: string;
601
604
  apiUrl?: string;
605
+ workspaceId?: string;
602
606
  sizeBytes?: number;
603
607
  }): Promise<void>;
604
608
  private _postBatchIngestRuns;
@@ -612,6 +616,7 @@ export declare class Client implements LangSmithTracingClientInterface {
612
616
  }, options?: {
613
617
  apiKey?: string;
614
618
  apiUrl?: string;
619
+ workspaceId?: string;
615
620
  useGzip?: boolean;
616
621
  sizeBytes?: number;
617
622
  }): Promise<void>;
@@ -1135,10 +1140,21 @@ export declare class Client implements LangSmithTracingClientInterface {
1135
1140
  deleteAnnotationQueue(queueId: string): Promise<void>;
1136
1141
  /**
1137
1142
  * Add runs to an annotation queue with the specified queue ID.
1143
+ *
1144
+ * The second argument is either:
1145
+ * - `RunKey[]` (preferred): each entry carries the run's full lookup key, so
1146
+ * it can be located directly without a scan. Required for workspaces served
1147
+ * by SmithDB; routes to `POST /runs/by-key`.
1148
+ * - `string[]`: a plain list of run IDs. This path will be deprecated in a
1149
+ * future release; prefer the key form. Routes to `POST /runs`.
1150
+ *
1151
+ * If every element is a string (or the list is empty) it is treated as run
1152
+ * IDs; otherwise the list is treated as `RunKey` objects.
1153
+ *
1138
1154
  * @param queueId - The ID of the annotation queue
1139
- * @param runIds - The IDs of the runs to be added to the annotation queue
1155
+ * @param runs - Either a list of run IDs (deprecated) or a list of run keys.
1140
1156
  */
1141
- addRunsToAnnotationQueue(queueId: string, runIds: string[]): Promise<void>;
1157
+ addRunsToAnnotationQueue(queueId: string, runs: string[] | RunKey[]): Promise<void>;
1142
1158
  /**
1143
1159
  * Get a run from an annotation queue at the specified index.
1144
1160
  * @param queueId - The ID of the annotation queue
package/dist/client.js CHANGED
@@ -200,6 +200,7 @@ export class AutoBatchQueue {
200
200
  otelContext: item.otelContext,
201
201
  apiKey: item.apiKey,
202
202
  apiUrl: item.apiUrl,
203
+ workspaceId: item.workspaceId,
203
204
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
204
205
  itemPromiseResolve: itemPromiseResolve,
205
206
  itemPromise,
@@ -240,6 +241,7 @@ export class AutoBatchQueue {
240
241
  otelContext: it.otelContext,
241
242
  apiKey: it.apiKey,
242
243
  apiUrl: it.apiUrl,
244
+ workspaceId: it.workspaceId,
243
245
  size: it.size,
244
246
  })),
245
247
  () => popped.forEach((it) => it.itemPromiseResolve()),
@@ -1217,8 +1219,13 @@ export class Client {
1217
1219
  const batchesByDestination = batch.reduce((acc, item) => {
1218
1220
  const apiUrl = item.apiUrl ?? this.apiUrl;
1219
1221
  const apiKey = item.apiKey ?? this.apiKey;
1220
- const isDefault = item.apiKey === this.apiKey && item.apiUrl === this.apiUrl;
1221
- const batchKey = isDefault ? "default" : `${apiUrl}|${apiKey}`;
1222
+ const workspaceId = item.workspaceId ?? this.workspaceId;
1223
+ const isDefault = item.apiKey === this.apiKey &&
1224
+ item.apiUrl === this.apiUrl &&
1225
+ item.workspaceId === this.workspaceId;
1226
+ const batchKey = isDefault
1227
+ ? "default"
1228
+ : `${apiUrl}|${apiKey}|${workspaceId ?? ""}`;
1222
1229
  if (!acc[batchKey]) {
1223
1230
  acc[batchKey] = [];
1224
1231
  }
@@ -1227,9 +1234,13 @@ export class Client {
1227
1234
  }, {});
1228
1235
  const batchPromises = [];
1229
1236
  for (const [batchKey, batch] of Object.entries(batchesByDestination)) {
1237
+ const isDefault = batchKey === "default";
1238
+ const parts = isDefault ? [] : batchKey.split("|");
1239
+ const workspaceIdPart = parts[2];
1230
1240
  const batchPromise = this._processBatch(batch, {
1231
- apiUrl: batchKey === "default" ? undefined : batchKey.split("|")[0],
1232
- apiKey: batchKey === "default" ? undefined : batchKey.split("|")[1],
1241
+ apiUrl: isDefault ? undefined : parts[0],
1242
+ apiKey: isDefault ? undefined : parts[1],
1243
+ workspaceId: isDefault || !workspaceIdPart ? undefined : workspaceIdPart,
1233
1244
  });
1234
1245
  batchPromises.push(batchPromise);
1235
1246
  }
@@ -1509,6 +1520,7 @@ export class Client {
1509
1520
  otelContext,
1510
1521
  apiKey: options?.apiKey,
1511
1522
  apiUrl: options?.apiUrl,
1523
+ workspaceId: options?.workspaceId,
1512
1524
  }).catch(console.error);
1513
1525
  return;
1514
1526
  }
@@ -1603,6 +1615,9 @@ export class Client {
1603
1615
  if (options?.apiKey !== undefined) {
1604
1616
  headers["x-api-key"] = options.apiKey;
1605
1617
  }
1618
+ if (options?.workspaceId !== undefined) {
1619
+ headers["x-tenant-id"] = options.workspaceId;
1620
+ }
1606
1621
  await this.batchIngestCaller.callWithOptions({ sizeBytes: options?.sizeBytes }, async () => {
1607
1622
  const res = await this._fetch(`${options?.apiUrl ?? this.apiUrl}/runs/batch`, {
1608
1623
  method: "POST",
@@ -1826,6 +1841,9 @@ export class Client {
1826
1841
  if (options?.apiKey !== undefined) {
1827
1842
  headers["x-api-key"] = options.apiKey;
1828
1843
  }
1844
+ if (options?.workspaceId !== undefined) {
1845
+ headers["x-tenant-id"] = options.workspaceId;
1846
+ }
1829
1847
  let transformedBody = body;
1830
1848
  if (options?.useGzip &&
1831
1849
  typeof body === "object" &&
@@ -1928,6 +1946,7 @@ export class Client {
1928
1946
  otelContext,
1929
1947
  apiKey: options?.apiKey,
1930
1948
  apiUrl: options?.apiUrl,
1949
+ workspaceId: options?.workspaceId,
1931
1950
  }).catch(console.error);
1932
1951
  return;
1933
1952
  }
@@ -1938,6 +1957,7 @@ export class Client {
1938
1957
  otelContext,
1939
1958
  apiKey: options?.apiKey,
1940
1959
  apiUrl: options?.apiUrl,
1960
+ workspaceId: options?.workspaceId,
1941
1961
  }).catch(console.error);
1942
1962
  }
1943
1963
  return;
@@ -4046,13 +4066,48 @@ export class Client {
4046
4066
  }
4047
4067
  /**
4048
4068
  * Add runs to an annotation queue with the specified queue ID.
4069
+ *
4070
+ * The second argument is either:
4071
+ * - `RunKey[]` (preferred): each entry carries the run's full lookup key, so
4072
+ * it can be located directly without a scan. Required for workspaces served
4073
+ * by SmithDB; routes to `POST /runs/by-key`.
4074
+ * - `string[]`: a plain list of run IDs. This path will be deprecated in a
4075
+ * future release; prefer the key form. Routes to `POST /runs`.
4076
+ *
4077
+ * If every element is a string (or the list is empty) it is treated as run
4078
+ * IDs; otherwise the list is treated as `RunKey` objects.
4079
+ *
4049
4080
  * @param queueId - The ID of the annotation queue
4050
- * @param runIds - The IDs of the runs to be added to the annotation queue
4081
+ * @param runs - Either a list of run IDs (deprecated) or a list of run keys.
4051
4082
  */
4052
- async addRunsToAnnotationQueue(queueId, runIds) {
4053
- const body = JSON.stringify(runIds.map((id, i) => assertUuid(id, `runIds[${i}]`).toString()));
4083
+ async addRunsToAnnotationQueue(queueId, runs) {
4084
+ const base = `${this.apiUrl}/annotation-queues/${assertUuid(queueId, "queueId")}/runs`;
4085
+ // All strings (including empty) -> legacy /runs; otherwise treat as run keys.
4086
+ const allStrings = runs.every((r) => typeof r === "string");
4087
+ let url;
4088
+ let body;
4089
+ if (!allStrings) {
4090
+ url = `${base}/by-key`;
4091
+ body = JSON.stringify(runs.map((run, i) => {
4092
+ const serialized = {
4093
+ run_id: assertUuid(run.runId, `runs[${i}].runId`).toString(),
4094
+ session_id: assertUuid(run.sessionId, `runs[${i}].sessionId`).toString(),
4095
+ start_time: typeof run.startTime === "string"
4096
+ ? run.startTime
4097
+ : new Date(run.startTime).toISOString(),
4098
+ };
4099
+ if (run.sourceProposedExampleId != null) {
4100
+ serialized.source_proposed_example_id = assertUuid(run.sourceProposedExampleId, `runs[${i}].sourceProposedExampleId`).toString();
4101
+ }
4102
+ return serialized;
4103
+ }));
4104
+ }
4105
+ else {
4106
+ url = base;
4107
+ body = JSON.stringify(runs.map((id, i) => assertUuid(id, `runs[${i}]`).toString()));
4108
+ }
4054
4109
  await this.caller.call(async () => {
4055
- const res = await this._fetch(`${this.apiUrl}/annotation-queues/${assertUuid(queueId, "queueId")}/runs`, {
4110
+ const res = await this._fetch(url, {
4056
4111
  method: "POST",
4057
4112
  headers: {
4058
4113
  ...this._mergedHeaders,
package/dist/index.cjs CHANGED
@@ -34,6 +34,6 @@ Object.defineProperty(exports, "UnprocessableEntityError", { enumerable: true, g
34
34
  Object.defineProperty(exports, "RateLimitError", { enumerable: true, get: function () { return error_js_1.RateLimitError; } });
35
35
  Object.defineProperty(exports, "InternalServerError", { enumerable: true, get: function () { return error_js_1.InternalServerError; } });
36
36
  // Update using pnpm bump-version
37
- exports.__version__ = "0.8.1";
37
+ exports.__version__ = "0.8.2";
38
38
  // Metadata key to hide a traced run from LangSmith's Messages View.
39
39
  exports.LS_MESSAGE_VIEW_EXCLUDE = "ls_message_view_exclude";
package/dist/index.d.ts CHANGED
@@ -7,5 +7,5 @@ export { uuid7, uuid7FromTime } from "./uuid.js";
7
7
  export { isTracingEnabled } from "./utils/guard.js";
8
8
  export { Cache, PromptCache, type CacheConfig, type CacheMetrics, configureGlobalPromptCache, promptCacheSingleton, } from "./utils/prompt_cache/index.js";
9
9
  export { LangsmithError, APIError, APIUserAbortError, APIConnectionError, APIConnectionTimeoutError, BadRequestError, AuthenticationError, PermissionDeniedError, NotFoundError, ConflictError, UnprocessableEntityError, RateLimitError, InternalServerError, } from "./_openapi_client/core/error.js";
10
- export declare const __version__ = "0.8.1";
10
+ export declare const __version__ = "0.8.2";
11
11
  export declare const LS_MESSAGE_VIEW_EXCLUDE: "ls_message_view_exclude";
package/dist/index.js CHANGED
@@ -7,6 +7,6 @@ export { isTracingEnabled } from "./utils/guard.js";
7
7
  export { Cache, PromptCache, configureGlobalPromptCache, promptCacheSingleton, } from "./utils/prompt_cache/index.js";
8
8
  export { LangsmithError, APIError, APIUserAbortError, APIConnectionError, APIConnectionTimeoutError, BadRequestError, AuthenticationError, PermissionDeniedError, NotFoundError, ConflictError, UnprocessableEntityError, RateLimitError, InternalServerError, } from "./_openapi_client/core/error.js";
9
9
  // Update using pnpm bump-version
10
- export const __version__ = "0.8.1";
10
+ export const __version__ = "0.8.2";
11
11
  // Metadata key to hide a traced run from LangSmith's Messages View.
12
12
  export const LS_MESSAGE_VIEW_EXCLUDE = "ls_message_view_exclude";
package/dist/schemas.d.ts CHANGED
@@ -531,6 +531,21 @@ export interface AnnotationQueueWithDetails extends AnnotationQueue {
531
531
  /** The rubric items for the annotation queue. */
532
532
  rubric_items?: AnnotationQueueRubricItem[];
533
533
  }
534
+ /**
535
+ * A run identified by its full lookup key, for adding to an annotation queue.
536
+ * Unlike a bare run ID, this carries the partition key (`sessionId` and
537
+ * `startTime`) so the run can be located directly, without a scan.
538
+ */
539
+ export interface RunKey {
540
+ /** The ID of the run to add to the queue. */
541
+ runId: string;
542
+ /** The ID of the project/session the run belongs to (partition key). */
543
+ sessionId: string;
544
+ /** The start time of the run (partition key): a Date, epoch ms, or ISO string. */
545
+ startTime: string | number | Date;
546
+ /** Optional back-pointer to the issues-agent proposed example that seeded this queue item. */
547
+ sourceProposedExampleId?: string;
548
+ }
534
549
  export interface FeedbackConfigSchema {
535
550
  /** The unique key identifying this feedback configuration. */
536
551
  feedback_key: string;
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports._MIN_BACKEND_VERSION = void 0;
4
- exports._MIN_BACKEND_VERSION = "0.16.12rc1";
4
+ exports._MIN_BACKEND_VERSION = "0.16.13rc1";
@@ -1 +1 @@
1
- export declare const _MIN_BACKEND_VERSION = "0.16.12rc1";
1
+ export declare const _MIN_BACKEND_VERSION = "0.16.13rc1";
@@ -1 +1 @@
1
- export const _MIN_BACKEND_VERSION = "0.16.12rc1";
1
+ export const _MIN_BACKEND_VERSION = "0.16.13rc1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langsmith",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "description": "Client library to connect to the LangSmith Observability and Evaluation Platform.",
5
5
  "packageManager": "pnpm@10.33.0",
6
6
  "files": [