langsmith 0.7.4 → 0.7.5

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 CHANGED
@@ -4103,6 +4103,23 @@ class Client {
4103
4103
  }
4104
4104
  return json.commits[0].commit_hash;
4105
4105
  }
4106
+ async _createCommitTags(promptOwnerAndName, commitId, tags) {
4107
+ const tagList = typeof tags === "string" ? [tags] : tags;
4108
+ await Promise.all(tagList.map(async (tag) => this.caller.call(async () => {
4109
+ const res = await this._fetch(`${this.apiUrl}/repos/${promptOwnerAndName}/tags`, {
4110
+ method: "POST",
4111
+ headers: {
4112
+ ...this._mergedHeaders,
4113
+ "Content-Type": "application/json",
4114
+ },
4115
+ signal: AbortSignal.timeout(this.timeout_ms),
4116
+ ...this.fetchOptions,
4117
+ body: JSON.stringify({ tag_name: tag, commit_id: commitId }),
4118
+ });
4119
+ await (0, error_js_1.raiseForStatus)(res, "create commit tag");
4120
+ return res;
4121
+ })));
4122
+ }
4106
4123
  async _likeOrUnlikePrompt(promptIdentifier, like) {
4107
4124
  const [owner, promptName, _] = (0, prompts_js_1.parseHubIdentifier)(promptIdentifier);
4108
4125
  const body = JSON.stringify({ like: like });
@@ -4369,6 +4386,8 @@ class Client {
4369
4386
  * @param object - The prompt object/manifest to commit (e.g., ChatPromptTemplate, messages array, etc.)
4370
4387
  * @param options - Optional configuration for the commit
4371
4388
  * @param options.parentCommitHash - The parent commit hash. Defaults to "latest" (the most recent commit).
4389
+ * @param options.tags - A tag or list of tags to apply to the commit.
4390
+ * @param options.description - A description for the commit.
4372
4391
  * @returns A Promise that resolves to the URL of the newly created commit
4373
4392
  * @throws {Error} If the prompt does not exist
4374
4393
  * @example
@@ -4384,9 +4403,9 @@ class Client {
4384
4403
  * const commitUrl = await client.createCommit("my-prompt", template);
4385
4404
  * console.log(`Commit created: ${commitUrl}`);
4386
4405
  *
4387
- * // Create a commit based on a specific parent commit
4406
+ * // Create a commit with tags
4388
4407
  * const commitUrl2 = await client.createCommit("my-prompt", template, {
4389
- * parentCommitHash: "abc123def456"
4408
+ * tags: ["production", "v1"]
4390
4409
  * });
4391
4410
  * ```
4392
4411
  */
@@ -4421,7 +4440,11 @@ class Client {
4421
4440
  return res;
4422
4441
  });
4423
4442
  const result = await response.json();
4424
- return this._getPromptUrl(`${owner}/${promptName}${result.commit_hash ? `:${result.commit_hash}` : ""}`);
4443
+ const commit = result.commit ?? result;
4444
+ if (options?.tags) {
4445
+ await this._createCommitTags(`${owner}/${promptName}`, commit.id, options.tags);
4446
+ }
4447
+ return this._getPromptUrl(`${owner}/${promptName}${commit.commit_hash ? `:${commit.commit_hash}` : ""}`);
4425
4448
  }
4426
4449
  /**
4427
4450
  * Update examples with attachments using multipart form data.
@@ -4756,7 +4779,8 @@ class Client {
4756
4779
  async pushPrompt(promptIdentifier, options) {
4757
4780
  // Create or update prompt metadata
4758
4781
  if (await this.promptExists(promptIdentifier)) {
4759
- if (options && Object.keys(options).some((key) => key !== "object")) {
4782
+ if (options &&
4783
+ ["description", "readme", "tags", "isPublic"].some((key) => options[key] !== undefined)) {
4760
4784
  await this.updatePrompt(promptIdentifier, {
4761
4785
  description: options?.description,
4762
4786
  readme: options?.readme,
@@ -4779,6 +4803,7 @@ class Client {
4779
4803
  // Create a commit with the new manifest
4780
4804
  const url = await this.createCommit(promptIdentifier, options?.object, {
4781
4805
  parentCommitHash: options?.parentCommitHash,
4806
+ tags: options?.commitTags,
4782
4807
  description: options?.commitDescription,
4783
4808
  });
4784
4809
  return url;
package/dist/client.d.ts CHANGED
@@ -1129,6 +1129,7 @@ export declare class Client implements LangSmithTracingClientInterface {
1129
1129
  protected _currentTenantIsOwner(owner: string): Promise<boolean>;
1130
1130
  protected _ownerConflictError(action: string, owner: string): Promise<Error>;
1131
1131
  protected _getLatestCommitHash(promptOwnerAndName: string): Promise<string | undefined>;
1132
+ protected _createCommitTags(promptOwnerAndName: string, commitId: string, tags: string | string[]): Promise<void>;
1132
1133
  protected _likeOrUnlikePrompt(promptIdentifier: string, like: boolean): Promise<LikePromptResponse>;
1133
1134
  protected _getPromptUrl(promptIdentifier: string): Promise<string>;
1134
1135
  /**
@@ -1287,6 +1288,8 @@ export declare class Client implements LangSmithTracingClientInterface {
1287
1288
  * @param object - The prompt object/manifest to commit (e.g., ChatPromptTemplate, messages array, etc.)
1288
1289
  * @param options - Optional configuration for the commit
1289
1290
  * @param options.parentCommitHash - The parent commit hash. Defaults to "latest" (the most recent commit).
1291
+ * @param options.tags - A tag or list of tags to apply to the commit.
1292
+ * @param options.description - A description for the commit.
1290
1293
  * @returns A Promise that resolves to the URL of the newly created commit
1291
1294
  * @throws {Error} If the prompt does not exist
1292
1295
  * @example
@@ -1302,14 +1305,15 @@ export declare class Client implements LangSmithTracingClientInterface {
1302
1305
  * const commitUrl = await client.createCommit("my-prompt", template);
1303
1306
  * console.log(`Commit created: ${commitUrl}`);
1304
1307
  *
1305
- * // Create a commit based on a specific parent commit
1308
+ * // Create a commit with tags
1306
1309
  * const commitUrl2 = await client.createCommit("my-prompt", template, {
1307
- * parentCommitHash: "abc123def456"
1310
+ * tags: ["production", "v1"]
1308
1311
  * });
1309
1312
  * ```
1310
1313
  */
1311
1314
  createCommit(promptIdentifier: string, object: any, options?: {
1312
1315
  parentCommitHash?: string;
1316
+ tags?: string | string[];
1313
1317
  description?: string;
1314
1318
  }): Promise<string>;
1315
1319
  /**
@@ -1413,6 +1417,7 @@ export declare class Client implements LangSmithTracingClientInterface {
1413
1417
  description?: string;
1414
1418
  readme?: string;
1415
1419
  tags?: string[];
1420
+ commitTags?: string | string[];
1416
1421
  commitDescription?: string;
1417
1422
  }): Promise<string>;
1418
1423
  /**
package/dist/client.js CHANGED
@@ -4065,6 +4065,23 @@ export class Client {
4065
4065
  }
4066
4066
  return json.commits[0].commit_hash;
4067
4067
  }
4068
+ async _createCommitTags(promptOwnerAndName, commitId, tags) {
4069
+ const tagList = typeof tags === "string" ? [tags] : tags;
4070
+ await Promise.all(tagList.map(async (tag) => this.caller.call(async () => {
4071
+ const res = await this._fetch(`${this.apiUrl}/repos/${promptOwnerAndName}/tags`, {
4072
+ method: "POST",
4073
+ headers: {
4074
+ ...this._mergedHeaders,
4075
+ "Content-Type": "application/json",
4076
+ },
4077
+ signal: AbortSignal.timeout(this.timeout_ms),
4078
+ ...this.fetchOptions,
4079
+ body: JSON.stringify({ tag_name: tag, commit_id: commitId }),
4080
+ });
4081
+ await raiseForStatus(res, "create commit tag");
4082
+ return res;
4083
+ })));
4084
+ }
4068
4085
  async _likeOrUnlikePrompt(promptIdentifier, like) {
4069
4086
  const [owner, promptName, _] = parseHubIdentifier(promptIdentifier);
4070
4087
  const body = JSON.stringify({ like: like });
@@ -4331,6 +4348,8 @@ export class Client {
4331
4348
  * @param object - The prompt object/manifest to commit (e.g., ChatPromptTemplate, messages array, etc.)
4332
4349
  * @param options - Optional configuration for the commit
4333
4350
  * @param options.parentCommitHash - The parent commit hash. Defaults to "latest" (the most recent commit).
4351
+ * @param options.tags - A tag or list of tags to apply to the commit.
4352
+ * @param options.description - A description for the commit.
4334
4353
  * @returns A Promise that resolves to the URL of the newly created commit
4335
4354
  * @throws {Error} If the prompt does not exist
4336
4355
  * @example
@@ -4346,9 +4365,9 @@ export class Client {
4346
4365
  * const commitUrl = await client.createCommit("my-prompt", template);
4347
4366
  * console.log(`Commit created: ${commitUrl}`);
4348
4367
  *
4349
- * // Create a commit based on a specific parent commit
4368
+ * // Create a commit with tags
4350
4369
  * const commitUrl2 = await client.createCommit("my-prompt", template, {
4351
- * parentCommitHash: "abc123def456"
4370
+ * tags: ["production", "v1"]
4352
4371
  * });
4353
4372
  * ```
4354
4373
  */
@@ -4383,7 +4402,11 @@ export class Client {
4383
4402
  return res;
4384
4403
  });
4385
4404
  const result = await response.json();
4386
- return this._getPromptUrl(`${owner}/${promptName}${result.commit_hash ? `:${result.commit_hash}` : ""}`);
4405
+ const commit = result.commit ?? result;
4406
+ if (options?.tags) {
4407
+ await this._createCommitTags(`${owner}/${promptName}`, commit.id, options.tags);
4408
+ }
4409
+ return this._getPromptUrl(`${owner}/${promptName}${commit.commit_hash ? `:${commit.commit_hash}` : ""}`);
4387
4410
  }
4388
4411
  /**
4389
4412
  * Update examples with attachments using multipart form data.
@@ -4718,7 +4741,8 @@ export class Client {
4718
4741
  async pushPrompt(promptIdentifier, options) {
4719
4742
  // Create or update prompt metadata
4720
4743
  if (await this.promptExists(promptIdentifier)) {
4721
- if (options && Object.keys(options).some((key) => key !== "object")) {
4744
+ if (options &&
4745
+ ["description", "readme", "tags", "isPublic"].some((key) => options[key] !== undefined)) {
4722
4746
  await this.updatePrompt(promptIdentifier, {
4723
4747
  description: options?.description,
4724
4748
  readme: options?.readme,
@@ -4741,6 +4765,7 @@ export class Client {
4741
4765
  // Create a commit with the new manifest
4742
4766
  const url = await this.createCommit(promptIdentifier, options?.object, {
4743
4767
  parentCommitHash: options?.parentCommitHash,
4768
+ tags: options?.commitTags,
4744
4769
  description: options?.commitDescription,
4745
4770
  });
4746
4771
  return url;
@@ -224,5 +224,5 @@ async function evaluateComparative(experiments, options) {
224
224
  });
225
225
  const results = await Promise.all(promises);
226
226
  await client.awaitPendingTraceBatches();
227
- return { experimentName, results };
227
+ return { experimentName, results, url: viewUrl, comparativeExperiment };
228
228
  }
@@ -1,5 +1,5 @@
1
1
  import { Client } from "../index.js";
2
- import { ComparisonEvaluationResult as ComparisonEvaluationResultRow, Example, Run } from "../schemas.js";
2
+ import { ComparativeExperiment, ComparisonEvaluationResult as ComparisonEvaluationResultRow, Example, Run } from "../schemas.js";
3
3
  import { evaluate } from "./index.js";
4
4
  type ExperimentResults = Awaited<ReturnType<typeof evaluate>>;
5
5
  /** @deprecated Use ComparativeEvaluatorNew instead: (args: { runs, example, inputs, outputs, referenceOutputs }) => ... */
@@ -54,8 +54,14 @@ export interface EvaluateComparativeOptions {
54
54
  maxConcurrency?: number;
55
55
  }
56
56
  export interface ComparisonEvaluationResults {
57
+ /** The name of the comparative experiment. */
57
58
  experimentName: string;
59
+ /** The per-example comparison results. */
58
60
  results: ComparisonEvaluationResultRow[];
61
+ /** URL of the pairwise comparison view in the LangSmith UI, if available. */
62
+ url: string | null;
63
+ /** The comparative experiment, exposing its id, dataset, and metadata. */
64
+ comparativeExperiment: ComparativeExperiment;
59
65
  }
60
66
  /** @deprecated Use `evaluate` and pass two experiments as targets. */
61
67
  export declare function evaluateComparative(experiments: Array<string> | Array<Promise<ExperimentResults> | ExperimentResults>, options: EvaluateComparativeOptions): Promise<ComparisonEvaluationResults>;
@@ -218,5 +218,5 @@ export async function evaluateComparative(experiments, options) {
218
218
  });
