langsmith 0.0.43 → 0.0.44

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.
@@ -7,6 +7,7 @@ services:
7
7
  - PORT=1985
8
8
  - LANGCHAIN_ENV=local_docker
9
9
  - LOG_LEVEL=warning
10
+ - LANGSMITH_LICENSE_KEY=${LANGSMITH_LICENSE_KEY}
10
11
  ports:
11
12
  - 1985:1985
12
13
  depends_on:
@@ -1,11 +1,13 @@
1
1
  version: '3'
2
2
  services:
3
+ # TODO: Move to the regular docker-compose.yaml once deployed
3
4
  langchain-hub:
4
5
  image: langchain/${_LANGSMITH_IMAGE_PREFIX-}langchainhub-backend:latest
5
6
  environment:
6
7
  - PORT=1985
7
8
  - LANGCHAIN_ENV=local_docker
8
9
  - LOG_LEVEL=warning
10
+ - LANGSMITH_LICENSE_KEY=${LANGSMITH_LICENSE_KEY}
9
11
  ports:
10
12
  - 1985:1985
11
13
  depends_on:
@@ -16,6 +16,7 @@ services:
16
16
  - LANGCHAIN_ENV=local_docker
17
17
  - LOG_LEVEL=warning
18
18
  - OPENAI_API_KEY=${OPENAI_API_KEY}
19
+ - LANGSMITH_LICENSE_KEY=${LANGSMITH_LICENSE_KEY}
19
20
  ports:
20
21
  - 1984:1984
21
22
  depends_on:
@@ -26,6 +27,7 @@ services:
26
27
  environment:
27
28
  - LANGCHAIN_ENV=local_docker
28
29
  - LOG_LEVEL=warning
30
+ - LANGSMITH_LICENSE_KEY=${LANGSMITH_LICENSE_KEY}
29
31
  entrypoint: "rq worker --with-scheduler -u redis://langchain-redis:6379 --serializer lc_database.queue.serializer.ORJSONSerializer --worker-class lc_database.queue.worker.Worker --connection-class lc_database.queue.connection.RedisRetry --job-class lc_database.queue.job.AsyncJob"
30
32
  langchain-hub:
31
33
  image: langchain/${_LANGSMITH_IMAGE_PREFIX-}langchainhub-backend:latest
@@ -33,6 +35,7 @@ services:
33
35
  - PORT=1985
34
36
  - LANGCHAIN_ENV=local_docker
35
37
  - LOG_LEVEL=warning
38
+ - LANGSMITH_LICENSE_KEY=${LANGSMITH_LICENSE_KEY}
36
39
  ports:
37
40
  - 1985:1985
38
41
  depends_on:
package/dist/cli/main.cjs CHANGED
@@ -24,12 +24,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  return result;
25
25
  };
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
+ const child_process = __importStar(require("child_process"));
27
28
  const fs = __importStar(require("fs"));
28
29
  const path = __importStar(require("path"));
29
30
  const util = __importStar(require("util"));
30
- const commander_1 = require("commander");
31
- const child_process = __importStar(require("child_process"));
32
31
  const env_js_1 = require("../utils/env.cjs");
32
+ const commander_1 = require("commander");
33
33
  const child_process_1 = require("child_process");
34
34
  const currentFileName = __filename;
35
35
  const currentDirName = __dirname;
@@ -308,6 +308,9 @@ const startCommand = new commander_1.Command("start")
308
308
  .option("--openai-api-key <openaiApiKey>", "Your OpenAI API key. If not provided, the OpenAI API Key will be read" +
309
309
  " from the OPENAI_API_KEY environment variable. If neither are provided," +
310
310
  " some features of LangSmith will not be available.")
