langsmith 0.0.1 → 0.0.3

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.
@@ -1,5 +1,7 @@
1
1
  version: "3"
2
2
  services:
3
+ langchain-playground:
4
+ image: langchain/${_LANGCHAINPLUS_IMAGE_PREFIX-}langchainplus-playground:latest
3
5
  langchain-frontend:
4
6
  image: langchain/${_LANGCHAINPLUS_IMAGE_PREFIX-}langchainplus-frontend:latest
5
7
  ports:
@@ -8,6 +10,7 @@ services:
8
10
  - REACT_APP_BACKEND_URL=http://localhost:1984
9
11
  depends_on:
10
12
  - langchain-backend
13
+ - langchain-playground
11
14
  volumes:
12
15
  - ./conf/nginx.conf:/etc/nginx/default.conf:ro
13
16
  langchain-backend:
package/dist/cli/main.cjs CHANGED
@@ -163,6 +163,7 @@ class PlusCommand {
163
163
  if (args.openaiApiKey) {
164
164
  (0, env_js_1.setEnvironmentVariable)("OPENAI_API_KEY", args.openaiApiKey);
165
165
  }
166
+ await this.pull(args);
166
167
  if (args.expose) {
167
168
  await this.startAndExpose(args.ngrokAuthtoken);
168
169
  }
@@ -188,7 +189,6 @@ class PlusCommand {
188
189
  "-f",
189
190
  this.dockerComposeFile,
190
191
  "up",
191
- "--pull=always",
192
192
  "--quiet-pull",
193
193
  "--wait",
194
194
  ];
@@ -205,7 +205,6 @@ class PlusCommand {
205
205
  "-f",
206
206
  this.ngrokPath,
207
207
  "up",
208
- "--pull=always",
209
208
  "--quiet-pull",
210
209
  "--wait",
211
210
  ];
package/dist/cli/main.js CHANGED
@@ -137,6 +137,7 @@ class PlusCommand {
137
137
  if (args.openaiApiKey) {
138
138
  setEnvironmentVariable("OPENAI_API_KEY", args.openaiApiKey);
139
139
  }
140
+ await this.pull(args);
140
141
  if (args.expose) {
141
142
  await this.startAndExpose(args.ngrokAuthtoken);
142
143
  }
@@ -162,7 +163,6 @@ class PlusCommand {
162
163
  "-f",
163
164
  this.dockerComposeFile,
164
165
  "up",
165
- "--pull=always",
166
166
  "--quiet-pull",
167
167
  "--wait",
168
168
  ];
@@ -179,7 +179,6 @@ class PlusCommand {
179
179
  "-f",
180
180
  this.ngrokPath,
181
181
  "up",
182
- "--pull=always",
183
182
  "--quiet-pull",
184
183
  "--wait",
185
184
  ];
package/dist/cli/main.ts CHANGED
@@ -151,7 +151,7 @@ class PlusCommand {
151
151
  if (args.openaiApiKey) {
152
152
  setEnvironmentVariable("OPENAI_API_KEY", args.openaiApiKey);
153
153
  }
154
-
154
+ await this.pull(args);
155
155
  if (args.expose) {
156
156
  await this.startAndExpose(args.ngrokAuthtoken);
157
157
  } else {
@@ -179,7 +179,6 @@ class PlusCommand {
179
179
  "-f",
180
180
  this.dockerComposeFile,
181
181
  "up",
182
- "--pull=always",
183
182
  "--quiet-pull",
184
183
  "--wait",
185
184
  ];
@@ -199,7 +198,6 @@ class PlusCommand {
199
198
  "-f",
200
199
  this.ngrokPath,
201
200
  "up",
202
- "--pull=always",
203
201
  "--quiet-pull",
204
202
  "--wait",
205
203
  ];
package/dist/client.cjs CHANGED
@@ -214,7 +214,7 @@ class Client {
214
214
  });
215
215
  await raiseForStatus(response, "delete run");
216
216
  }
217
- async createProject({ projectName, projectExtra, mode, upsert, }) {
217
+ async createProject({ projectName, projectExtra, upsert, }) {
218
218
  const upsert_ = upsert ? `?upsert=true` : "";
219
219
  const endpoint = `${this.apiUrl}/sessions${upsert_}`;
220
220
  const body = {
@@ -223,9 +223,6 @@ class Client {
223
223
  if (projectExtra !== undefined) {
224
224
  body["extra"] = projectExtra;
225
225
  }
226
- if (mode !== undefined) {
227
- body["mode"] = mode;
228
- }
229
226
  const response = await this.caller.call(fetch, endpoint, {
230
227
  method: "POST",
231
228
  headers: { ...this.headers, "Content-Type": "application/json" },
@@ -290,15 +287,25 @@ class Client {
290
287
  });
291
288
  await raiseForStatus(response, `delete session ${projectId_} (${projectName})`);
292
289
  }
293
- async uploadCsv({ csvFile, fileName, inputKeys, outputKeys, description, }) {
290
+ async uploadCsv({ csvFile, fileName, inputKeys, outputKeys, description, dataType, name, }) {
294
291
  const url = `${this.apiUrl}/datasets/upload`;
295
292
  const formData = new FormData();
296
293
  formData.append("file", csvFile, fileName);
297
- formData.append("input_keys", inputKeys.join(","));
298
- formData.append("output_keys", outputKeys.join(","));
294
+ inputKeys.forEach((key) => {
295
+ formData.append("input_keys", key);
296
+ });
297
+ outputKeys.forEach((key) => {
298
+ formData.append("output_keys", key);
299
+ });
299
300
  if (description) {
300
301
  formData.append("description", description);
301
302
  }
303
+ if (dataType) {
304
+ formData.append("data_type", dataType);
305
+ }
306
+ if (name) {
307
+ formData.append("name", name);
308
+ }
302
309
  const response = await this.caller.call(fetch, url, {
303
310
  method: "POST",
304
311
  headers: this.headers,
@@ -315,14 +322,18 @@ class Client {
315
322
  const result = await response.json();
316
323
  return result;
317
324
  }
318
- async createDataset(name, { description } = {}) {
325
+ async createDataset(name, { description, dataType, } = {}) {
326
+ const body = {
327
+ name,
328
+ description,
329
+ };
330
+ if (dataType) {
331
+ body.data_type = dataType;
332
+ }
319
333
  const response = await this.caller.call(fetch, `${this.apiUrl}/datasets`, {
320
334
  method: "POST",
321
335
  headers: { ...this.headers, "Content-Type": "application/json" },
322
- body: JSON.stringify({
323
- name,
324
- description,
325
- }),
336
+ body: JSON.stringify(body),
326
337
  signal: AbortSignal.timeout(this.timeout_ms),
327
338
  });
328
339
  if (!response.ok) {
@@ -400,8 +411,7 @@ class Client {
400
411
  if (!response.ok) {
401
412
  throw new Error(`Failed to delete ${path}: ${response.status} ${response.statusText}`);
402
413
  }
403
- const results = await response.json();
404
- return results;
414
+ await response.json();
405
415
  }
406
416
  async createExample(inputs, outputs, { datasetId, datasetName, createdAt, }) {
407
417
  let datasetId_ = datasetId;
@@ -473,8 +483,7 @@ class Client {
473
483
  if (!response.ok) {
474
484
  throw new Error(`Failed to delete ${path}: ${response.status} ${response.statusText}`);
475
485
  }
476
- const result = await response.json();
477
- return result;
486
+ await response.json();
478
487
  }
479
488
  async updateExample(exampleId, update) {
480
489
  const response = await this.caller.call(fetch, `${this.apiUrl}/examples/${exampleId}`, {
@@ -567,8 +576,7 @@ class Client {
567
576
  if (!response.ok) {
568
577
  throw new Error(`Failed to delete ${path}: ${response.status} ${response.statusText}`);
569
578
  }
570
- const result = await response.json();
571
- return result;
579
+ await response.json();
572
580
  }
573
581
  async listFeedback({ runIds, limit, offset, } = {}) {
574
582
  const queryParams = new URLSearchParams();
package/dist/client.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AsyncCallerParams } from "./utils/async_caller.js";
2
- import { Dataset, Example, ExampleUpdate, Feedback, KVMap, Run, RunCreate, RunType, RunUpdate, ScoreType, TracerSession, TracerSessionResult, ValueType } from "./schemas.js";
2
+ import { Dataset, Example, ExampleUpdate, Feedback, KVMap, Run, RunCreate, RunType, RunUpdate, ScoreType, TracerSession, TracerSessionResult, ValueType, DataType } from "./schemas.js";
3
3
  import { RunEvaluator } from "./evaluation/evaluator.js";
4
4
  interface ClientConfig {
5
5
  apiUrl?: string;
@@ -23,6 +23,8 @@ interface UploadCSVParams {
23
23
  inputKeys: string[];
24
24
  outputKeys: string[];
25
25
  description?: string;
26
+ dataType?: DataType;
27
+ name?: string;
26
28
  }
27
29
  interface CreateRunParams {
28
30
  name: string;
@@ -62,10 +64,9 @@ export declare class Client {
62
64
  private _loadChildRuns;
63
65
  listRuns({ projectId, projectName, executionOrder, runType, error, id, limit, offset, }: ListRunsParams): Promise<Run[]>;
64
66
  deleteRun(runId: string): Promise<void>;
65
- createProject({ projectName, projectExtra, mode, upsert, }: {
67
+ createProject({ projectName, projectExtra, upsert, }: {
66
68
  projectName: string;
67
69
  projectExtra?: object;
68
- mode?: string;
69
70
  upsert?: boolean;
70
71
  }): Promise<TracerSession>;
71
72
  readProject({ projectId, projectName, }: {
@@ -77,9 +78,10 @@ export declare class Client {
77
78
  projectId?: string;
78
79
  projectName?: string;
79
80
  }): Promise<void>;
80
- uploadCsv({ csvFile, fileName, inputKeys, outputKeys, description, }: UploadCSVParams): Promise<Dataset>;
81
- createDataset(name: string, { description }?: {
81
+ uploadCsv({ csvFile, fileName, inputKeys, outputKeys, description, dataType, name, }: UploadCSVParams): Promise<Dataset>;
82
+ createDataset(name: string, { description, dataType, }?: {
82
83
  description?: string;
84
+ dataType?: DataType;
83
85
  }): Promise<Dataset>;
84
86
  readDataset({ datasetId, datasetName, }: {
85
87
  datasetId?: string;
@@ -92,7 +94,7 @@ export declare class Client {
92
94
  deleteDataset({ datasetId, datasetName, }: {
93
95
  datasetId?: string;
94
96
  datasetName?: string;
95
- }): Promise<Dataset>;
97
+ }): Promise<void>;
96
98
  createExample(inputs: KVMap, outputs: KVMap, { datasetId, datasetName, createdAt, }: {
97
99
  datasetId?: string;
98
100
  datasetName?: string;
@@ -105,7 +107,7 @@ export declare class Client {
105
107
  limit?: number;
106
108
  offset?: number;
107
109
  }): Promise<Example[]>;
108
- deleteExample(exampleId: string): Promise<Example>;
110
+ deleteExample(exampleId: string): Promise<void>;
109
111
  updateExample(exampleId: string, update: ExampleUpdate): Promise<object>;
110
112
  evaluateRun(run: Run | string, evaluator: RunEvaluator, { sourceInfo, loadChildRuns, }?: {
111
113
  sourceInfo?: KVMap;
@@ -120,7 +122,7 @@ export declare class Client {
120
122
  feedbackSourceType?: "API" | "MODEL";
121
123
  }): Promise<Feedback>;
122
124
  readFeedback(feedbackId: string): Promise<Feedback>;
123
- deleteFeedback(feedbackId: string): Promise<Feedback>;
125
+ deleteFeedback(feedbackId: string): Promise<void>;
124
126
  listFeedback({ runIds, limit, offset, }?: {
125
127
  runIds?: string[];
126
128
  limit?: number;
package/dist/client.js CHANGED
@@ -188,7 +188,7 @@ export class Client {
188
188
  });
189
189
  await raiseForStatus(response, "delete run");
190
190
  }
191
- async createProject({ projectName, projectExtra, mode, upsert, }) {
191
+ async createProject({ projectName, projectExtra, upsert, }) {
192
192
  const upsert_ = upsert ? `?upsert=true` : "";
193
193
  const endpoint = `${this.apiUrl}/sessions${upsert_}`;
194
194
  const body = {
@@ -197,9 +197,6 @@ export class Client {
197
197
  if (projectExtra !== undefined) {
198
198
  body["extra"] = projectExtra;
199
199
  }
200
- if (mode !== undefined) {
201
- body["mode"] = mode;
202
- }
203
200
  const response = await this.caller.call(fetch, endpoint, {
204
201
  method: "POST",
205
202
  headers: { ...this.headers, "Content-Type": "application/json" },
@@ -264,15 +261,25 @@ export class Client {
264
261
  });
265
262
  await raiseForStatus(response, `delete session ${projectId_} (${projectName})`);
266
263
  }
267
- async uploadCsv({ csvFile, fileName, inputKeys, outputKeys, description, }) {
264
+ async uploadCsv({ csvFile, fileName, inputKeys, outputKeys, description, dataType, name, }) {
268
265
  const url = `${this.apiUrl}/datasets/upload`;
269
266
  const formData = new FormData();
270
267
  formData.append("file", csvFile, fileName);
271
- formData.append("input_keys", inputKeys.join(","));
272
- formData.append("output_keys", outputKeys.join(","));
268
+ inputKeys.forEach((key) => {
269
+ formData.append("input_keys", key);
270
+ });
271
+ outputKeys.forEach((key) => {
272
+ formData.append("output_keys", key);
273
+ });
273
274
  if (description) {
274
275
  formData.append("description", description);
275
276
  }
277
+ if (dataType) {
278
+ formData.append("data_type", dataType);
279
+ }
280
+ if (name) {
281
+ formData.append("name", name);
282
+ }
276
283
  const response = await this.caller.call(fetch, url, {
277
284
  method: "POST",
278
285
  headers: this.headers,
@@ -289,14 +296,18 @@ export class Client {
289
296
  const result = await response.json();
290
297
  return result;
291
298
  }
292
- async createDataset(name, { description } = {}) {
299
+ async createDataset(name, { description, dataType, } = {}) {
300
+ const body = {
301
+ name,
302
+ description,
303
+ };
304
+ if (dataType) {
305
+ body.data_type = dataType;
306
+ }
293
307
  const response = await this.caller.call(fetch, `${this.apiUrl}/datasets`, {
294
308
  method: "POST",
295
309
  headers: { ...this.headers, "Content-Type": "application/json" },
296
- body: JSON.stringify({
297
- name,
298
- description,
299
- }),
310
+ body: JSON.stringify(body),
300
311
  signal: AbortSignal.timeout(this.timeout_ms),
301
312
  });
302
313
  if (!response.ok) {
@@ -374,8 +385,7 @@ export class Client {
374
385
  if (!response.ok) {
375
386
  throw new Error(`Failed to delete ${path}: ${response.status} ${response.statusText}`);
376
387
  }
377
- const results = await response.json();
378
- return results;
388
+ await response.json();
379
389
  }
380
390
  async createExample(inputs, outputs, { datasetId, datasetName, createdAt, }) {
381
391
  let datasetId_ = datasetId;
@@ -447,8 +457,7 @@ export class Client {
447
457
  if (!response.ok) {
448
458
  throw new Error(`Failed to delete ${path}: ${response.status} ${response.statusText}`);
449
459
  }
450
- const result = await response.json();
451
- return result;
460
+ await response.json();
452
461
  }
453
462
  async updateExample(exampleId, update) {
454
463
  const response = await this.caller.call(fetch, `${this.apiUrl}/examples/${exampleId}`, {
@@ -541,8 +550,7 @@ export class Client {
541
550
  if (!response.ok) {
542
551
  throw new Error(`Failed to delete ${path}: ${response.status} ${response.statusText}`);
543
552
  }
544
- const result = await response.json();
545
- return result;
553
+ await response.json();
546
554
  }
547
555
  async listFeedback({ runIds, limit, offset, } = {}) {
548
556
  const queryParams = new URLSearchParams();
@@ -131,6 +131,12 @@ class RunTree {
131
131
  writable: true,
132
132
  value: void 0
133
133
  });
134
+ Object.defineProperty(this, "events", {
135
+ enumerable: true,
136
+ configurable: true,
137
+ writable: true,
138
+ value: void 0
139
+ });
134
140
  const defaultConfig = RunTree.getDefaultConfig();
135
141
  Object.assign(this, { ...defaultConfig, ...config });
136
142
  }
@@ -225,6 +231,8 @@ class RunTree {
225
231
  outputs: this.outputs,
226
232
  parent_run_id: this.parent_run?.id,
227
233
  reference_example_id: this.reference_example_id,
234
+ extra: this.extra,
235
+ events: this.events,
228
236
  };
229
237
  await this.client.updateRun(this.id, runUpdate);
230
238
  }
@@ -37,6 +37,7 @@ export declare class RunTree implements BaseRun {
37
37
  outputs?: KVMap;
38
38
  reference_example_id?: string;
39
39
  client: Client;
40
+ events?: KVMap[] | undefined;
40
41
  constructor(config: RunTreeConfig);
41
42
  private static getDefaultConfig;
42
43
  createChild(config: RunTreeConfig): Promise<RunTree>;
package/dist/run_trees.js CHANGED
@@ -105,6 +105,12 @@ export class RunTree {
105
105
  writable: true,
106
106
  value: void 0
107
107
  });
108
+ Object.defineProperty(this, "events", {
109
+ enumerable: true,
110
+ configurable: true,
111
+ writable: true,
112
+ value: void 0
113
+ });
108
114
  const defaultConfig = RunTree.getDefaultConfig();
109
115
  Object.assign(this, { ...defaultConfig, ...config });
110
116
  }
@@ -199,6 +205,8 @@ export class RunTree {
199
205
  outputs: this.outputs,
200
206
  parent_run_id: this.parent_run?.id,
201
207
  reference_example_id: this.reference_example_id,
208
+ extra: this.extra,
209
+ events: this.events,
202
210
  };
203
211
  await this.client.updateRun(this.id, runUpdate);
204
212
  }
package/dist/schemas.d.ts CHANGED
@@ -3,7 +3,6 @@ export interface TracerSession {
3
3
  id: string;
4
4
  start_time: number;
5
5
  name?: string;
6
- mode?: string;
7
6
  }
8
7
  export interface TracerSessionResult extends TracerSession {
9
8
  run_count?: number;
@@ -18,9 +17,10 @@ export interface TracerSessionResult extends TracerSession {
18
17
  run_facets?: KVMap[];
19
18
  }
20
19
  export type KVMap = Record<string, any>;
21
- export type RunType = "llm" | "chain" | "tool";
20
+ export type RunType = "llm" | "chain" | "tool" | "retriever" | "embedding";
22
21
  export type ScoreType = number | boolean | null;
23
22
  export type ValueType = number | boolean | string | object | null;
23
+ export type DataType = "kv" | "llm" | "chat";
24
24
  export interface BaseExample {
25
25
  dataset_id: string;
26
26
  inputs: KVMap;
@@ -58,10 +58,13 @@ export interface RunCreate extends BaseRun {
58
58
  }
59
59
  export interface RunUpdate {
60
60
  end_time?: number;
61
+ extra?: KVMap;
61
62
  error?: string;
62
63
  outputs?: KVMap;
63
64
  parent_run_id?: string;
64
65
  reference_example_id?: string;
66
+ events?: KVMap[];
67
+ session_id?: string;
65
68
  }
66
69
  export interface ExampleCreate extends BaseExample {
67
70
  id?: string;
@@ -82,6 +85,7 @@ export interface BaseDataset {
82
85
  name: string;
83
86
  description: string;
84
87
  tenant_id: string;
88
+ data_type?: DataType;
85
89
  }
86
90
  export interface Dataset extends BaseDataset {
87
91
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langsmith",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform.",
5
5
  "files": [
6
6
  "dist/",