219
219
  const results = await Promise.all(promises);
220
220
  await client.awaitPendingTraceBatches();
221
- return { experimentName, results };
221
+ return { experimentName, results, url: viewUrl, comparativeExperiment };
222
222
  }
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.__version__ = exports.promptCacheSingleton = exports.configureGlobalPromptCache = exports.PromptCache = exports.Cache = exports.uuid7FromTime = exports.uuid7 = exports.getDefaultProjectName = exports.overrideFetchImplementation = exports.RunTree = exports.Client = void 0;
3
+ exports.LS_MESSAGE_VIEW_EXCLUDE = exports.__version__ = exports.promptCacheSingleton = exports.configureGlobalPromptCache = exports.PromptCache = exports.Cache = exports.uuid7FromTime = exports.uuid7 = exports.getDefaultProjectName = exports.overrideFetchImplementation = exports.RunTree = exports.Client = void 0;
4
4
  var client_js_1 = require("./client.cjs");
5
5
  Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_js_1.Client; } });
6
6
  var run_trees_js_1 = require("./run_trees.cjs");
@@ -18,4 +18,6 @@ Object.defineProperty(exports, "PromptCache", { enumerable: true, get: function
18
18
  Object.defineProperty(exports, "configureGlobalPromptCache", { enumerable: true, get: function () { return index_js_1.configureGlobalPromptCache; } });
19
19
  Object.defineProperty(exports, "promptCacheSingleton", { enumerable: true, get: function () { return index_js_1.promptCacheSingleton; } });
20
20
  // Update using pnpm bump-version
21
- exports.__version__ = "0.7.4";
21
+ exports.__version__ = "0.7.5";
22
+ // Metadata key to hide a traced run from LangSmith's Messages View.
23
+ exports.LS_MESSAGE_VIEW_EXCLUDE = "ls_message_view_exclude";
package/dist/index.d.ts CHANGED
@@ -5,4 +5,5 @@ export { overrideFetchImplementation } from "./singletons/fetch.js";
5
5
  export { getDefaultProjectName } from "./utils/project.js";
6
6
  export { uuid7, uuid7FromTime } from "./uuid.js";
7
7
  export { Cache, PromptCache, type CacheConfig, type CacheMetrics, configureGlobalPromptCache, promptCacheSingleton, } from "./utils/prompt_cache/index.js";
8
- export declare const __version__ = "0.7.4";
8
+ export declare const __version__ = "0.7.5";
9
+ export declare const LS_MESSAGE_VIEW_EXCLUDE: "ls_message_view_exclude";
package/dist/index.js CHANGED
@@ -5,4 +5,6 @@ export { getDefaultProjectName } from "./utils/project.js";
5
5
  export { uuid7, uuid7FromTime } from "./uuid.js";
6
6
  export { Cache, PromptCache, configureGlobalPromptCache, promptCacheSingleton, } from "./utils/prompt_cache/index.js";
7
7
  // Update using pnpm bump-version
8
- export const __version__ = "0.7.4";
8
+ export const __version__ = "0.7.5";
9
+ // Metadata key to hide a traced run from LangSmith's Messages View.
10
+ export const LS_MESSAGE_VIEW_EXCLUDE = "ls_message_view_exclude";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langsmith",
3
- "version": "0.7.4",
3
+ "version": "0.7.5",
4
4
  "description": "Client library to connect to the LangSmith Observability and Evaluation Platform.",
5
5
  "packageManager": "pnpm@10.33.0",
6
6
  "files": [