311
+ .option("--langsmith-license-key <langsmithLicenseKey>", "The LangSmith license key to use for LangSmith. If not provided, the LangSmith" +
312
+ " License Key will be read from the LANGSMITH_LICENSE_KEY environment variable." +
313
+ " If neither are provided, the Langsmith application will not spin up.")
311
314
  .action(async (args) => {
312
315
  const smith = await SmithCommand.create();
313
316
  if (args.stage === "dev") {
@@ -319,6 +322,9 @@ const startCommand = new commander_1.Command("start")
319
322
  if (args.openaiApiKey) {
320
323
  (0, env_js_1.setEnvironmentVariable)("OPENAI_API_KEY", args.openaiApiKey);
321
324
  }
325
+ if (args.langsmithLicenseKey) {
326
+ (0, env_js_1.setEnvironmentVariable)("LANGSMITH_LICENSE_KEY", args.langsmithLicenseKey);
327
+ }
322
328
  await smith.pull({ stage: args.stage });
323
329
  if (args.expose) {
324
330
  await smith.startAndExpose(args.ngrokAuthtoken, args.stage);
package/dist/cli/main.js CHANGED
@@ -1,9 +1,9 @@
1
+ import * as child_process from "child_process";
1
2
  import * as fs from "fs";
2
3
  import * as path from "path";
3
4
  import * as util from "util";
4
- import { Command } from "commander";
5
- import * as child_process from "child_process";
6
5
  import { getLangChainEnvVars, getRuntimeEnvironment, setEnvironmentVariable, } from "../utils/env.js";
6
+ import { Command } from "commander";
7
7
  import { spawn } from "child_process";
8
8
  const currentFileName = __filename;
9
9
  const currentDirName = __dirname;
@@ -282,6 +282,9 @@ const startCommand = new Command("start")
282
282
  .option("--openai-api-key <openaiApiKey>", "Your OpenAI API key. If not provided, the OpenAI API Key will be read" +
283
283
  " from the OPENAI_API_KEY environment variable. If neither are provided," +
284
284
  " some features of LangSmith will not be available.")
285
+ .option("--langsmith-license-key <langsmithLicenseKey>", "The LangSmith license key to use for LangSmith. If not provided, the LangSmith" +
286
+ " License Key will be read from the LANGSMITH_LICENSE_KEY environment variable." +
287
+ " If neither are provided, the Langsmith application will not spin up.")
285
288
  .action(async (args) => {
286
289
  const smith = await SmithCommand.create();
287
290
  if (args.stage === "dev") {
@@ -293,6 +296,9 @@ const startCommand = new Command("start")
293
296
  if (args.openaiApiKey) {
294
297
  setEnvironmentVariable("OPENAI_API_KEY", args.openaiApiKey);
295
298
  }
299
+ if (args.langsmithLicenseKey) {
300
+ setEnvironmentVariable("LANGSMITH_LICENSE_KEY", args.langsmithLicenseKey);
301
+ }
296
302
  await smith.pull({ stage: args.stage });
297
303
  if (args.expose) {
298
304
  await smith.startAndExpose(args.ngrokAuthtoken, args.stage);
package/dist/cli/main.ts CHANGED
@@ -1,13 +1,15 @@
1
+ import * as child_process from "child_process";
1
2
  import * as fs from "fs";
2
3
  import * as path from "path";
3
4
  import * as util from "util";
4
- import { Command } from "commander";
5
- import * as child_process from "child_process";
5
+
6
6
  import {
7
7
  getLangChainEnvVars,
8
8
  getRuntimeEnvironment,
9
9
  setEnvironmentVariable,
10
10
  } from "../utils/env.js";
11
+
12
+ import { Command } from "commander";
11
13
  import { spawn } from "child_process";
12
14
 
13
15
  const currentFileName = __filename;
@@ -330,6 +332,12 @@ const startCommand = new Command("start")
330
332
  " from the OPENAI_API_KEY environment variable. If neither are provided," +
331
333
  " some features of LangSmith will not be available."
332
334
  )
335
+ .option(
336
+ "--langsmith-license-key <langsmithLicenseKey>",
337
+ "The LangSmith license key to use for LangSmith. If not provided, the LangSmith" +
338
+ " License Key will be read from the LANGSMITH_LICENSE_KEY environment variable." +
339
+ " If neither are provided, the Langsmith application will not spin up."
340
+ )
333
341
  .action(async (args) => {
334
342
  const smith = await SmithCommand.create();
335
343
  if (args.stage === "dev") {
@@ -340,6 +348,9 @@ const startCommand = new Command("start")
340
348
  if (args.openaiApiKey) {
341
349
  setEnvironmentVariable("OPENAI_API_KEY", args.openaiApiKey);
342
350
  }
351
+ if (args.langsmithLicenseKey) {
352
+ setEnvironmentVariable("LANGSMITH_LICENSE_KEY", args.langsmithLicenseKey);
353
+ }
343
354
  await smith.pull({ stage: args.stage });
344
355
  if (args.expose) {
345
356
  await smith.startAndExpose(args.ngrokAuthtoken, args.stage);
package/dist/client.cjs CHANGED
@@ -414,6 +414,61 @@ class Client {
414
414
  const runs = await response.json();
415
415
  return runs;
416
416
  }
417
+ async readDatasetSharedSchema(datasetId, datasetName) {
418
+ if (!datasetId && !datasetName) {
419
+ throw new Error("Either datasetId or datasetName must be given");
420
+ }
421
+ if (!datasetId) {
422
+ const dataset = await this.readDataset({ datasetName });
423
+ datasetId = dataset.id;
424
+ }
425
+ const response = await this.caller.call(fetch, `${this.apiUrl}/datasets/${datasetId}/share`, {
426
+ method: "GET",
427
+ headers: this.headers,
428
+ signal: AbortSignal.timeout(this.timeout_ms),
429
+ });
430
+ const shareSchema = await response.json();
431
+ shareSchema.url = `${this.getHostUrl()}/public/${shareSchema.share_token}/d`;
432
+ return shareSchema;
433
+ }
434
+ async shareDataset(datasetId, datasetName) {
435
+ if (!datasetId && !datasetName) {
436
+ throw new Error("Either datasetId or datasetName must be given");
437
+ }
438
+ if (!datasetId) {
439
+ const dataset = await this.readDataset({ datasetName });
440
+ datasetId = dataset.id;
441
+ }
442
+ const data = {
443
+ dataset_id: datasetId,
444
+ };
445
+ const response = await this.caller.call(fetch, `${this.apiUrl}/datasets/${datasetId}/share`, {
446
+ method: "PUT",
447
+ headers: this.headers,
448
+ body: JSON.stringify(data),
449
+ signal: AbortSignal.timeout(this.timeout_ms),
450
+ });
451
+ const shareSchema = await response.json();
452
+ shareSchema.url = `${this.getHostUrl()}/public/${shareSchema.share_token}/d`;
453
+ return shareSchema;
454
+ }
455
+ async unshareDataset(datasetId) {
456
+ const response = await this.caller.call(fetch, `${this.apiUrl}/datasets/${datasetId}/share`, {
457
+ method: "DELETE",
458
+ headers: this.headers,
459
+ signal: AbortSignal.timeout(this.timeout_ms),
460
+ });
461
+ await raiseForStatus(response, "unshare dataset");
462
+ }
463
+ async readSharedDataset(shareToken) {
464
+ const response = await this.caller.call(fetch, `${this.apiUrl}/public/${shareToken}/datasets`, {
465
+ method: "GET",
466
+ headers: this.headers,
467
+ signal: AbortSignal.timeout(this.timeout_ms),
468
+ });
469
+ const dataset = await response.json();
470
+ return dataset;
471
+ }
417
472
  async createProject({ projectName, projectExtra, upsert, referenceDatasetId, }) {
418
473
  const upsert_ = upsert ? `?upsert=true` : "";
419
474
  const endpoint = `${this.apiUrl}/sessions${upsert_}`;
@@ -812,7 +867,7 @@ class Client {
812
867
  feedbackSourceType: "model",
813
868
  });
814
869
  }
815
- async createFeedback(runId, key, { score, value, correction, comment, sourceInfo, feedbackSourceType = "api", sourceRunId, feedbackId, }) {
870
+ async createFeedback(runId, key, { score, value, correction, comment, sourceInfo, feedbackSourceType = "api", sourceRunId, feedbackId, eager = false, }) {
816
871
  const feedback_source = {
817
872
  type: feedbackSourceType ?? "api",
818
873
  metadata: sourceInfo ?? {},
@@ -832,7 +887,8 @@ class Client {
832
887
  comment,
833
888
  feedback_source: feedback_source,
834
889
  };
835
- const response = await this.caller.call(fetch, `${this.apiUrl}/feedback`, {
890
+ const url = `${this.apiUrl}/feedback` + (eager ? "/eager" : "");
891
+ const response = await this.caller.call(fetch, url, {
836
892
  method: "POST",
837
893
  headers: { ...this.headers, "Content-Type": "application/json" },
838
894
  body: JSON.stringify(feedback),
package/dist/client.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AsyncCallerParams } from "./utils/async_caller.js";
2
- import { DataType, Dataset, Example, ExampleUpdate, Feedback, KVMap, LangChainBaseMessage, Run, RunCreate, RunUpdate, ScoreType, TracerSession, TracerSessionResult, ValueType } from "./schemas.js";
2
+ import { DataType, Dataset, DatasetShareSchema, Example, ExampleUpdate, Feedback, KVMap, LangChainBaseMessage, Run, RunCreate, RunUpdate, ScoreType, TracerSession, TracerSessionResult, ValueType } from "./schemas.js";
3
3
  import { RunEvaluator } from "./evaluation/evaluator.js";
4
4
  interface ClientConfig {
5
5
  apiUrl?: string;
@@ -99,6 +99,10 @@ export declare class Client {
99
99
  listSharedRuns(shareToken: string, { runIds, }?: {
100
100
  runIds?: string[];
101
101
  }): Promise<Run[]>;
102
+ readDatasetSharedSchema(datasetId?: string, datasetName?: string): Promise<DatasetShareSchema>;
103
+ shareDataset(datasetId?: string, datasetName?: string): Promise<DatasetShareSchema>;
104
+ unshareDataset(datasetId: string): Promise<void>;
105
+ readSharedDataset(shareToken: string): Promise<Dataset>;
102
106
  createProject({ projectName, projectExtra, upsert, referenceDatasetId, }: {
103
107
  projectName: string;
104
108
  projectExtra?: object;
@@ -161,7 +165,7 @@ export declare class Client {
161
165
  sourceInfo?: KVMap;
162
166
  loadChildRuns: boolean;
163
167
  }): Promise<Feedback>;
164
- createFeedback(runId: string, key: string, { score, value, correction, comment, sourceInfo, feedbackSourceType, sourceRunId, feedbackId, }: {
168
+ createFeedback(runId: string, key: string, { score, value, correction, comment, sourceInfo, feedbackSourceType, sourceRunId, feedbackId, eager, }: {
165
169
  score?: ScoreType;
166
170
  value?: ValueType;
167
171
  correction?: object;
@@ -170,6 +174,7 @@ export declare class Client {
170
174
  feedbackSourceType?: FeedbackSourceType;
171
175
  sourceRunId?: string;
172
176
  feedbackId?: string;
177
+ eager?: boolean;
173
178
  }): Promise<Feedback>;
174
179
  updateFeedback(feedbackId: string, { score, value, correction, comment, }: {
175
180
  score?: number | boolean | null;
package/dist/client.js CHANGED
@@ -388,6 +388,61 @@ export class Client {
388
388
  const runs = await response.json();
389
389
  return runs;
390
390
  }
391
+ async readDatasetSharedSchema(datasetId, datasetName) {
392
+ if (!datasetId && !datasetName) {
393
+ throw new Error("Either datasetId or datasetName must be given");
394
+ }
395
+ if (!datasetId) {
396
+ const dataset = await this.readDataset({ datasetName });
397
+ datasetId = dataset.id;
398
+ }
399
+ const response = await this.caller.call(fetch, `${this.apiUrl}/datasets/${datasetId}/share`, {
400
+ method: "GET",
401
+ headers: this.headers,
402
+ signal: AbortSignal.timeout(this.timeout_ms),
403
+ });
404
+ const shareSchema = await response.json();
405
+ shareSchema.url = `${this.getHostUrl()}/public/${shareSchema.share_token}/d`;
406
+ return shareSchema;
407
+ }
408
+ async shareDataset(datasetId, datasetName) {
409
+ if (!datasetId && !datasetName) {
410
+ throw new Error("Either datasetId or datasetName must be given");
411
+ }
412
+ if (!datasetId) {
413
+ const dataset = await this.readDataset({ datasetName });
414
+ datasetId = dataset.id;
415
+ }
416
+ const data = {
417
+ dataset_id: datasetId,
418
+ };
419
+ const response = await this.caller.call(fetch, `${this.apiUrl}/datasets/${datasetId}/share`, {
420
+ method: "PUT",
421
+ headers: this.headers,
422
+ body: JSON.stringify(data),
423
+ signal: AbortSignal.timeout(this.timeout_ms),
424
+ });
425
+ const shareSchema = await response.json();
426
+ shareSchema.url = `${this.getHostUrl()}/public/${shareSchema.share_token}/d`;
427
+ return shareSchema;
428
+ }
429
+ async unshareDataset(datasetId) {
430
+ const response = await this.caller.call(fetch, `${this.apiUrl}/datasets/${datasetId}/share`, {
431
+ method: "DELETE",
432
+ headers: this.headers,
433
+ signal: AbortSignal.timeout(this.timeout_ms),
434
+ });
435
+ await raiseForStatus(response, "unshare dataset");
436
+ }
437
+ async readSharedDataset(shareToken) {
438
+ const response = await this.caller.call(fetch, `${this.apiUrl}/public/${shareToken}/datasets`, {
439
+ method: "GET",
440
+ headers: this.headers,
441
+ signal: AbortSignal.timeout(this.timeout_ms),
442
+ });
443
+ const dataset = await response.json();
444
+ return dataset;
445
+ }
391
446
  async createProject({ projectName, projectExtra, upsert, referenceDatasetId, }) {
392
447
  const upsert_ = upsert ? `?upsert=true` : "";
393
448
  const endpoint = `${this.apiUrl}/sessions${upsert_}`;
@@ -786,7 +841,7 @@ export class Client {
786
841
  feedbackSourceType: "model",
787
842
  });
788
843
  }
789
- async createFeedback(runId, key, { score, value, correction, comment, sourceInfo, feedbackSourceType = "api", sourceRunId, feedbackId, }) {
844
+ async createFeedback(runId, key, { score, value, correction, comment, sourceInfo, feedbackSourceType = "api", sourceRunId, feedbackId, eager = false, }) {
790
845
  const feedback_source = {
791
846
  type: feedbackSourceType ?? "api",
792
847
  metadata: sourceInfo ?? {},
@@ -806,7 +861,8 @@ export class Client {
806
861
  comment,
807
862
  feedback_source: feedback_source,
808
863
  };
809
- const response = await this.caller.call(fetch, `${this.apiUrl}/feedback`, {
864
+ const url = `${this.apiUrl}/feedback` + (eager ? "/eager" : "");
865
+ const response = await this.caller.call(fetch, url, {
810
866
  method: "POST",
811
867
  headers: { ...this.headers, "Content-Type": "application/json" },
812
868
  body: JSON.stringify(feedback),
package/dist/schemas.d.ts CHANGED
@@ -151,6 +151,14 @@ export interface Dataset extends BaseDataset {
151
151
  id: string;
152
152
  created_at: string;
153
153
  modified_at: string;
154
+ example_count?: number;
155
+ session_count?: number;
156
+ last_session_start_time?: number;
157
+ }
158
+ export interface DatasetShareSchema {
159
+ dataset_id: string;
160
+ share_token: string;
161
+ url: string;
154
162
  }
155
163
  export interface FeedbackSourceBase {
156
164
  type: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langsmith",
3
- "version": "0.0.43",
3
+ "version": "0.0.44",
4
4
  "description": "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform.",
5
5
  "files": [
6
6
  "dist/",