langsmith 0.0.29 → 0.0.32

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
@@ -298,7 +298,6 @@ class Client {
298
298
  body: JSON.stringify(data),
299
299
  signal: AbortSignal.timeout(this.timeout_ms),
300
300
  });
301
- // await raiseForStatus(response, "share run");
302
301
  const result = await response.json();
303
302
  if (result === null || !("share_token" in result)) {
304
303
  throw new Error("Invalid response from server");
@@ -319,7 +318,6 @@ class Client {
319
318
  headers: this.headers,
320
319
  signal: AbortSignal.timeout(this.timeout_ms),
321
320
  });
322
- // await raiseForStatus(response, "read run shared link");
323
321
  const result = await response.json();
324
322
  if (result === null || !("share_token" in result)) {
325
323
  return undefined;
@@ -375,8 +373,32 @@ class Client {
375
373
  }
376
374
  return result;
377
375
  }
378
- async *listProjects() {
379
- for await (const projects of this._getPaginated("/sessions")) {
376
+ async *listProjects({ projectIds, name, nameContains, referenceDatasetId, referenceDatasetName, referenceFree, } = {}) {
377
+ const params = new URLSearchParams();
378
+ if (projectIds !== undefined) {
379
+ for (const projectId of projectIds) {
380
+ params.append("id", projectId);
381
+ }
382
+ }
383
+ if (name !== undefined) {
384
+ params.append("name", name);
385
+ }
386
+ if (nameContains !== undefined) {
387
+ params.append("name_contains", nameContains);
388
+ }
389
+ if (referenceDatasetId !== undefined) {
390
+ params.append("reference_dataset", referenceDatasetId);
391
+ }
392
+ else if (referenceDatasetName !== undefined) {
393
+ const dataset = await this.readDataset({
394
+ datasetName: referenceDatasetName,
395
+ });
396
+ params.append("reference_dataset", dataset.id);
397
+ }
398
+ if (referenceFree !== undefined) {
399
+ params.append("reference_free", referenceFree.toString());
400
+ }
401
+ for await (const projects of this._getPaginated("/sessions", params)) {
380
402
  yield* projects;
381
403
  }
382
404
  }
package/dist/client.d.ts CHANGED
@@ -87,7 +87,14 @@ export declare class Client {
87
87
  projectId?: string;
88
88
  projectName?: string;
89
89
  }): Promise<TracerSessionResult>;
90
- listProjects(): AsyncIterable<TracerSession>;
90
+ listProjects({ projectIds, name, nameContains, referenceDatasetId, referenceDatasetName, referenceFree, }?: {
91
+ projectIds?: string[];
92
+ name?: string;
93
+ nameContains?: string;
94
+ referenceDatasetId?: string;
95
+ referenceDatasetName?: string;
96
+ referenceFree?: boolean;
97
+ }): AsyncIterable<TracerSession>;
91
98
  deleteProject({ projectId, projectName, }: {
92
99
  projectId?: string;
93
100
  projectName?: string;
package/dist/client.js CHANGED
@@ -272,7 +272,6 @@ export class Client {
272
272
  body: JSON.stringify(data),
273
273
  signal: AbortSignal.timeout(this.timeout_ms),
274
274
  });
275
- // await raiseForStatus(response, "share run");
276
275
  const result = await response.json();
277
276
  if (result === null || !("share_token" in result)) {
278
277
  throw new Error("Invalid response from server");
@@ -293,7 +292,6 @@ export class Client {
293
292
  headers: this.headers,
294
293
  signal: AbortSignal.timeout(this.timeout_ms),
295
294
  });
296
- // await raiseForStatus(response, "read run shared link");
297
295
  const result = await response.json();
298
296
  if (result === null || !("share_token" in result)) {
299
297
  return undefined;
@@ -349,8 +347,32 @@ export class Client {
349
347
  }
350
348
  return result;
351
349
  }
352
- async *listProjects() {
353
- for await (const projects of this._getPaginated("/sessions")) {
350
+ async *listProjects({ projectIds, name, nameContains, referenceDatasetId, referenceDatasetName, referenceFree, } = {}) {
351
+ const params = new URLSearchParams();
352
+ if (projectIds !== undefined) {
353
+ for (const projectId of projectIds) {
354
+ params.append("id", projectId);
355
+ }
356
+ }
357
+ if (name !== undefined) {
358
+ params.append("name", name);
359
+ }
360
+ if (nameContains !== undefined) {
361
+ params.append("name_contains", nameContains);
362
+ }
363
+ if (referenceDatasetId !== undefined) {
364
+ params.append("reference_dataset", referenceDatasetId);
365
+ }
366
+ else if (referenceDatasetName !== undefined) {
367
+ const dataset = await this.readDataset({
368
+ datasetName: referenceDatasetName,
369
+ });
370
+ params.append("reference_dataset", dataset.id);
371
+ }
372
+ if (referenceFree !== undefined) {
373
+ params.append("reference_free", referenceFree.toString());
374
+ }
375
+ for await (const projects of this._getPaginated("/sessions", params)) {
354
376
  yield* projects;
355
377
  }
356
378
  }
package/dist/schemas.d.ts CHANGED
@@ -61,6 +61,7 @@ export interface RunUpdate {
61
61
  end_time?: number;
62
62
  extra?: KVMap;
63
63
  error?: string;
64
+ inputs?: KVMap;
64
65
  outputs?: KVMap;
65
66
  parent_run_id?: string;
66
67
  reference_example_id?: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setEnvironmentVariable = exports.getEnvironmentVariable = exports.getRuntimeEnvironment = exports.getEnv = exports.isNode = exports.isDeno = exports.isJsDom = exports.isWebWorker = exports.isBrowser = void 0;
3
+ exports.getShas = exports.setEnvironmentVariable = exports.getEnvironmentVariable = exports.getRuntimeEnvironment = exports.getEnv = exports.isNode = exports.isDeno = exports.isJsDom = exports.isWebWorker = exports.isBrowser = void 0;
4
4
  const isBrowser = () => typeof window !== "undefined" && typeof window.document !== "undefined";
5
5
  exports.isBrowser = isBrowser;
6
6
  const isWebWorker = () => typeof globalThis === "object" &&
@@ -49,9 +49,11 @@ let runtimeEnvironment;
49
49
  async function getRuntimeEnvironment() {
50
50
  if (runtimeEnvironment === undefined) {
51
51
  const env = (0, exports.getEnv)();
52
+ const releaseEnv = getShas();
52
53
  runtimeEnvironment = {
53
54
  library: "langsmith",
54
55
  runtime: env,
56
+ ...releaseEnv,
55
57
  };
56
58
  }
57
59
  return runtimeEnvironment;
@@ -78,3 +80,45 @@ function setEnvironmentVariable(name, value) {
78
80
  }
79
81
  }
80
82
  exports.setEnvironmentVariable = setEnvironmentVariable;
83
+ let cachedCommitSHAs;
84
+ /**
85
+ * Get the Git commit SHA from common environment variables
86
+ * used by different CI/CD platforms.
87
+ * @returns {string | undefined} The Git commit SHA or undefined if not found.
88
+ */
89
+ function getShas() {
90
+ if (cachedCommitSHAs !== undefined) {
91
+ return cachedCommitSHAs;
92
+ }
93
+ const common_release_envs = [
94
+ "VERCEL_GIT_COMMIT_SHA",
95
+ "NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA",
96
+ "COMMIT_REF",
97
+ "RENDER_GIT_COMMIT",
98
+ "CI_COMMIT_SHA",
99
+ "CIRCLE_SHA1",
100
+ "CF_PAGES_COMMIT_SHA",
101
+ "REACT_APP_GIT_SHA",
102
+ "SOURCE_VERSION",
103
+ "GITHUB_SHA",
104
+ "TRAVIS_COMMIT",
105
+ "GIT_COMMIT",
106
+ "BUILD_VCS_NUMBER",
107
+ "bamboo_planRepository_revision",
108
+ "Build.SourceVersion",
109
+ "BITBUCKET_COMMIT",
110
+ "DRONE_COMMIT_SHA",
111
+ "SEMAPHORE_GIT_SHA",
112
+ "BUILDKITE_COMMIT",
113
+ ];
114
+ const shas = {};
115
+ for (const env of common_release_envs) {
116
+ const envVar = getEnvironmentVariable(env);
117
+ if (envVar !== undefined) {
118
+ shas[env] = envVar;
119
+ }
120
+ }
121
+ cachedCommitSHAs = shas;
122
+ return shas;
123
+ }
124
+ exports.getShas = getShas;
@@ -20,3 +20,13 @@ export type RuntimeEnvironment = {
20
20
  export declare function getRuntimeEnvironment(): Promise<RuntimeEnvironment>;
21
21
  export declare function getEnvironmentVariable(name: string): string | undefined;
22
22
  export declare function setEnvironmentVariable(name: string, value: string): void;
23
+ interface ICommitSHAs {
24
+ [key: string]: string;
25
+ }
26
+ /**
27
+ * Get the Git commit SHA from common environment variables
28
+ * used by different CI/CD platforms.
29
+ * @returns {string | undefined} The Git commit SHA or undefined if not found.
30
+ */
31
+ export declare function getShas(): ICommitSHAs;
32
+ export {};
package/dist/utils/env.js CHANGED
@@ -40,9 +40,11 @@ let runtimeEnvironment;
40
40
  export async function getRuntimeEnvironment() {
41
41
  if (runtimeEnvironment === undefined) {
42
42
  const env = getEnv();
43
+ const releaseEnv = getShas();
43
44
  runtimeEnvironment = {
44
45
  library: "langsmith",
45
46
  runtime: env,
47
+ ...releaseEnv,
46
48
  };
47
49
  }
48
50
  return runtimeEnvironment;
@@ -66,3 +68,44 @@ export function setEnvironmentVariable(name, value) {
66
68
  process.env[name] = value;
67
69
  }
68
70
  }
71
+ let cachedCommitSHAs;
72
+ /**
73
+ * Get the Git commit SHA from common environment variables
74
+ * used by different CI/CD platforms.
75
+ * @returns {string | undefined} The Git commit SHA or undefined if not found.
76
+ */
77
+ export function getShas() {
78
+ if (cachedCommitSHAs !== undefined) {
79
+ return cachedCommitSHAs;
80
+ }
81
+ const common_release_envs = [
82
+ "VERCEL_GIT_COMMIT_SHA",
83
+ "NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA",
84
+ "COMMIT_REF",
85
+ "RENDER_GIT_COMMIT",
86
+ "CI_COMMIT_SHA",
87
+ "CIRCLE_SHA1",
88
+ "CF_PAGES_COMMIT_SHA",
89
+ "REACT_APP_GIT_SHA",
90
+ "SOURCE_VERSION",
91
+ "GITHUB_SHA",
92
+ "TRAVIS_COMMIT",
93
+ "GIT_COMMIT",
94
+ "BUILD_VCS_NUMBER",
95
+ "bamboo_planRepository_revision",
96
+ "Build.SourceVersion",
97
+ "BITBUCKET_COMMIT",
98
+ "DRONE_COMMIT_SHA",
99
+ "SEMAPHORE_GIT_SHA",
100
+ "BUILDKITE_COMMIT",
101
+ ];
102
+ const shas = {};
103
+ for (const env of common_release_envs) {
104
+ const envVar = getEnvironmentVariable(env);
105
+ if (envVar !== undefined) {
106
+ shas[env] = envVar;
107
+ }
108
+ }
109
+ cachedCommitSHAs = shas;
110
+ return shas;
111
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langsmith",
3
- "version": "0.0.29",
3
+ "version": "0.0.32",
4
4
  "description": "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform.",
5
5
  "files": [
6
6
  "dist/",