langsmith 0.1.40 → 0.1.42

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
@@ -56,13 +56,13 @@ async function mergeRuntimeEnvIntoRunCreates(runs) {
56
56
  });
57
57
  }
58
58
  const getTracingSamplingRate = () => {
59
- const samplingRateStr = (0, env_js_1.getEnvironmentVariable)("LANGCHAIN_TRACING_SAMPLING_RATE");
59
+ const samplingRateStr = (0, env_js_1.getLangSmithEnvironmentVariable)("TRACING_SAMPLING_RATE");
60
60
  if (samplingRateStr === undefined) {
61
61
  return undefined;
62
62
  }
63
63
  const samplingRate = parseFloat(samplingRateStr);
64
64
  if (samplingRate < 0 || samplingRate > 1) {
65
- throw new Error(`LANGCHAIN_TRACING_SAMPLING_RATE must be between 0 and 1 if set. Got: ${samplingRate}`);
65
+ throw new Error(`LANGSMITH_TRACING_SAMPLING_RATE must be between 0 and 1 if set. Got: ${samplingRate}`);
66
66
  }
67
67
  return samplingRate;
68
68
  };
@@ -296,11 +296,11 @@ class Client {
296
296
  this.fetchOptions = config.fetchOptions || {};
297
297
  }
298
298
  static getDefaultClientConfig() {
299
- const apiKey = (0, env_js_1.getEnvironmentVariable)("LANGCHAIN_API_KEY");
300
- const apiUrl = (0, env_js_1.getEnvironmentVariable)("LANGCHAIN_ENDPOINT") ??
299
+ const apiKey = (0, env_js_1.getLangSmithEnvironmentVariable)("API_KEY");
300
+ const apiUrl = (0, env_js_1.getLangSmithEnvironmentVariable)("ENDPOINT") ??
301
301
  "https://api.smith.langchain.com";
302
- const hideInputs = (0, env_js_1.getEnvironmentVariable)("LANGCHAIN_HIDE_INPUTS") === "true";
303
- const hideOutputs = (0, env_js_1.getEnvironmentVariable)("LANGCHAIN_HIDE_OUTPUTS") === "true";
302
+ const hideInputs = (0, env_js_1.getLangSmithEnvironmentVariable)("HIDE_INPUTS") === "true";
303
+ const hideOutputs = (0, env_js_1.getLangSmithEnvironmentVariable)("HIDE_OUTPUTS") === "true";
304
304
  return {
305
305
  apiUrl: apiUrl,
306
306
  apiKey: apiKey,
@@ -743,7 +743,7 @@ class Client {
743
743
  }
744
744
  else {
745
745
  const project = await this.readProject({
746
- projectName: (0, env_js_1.getEnvironmentVariable)("LANGCHAIN_PROJECT") || "default",
746
+ projectName: (0, env_js_1.getLangSmithEnvironmentVariable)("PROJECT") || "default",
747
747
  });
748
748
  sessionId = project.id;
749
749
  }
@@ -1263,7 +1263,7 @@ class Client {
1263
1263
  }
1264
1264
  throw new Error("No projects found to resolve tenant.");
1265
1265
  }
1266
- async *listProjects({ projectIds, name, nameContains, referenceDatasetId, referenceDatasetName, referenceFree, } = {}) {
1266
+ async *listProjects({ projectIds, name, nameContains, referenceDatasetId, referenceDatasetName, referenceFree, metadata, } = {}) {
1267
1267
  const params = new URLSearchParams();
1268
1268
  if (projectIds !== undefined) {
1269
1269
  for (const projectId of projectIds) {
@@ -1288,6 +1288,9 @@ class Client {
1288
1288
  if (referenceFree !== undefined) {
1289
1289
  params.append("reference_free", referenceFree.toString());
1290
1290
  }
1291
+ if (metadata !== undefined) {
1292
+ params.append("metadata", JSON.stringify(metadata));
1293
+ }
1291
1294
  for await (const projects of this._getPaginated("/sessions", params)) {
1292
1295
  yield* projects;
1293
1296
  }
@@ -2328,12 +2331,14 @@ class Client {
2328
2331
  async pushPrompt(promptIdentifier, options) {
2329
2332
  // Create or update prompt metadata
2330
2333
  if (await this.promptExists(promptIdentifier)) {
2331
- await this.updatePrompt(promptIdentifier, {
2332
- description: options?.description,
2333
- readme: options?.readme,
2334
- tags: options?.tags,
2335
- isPublic: options?.isPublic,
2336
- });
2334
+ if (options && Object.keys(options).some((key) => key !== "object")) {
2335
+ await this.updatePrompt(promptIdentifier, {
2336
+ description: options?.description,
2337
+ readme: options?.readme,
2338
+ tags: options?.tags,
2339
+ isPublic: options?.isPublic,
2340
+ });
2341
+ }
2337
2342
  }
2338
2343
  else {
2339
2344
  await this.createPrompt(promptIdentifier, {
package/dist/client.d.ts CHANGED
@@ -365,13 +365,14 @@ export declare class Client {
365
365
  datasetName?: string;
366
366
  }): Promise<string>;
367
367
  private _getTenantId;
368
- listProjects({ projectIds, name, nameContains, referenceDatasetId, referenceDatasetName, referenceFree, }?: {
368
+ listProjects({ projectIds, name, nameContains, referenceDatasetId, referenceDatasetName, referenceFree, metadata, }?: {
369
369
  projectIds?: string[];
370
370
  name?: string;
371
371
  nameContains?: string;
372
372
  referenceDatasetId?: string;
373
373
  referenceDatasetName?: string;
374
374
  referenceFree?: boolean;
375
+ metadata?: RecordStringAny;
375
376
  }): AsyncIterable<TracerSession>;
376
377
  deleteProject({ projectId, projectName, }: {
377
378
  projectId?: string;
package/dist/client.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as uuid from "uuid";
2
2
  import { AsyncCaller } from "./utils/async_caller.js";
3
3
  import { convertLangChainMessageToExample, isLangChainMessage, } from "./utils/messages.js";
4
- import { getEnvironmentVariable, getLangChainEnvVarsMetadata, getRuntimeEnvironment, } from "./utils/env.js";
4
+ import { getLangChainEnvVarsMetadata, getLangSmithEnvironmentVariable, getRuntimeEnvironment, } from "./utils/env.js";
5
5
  import { __version__ } from "./index.js";
6
6
  import { assertUuid } from "./utils/_uuid.js";
7
7
  import { warnOnce } from "./utils/warn.js";
@@ -30,13 +30,13 @@ async function mergeRuntimeEnvIntoRunCreates(runs) {
30
30
  });
31
31
  }
32
32
  const getTracingSamplingRate = () => {
33
- const samplingRateStr = getEnvironmentVariable("LANGCHAIN_TRACING_SAMPLING_RATE");
33
+ const samplingRateStr = getLangSmithEnvironmentVariable("TRACING_SAMPLING_RATE");
34
34
  if (samplingRateStr === undefined) {
35
35
  return undefined;
36
36
  }
37
37
  const samplingRate = parseFloat(samplingRateStr);
38
38
  if (samplingRate < 0 || samplingRate > 1) {
39
- throw new Error(`LANGCHAIN_TRACING_SAMPLING_RATE must be between 0 and 1 if set. Got: ${samplingRate}`);
39
+ throw new Error(`LANGSMITH_TRACING_SAMPLING_RATE must be between 0 and 1 if set. Got: ${samplingRate}`);
40
40
  }
41
41
  return samplingRate;
42
42
  };
@@ -269,11 +269,11 @@ export class Client {
269
269
  this.fetchOptions = config.fetchOptions || {};
270
270
  }
271
271
  static getDefaultClientConfig() {
272
- const apiKey = getEnvironmentVariable("LANGCHAIN_API_KEY");
273
- const apiUrl = getEnvironmentVariable("LANGCHAIN_ENDPOINT") ??
272
+ const apiKey = getLangSmithEnvironmentVariable("API_KEY");
273
+ const apiUrl = getLangSmithEnvironmentVariable("ENDPOINT") ??
274
274
  "https://api.smith.langchain.com";
275
- const hideInputs = getEnvironmentVariable("LANGCHAIN_HIDE_INPUTS") === "true";
276
- const hideOutputs = getEnvironmentVariable("LANGCHAIN_HIDE_OUTPUTS") === "true";
275
+ const hideInputs = getLangSmithEnvironmentVariable("HIDE_INPUTS") === "true";
276
+ const hideOutputs = getLangSmithEnvironmentVariable("HIDE_OUTPUTS") === "true";
277
277
  return {
278
278
  apiUrl: apiUrl,
279
279
  apiKey: apiKey,
@@ -716,7 +716,7 @@ export class Client {
716
716
  }
717
717
  else {
718
718
  const project = await this.readProject({
719
- projectName: getEnvironmentVariable("LANGCHAIN_PROJECT") || "default",
719
+ projectName: getLangSmithEnvironmentVariable("PROJECT") || "default",
720
720
  });
721
721
  sessionId = project.id;
722
722
  }
@@ -1236,7 +1236,7 @@ export class Client {
1236
1236
  }
1237
1237
  throw new Error("No projects found to resolve tenant.");
1238
1238
  }
1239
- async *listProjects({ projectIds, name, nameContains, referenceDatasetId, referenceDatasetName, referenceFree, } = {}) {
1239
+ async *listProjects({ projectIds, name, nameContains, referenceDatasetId, referenceDatasetName, referenceFree, metadata, } = {}) {
1240
1240
  const params = new URLSearchParams();
1241
1241
  if (projectIds !== undefined) {
1242
1242
  for (const projectId of projectIds) {
@@ -1261,6 +1261,9 @@ export class Client {
1261
1261
  if (referenceFree !== undefined) {
1262
1262
  params.append("reference_free", referenceFree.toString());
1263
1263
  }
1264
+ if (metadata !== undefined) {
1265
+ params.append("metadata", JSON.stringify(metadata));
1266
+ }
1264
1267
  for await (const projects of this._getPaginated("/sessions", params)) {
1265
1268
  yield* projects;
1266
1269
  }
@@ -2301,12 +2304,14 @@ export class Client {
2301
2304
  async pushPrompt(promptIdentifier, options) {
2302
2305
  // Create or update prompt metadata
2303
2306
  if (await this.promptExists(promptIdentifier)) {
2304
- await this.updatePrompt(promptIdentifier, {
2305
- description: options?.description,
2306
- readme: options?.readme,
2307
- tags: options?.tags,
2308
- isPublic: options?.isPublic,
2309
- });
2307
+ if (options && Object.keys(options).some((key) => key !== "object")) {
2308
+ await this.updatePrompt(promptIdentifier, {
2309
+ description: options?.description,
2310
+ readme: options?.readme,
2311
+ tags: options?.tags,
2312
+ isPublic: options?.isPublic,
2313
+ });
2314
+ }
2310
2315
  }
2311
2316
  else {
2312
2317
  await this.createPrompt(promptIdentifier, {
package/dist/env.cjs CHANGED
@@ -6,12 +6,7 @@ const isTracingEnabled = (tracingEnabled) => {
6
6
  if (tracingEnabled !== undefined) {
7
7
  return tracingEnabled;
8
8
  }
9
- const envVars = [
10
- "LANGSMITH_TRACING_V2",
11
- "LANGCHAIN_TRACING_V2",
12
- "LANGSMITH_TRACING",
13
- "LANGCHAIN_TRACING",
14
- ];
15
- return !!envVars.find((envVar) => (0, env_js_1.getEnvironmentVariable)(envVar) === "true");
9
+ const envVars = ["TRACING_V2", "TRACING"];
10
+ return !!envVars.find((envVar) => (0, env_js_1.getLangSmithEnvironmentVariable)(envVar) === "true");
16
11
  };
17
12
  exports.isTracingEnabled = isTracingEnabled;
package/dist/env.js CHANGED
@@ -1,13 +1,8 @@
1
- import { getEnvironmentVariable } from "./utils/env.js";
1
+ import { getLangSmithEnvironmentVariable } from "./utils/env.js";
2
2
  export const isTracingEnabled = (tracingEnabled) => {
3
3
  if (tracingEnabled !== undefined) {
4
4
  return tracingEnabled;
5
5
  }
6
- const envVars = [
7
- "LANGSMITH_TRACING_V2",
8
- "LANGCHAIN_TRACING_V2",
9
- "LANGSMITH_TRACING",
10
- "LANGCHAIN_TRACING",
11
- ];
12
- return !!envVars.find((envVar) => getEnvironmentVariable(envVar) === "true");
6
+ const envVars = ["TRACING_V2", "TRACING"];
7
+ return !!envVars.find((envVar) => getLangSmithEnvironmentVariable(envVar) === "true");
13
8
  };
@@ -680,7 +680,7 @@ async function _forward(fn, example, experimentName, metadata, client) {
680
680
  if (!run) {
681
681
  throw new Error(`Run not created by target function.
682
682
  This is most likely due to tracing not being enabled.\n
683
- Try setting "LANGCHAIN_TRACING_V2=true" in your environment.`);
683
+ Try setting "LANGSMITH_TRACING=true" in your environment.`);
684
684
  }
685
685
  return {
686
686
  run,
@@ -676,7 +676,7 @@ async function _forward(fn, example, experimentName, metadata, client) {
676
676
  if (!run) {
677
677
  throw new Error(`Run not created by target function.
678
678
  This is most likely due to tracing not being enabled.\n
679
- Try setting "LANGCHAIN_TRACING_V2=true" in your environment.`);
679
+ Try setting "LANGSMITH_TRACING=true" in your environment.`);
680
680
  }
681
681
  return {
682
682
  run,
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.1.40";
9
+ exports.__version__ = "0.1.42";
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { Client } from "./client.js";
2
2
  export type { Dataset, Example, TracerSession, Run, Feedback, RetrieverOutput, } from "./schemas.js";
3
3
  export { RunTree, type RunTreeConfig } from "./run_trees.js";
4
- export declare const __version__ = "0.1.40";
4
+ export declare const __version__ = "0.1.42";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export { Client } from "./client.js";
2
2
  export { RunTree } from "./run_trees.js";
3
3
  // Update using yarn bump-version
4
- export const __version__ = "0.1.40";
4
+ export const __version__ = "0.1.42";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getShas = exports.setEnvironmentVariable = exports.getEnvironmentVariable = exports.getEnvironmentVariables = exports.getLangChainEnvVarsMetadata = exports.getLangChainEnvVars = exports.getRuntimeEnvironment = exports.getEnv = exports.isNode = exports.isDeno = exports.isJsDom = exports.isWebWorker = exports.isBrowser = void 0;
3
+ exports.getShas = exports.setEnvironmentVariable = exports.getLangSmithEnvironmentVariable = exports.getEnvironmentVariable = exports.getEnvironmentVariables = exports.getLangChainEnvVarsMetadata = exports.getLangChainEnvVars = exports.getRuntimeEnvironment = exports.getEnv = exports.isNode = exports.isDeno = exports.isJsDom = exports.isWebWorker = exports.isBrowser = void 0;
4
4
  // Inlined from https://github.com/flexdinesh/browser-or-node
5
5
  const index_js_1 = require("../index.cjs");
6
6
  let globalEnv;
@@ -173,6 +173,11 @@ function getEnvironmentVariable(name) {
173
173
  }
174
174
  }
175
175
  exports.getEnvironmentVariable = getEnvironmentVariable;
176
+ function getLangSmithEnvironmentVariable(name) {
177
+ return (getEnvironmentVariable(`LANGSMITH_${name}`) ||
178
+ getEnvironmentVariable(`LANGCHAIN_${name}`));
179
+ }
180
+ exports.getLangSmithEnvironmentVariable = getLangSmithEnvironmentVariable;
176
181
  function setEnvironmentVariable(name, value) {
177
182
  if (typeof process !== "undefined") {
178
183
  // eslint-disable-next-line no-process-env
@@ -47,6 +47,7 @@ export declare function getLangChainEnvVarsMetadata(): Record<string, string>;
47
47
  */
48
48
  export declare function getEnvironmentVariables(): Record<string, string> | undefined;
49
49
  export declare function getEnvironmentVariable(name: string): string | undefined;
50
+ export declare function getLangSmithEnvironmentVariable(name: string): string | undefined;
50
51
  export declare function setEnvironmentVariable(name: string, value: string): void;
51
52
  interface ICommitSHAs {
52
53
  [key: string]: string;
package/dist/utils/env.js CHANGED
@@ -159,6 +159,10 @@ export function getEnvironmentVariable(name) {
159
159
  return undefined;
160
160
  }
161
161
  }
162
+ export function getLangSmithEnvironmentVariable(name) {
163
+ return (getEnvironmentVariable(`LANGSMITH_${name}`) ||
164
+ getEnvironmentVariable(`LANGCHAIN_${name}`));
165
+ }
162
166
  export function setEnvironmentVariable(name, value) {
163
167
  if (typeof process !== "undefined") {
164
168
  // eslint-disable-next-line no-process-env
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langsmith",
3
- "version": "0.1.40",
3
+ "version": "0.1.42",
4
4
  "description": "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform.",
5
5
  "packageManager": "yarn@1.22.19",
6
6
  "files": [