langsmith 0.1.36 → 0.1.38

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/README.md CHANGED
@@ -53,6 +53,7 @@ Tracing can be activated by setting the following environment variables or by ma
53
53
  ```typescript
54
54
  process.env["LANGSMITH_TRACING"] = "true";
55
55
  process.env["LANGCHAIN_ENDPOINT"] = "https://api.smith.langchain.com";
56
+ // process.env["LANGCHAIN_ENDPOINT"] = "https://eu.api.smith.langchain.com"; // If signed up in the EU region
56
57
  process.env["LANGCHAIN_API_KEY"] = "<YOUR-LANGSMITH-API-KEY>";
57
58
  // process.env["LANGCHAIN_PROJECT"] = "My Project Name"; // Optional: "default" is used if not set
58
59
  ```
package/dist/client.cjs CHANGED
@@ -319,6 +319,10 @@ class Client {
319
319
  this.webUrl = "https://dev.smith.langchain.com";
320
320
  return this.webUrl;
321
321
  }
322
+ else if (this.apiUrl.split(".", 1)[0].includes("eu")) {
323
+ this.webUrl = "https://eu.smith.langchain.com";
324
+ return this.webUrl;
325
+ }
322
326
  else {
323
327
  this.webUrl = "https://smith.langchain.com";
324
328
  return this.webUrl;
@@ -1659,6 +1663,81 @@ class Client {
1659
1663
  const result = await response.json();
1660
1664
  return result;
1661
1665
  }
1666
+ async updateExamples(update) {
1667
+ const response = await this.caller.call(fetch, `${this.apiUrl}/examples/bulk`, {
1668
+ method: "PATCH",
1669
+ headers: { ...this.headers, "Content-Type": "application/json" },
1670
+ body: JSON.stringify(update),
1671
+ signal: AbortSignal.timeout(this.timeout_ms),
1672
+ ...this.fetchOptions,
1673
+ });
1674
+ if (!response.ok) {
1675
+ throw new Error(`Failed to update examples: ${response.status} ${response.statusText}`);
1676
+ }
1677
+ const result = await response.json();
1678
+ return result;
1679
+ }
1680
+ async listDatasetSplits({ datasetId, datasetName, asOf, }) {
1681
+ let datasetId_;
1682
+ if (datasetId === undefined && datasetName === undefined) {
1683
+ throw new Error("Must provide dataset name or ID");
1684
+ }
1685
+ else if (datasetId !== undefined && datasetName !== undefined) {
1686
+ throw new Error("Must provide either datasetName or datasetId, not both");
1687
+ }
1688
+ else if (datasetId === undefined) {
1689
+ const dataset = await this.readDataset({ datasetName });
1690
+ datasetId_ = dataset.id;
1691
+ }
1692
+ else {
1693
+ datasetId_ = datasetId;
1694
+ }
1695
+ (0, _uuid_js_1.assertUuid)(datasetId_);
1696
+ const params = new URLSearchParams();
1697
+ const dataset_version = asOf
1698
+ ? typeof asOf === "string"
1699
+ ? asOf
1700
+ : asOf?.toISOString()
1701
+ : undefined;
1702
+ if (dataset_version) {
1703
+ params.append("as_of", dataset_version);
1704
+ }
1705
+ const response = await this._get(`/datasets/${datasetId_}/splits`, params);
1706
+ return response;
1707
+ }
1708
+ async updateDatasetSplits({ datasetId, datasetName, splitName, exampleIds, remove = false, }) {
1709
+ let datasetId_;
1710
+ if (datasetId === undefined && datasetName === undefined) {
1711
+ throw new Error("Must provide dataset name or ID");
1712
+ }
1713
+ else if (datasetId !== undefined && datasetName !== undefined) {
1714
+ throw new Error("Must provide either datasetName or datasetId, not both");
1715
+ }
1716
+ else if (datasetId === undefined) {
1717
+ const dataset = await this.readDataset({ datasetName });
1718
+ datasetId_ = dataset.id;
1719
+ }
1720
+ else {
1721
+ datasetId_ = datasetId;
1722
+ }
1723
+ (0, _uuid_js_1.assertUuid)(datasetId_);
1724
+ const data = {
1725
+ split_name: splitName,
1726
+ examples: exampleIds.map((id) => {
1727
+ (0, _uuid_js_1.assertUuid)(id);
1728
+ return id;
1729
+ }),
1730
+ remove,
1731
+ };
1732
+ const response = await this.caller.call(fetch, `${this.apiUrl}/datasets/${datasetId_}/splits`, {
1733
+ method: "PUT",
1734
+ headers: { ...this.headers, "Content-Type": "application/json" },
1735
+ body: JSON.stringify(data),
1736
+ signal: AbortSignal.timeout(this.timeout_ms),
1737
+ ...this.fetchOptions,
1738
+ });
1739
+ await raiseForStatus(response, "update dataset splits");
1740
+ }
1662
1741
  /**
1663
1742
  * @deprecated This method is deprecated and will be removed in future LangSmith versions, use `evaluate` from `langsmith/evaluation` instead.
1664
1743
  */
package/dist/client.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AsyncCallerParams } from "./utils/async_caller.js";
2
- import { ComparativeExperiment, DataType, Dataset, DatasetDiffInfo, DatasetShareSchema, Example, ExampleUpdate, Feedback, FeedbackConfig, FeedbackIngestToken, KVMap, LangChainBaseMessage, Run, RunCreate, RunUpdate, ScoreType, TimeDelta, TracerSession, TracerSessionResult, ValueType } from "./schemas.js";
2
+ import { ComparativeExperiment, DataType, Dataset, DatasetDiffInfo, DatasetShareSchema, Example, ExampleUpdate, ExampleUpdateWithId, Feedback, FeedbackConfig, FeedbackIngestToken, KVMap, LangChainBaseMessage, Run, RunCreate, RunUpdate, ScoreType, TimeDelta, TracerSession, TracerSessionResult, ValueType } from "./schemas.js";
3
3
  import { EvaluationResult, EvaluationResults, RunEvaluator } from "./evaluation/evaluator.js";
4
4
  interface ClientConfig {
5
5
  apiUrl?: string;
@@ -430,6 +430,19 @@ export declare class Client {
430
430
  }): AsyncIterable<Example>;
431
431
  deleteExample(exampleId: string): Promise<void>;
432
432
  updateExample(exampleId: string, update: ExampleUpdate): Promise<object>;
433
+ updateExamples(update: ExampleUpdateWithId[]): Promise<object>;
434
+ listDatasetSplits({ datasetId, datasetName, asOf, }: {
435
+ datasetId?: string;
436
+ datasetName?: string;
437
+ asOf?: string | Date;
438
+ }): Promise<string[]>;
439
+ updateDatasetSplits({ datasetId, datasetName, splitName, exampleIds, remove, }: {
440
+ datasetId?: string;
441
+ datasetName?: string;
442
+ splitName: string;
443
+ exampleIds: string[];
444
+ remove?: boolean;
445
+ }): Promise<void>;
433
446
  /**
434
447
  * @deprecated This method is deprecated and will be removed in future LangSmith versions, use `evaluate` from `langsmith/evaluation` instead.
435
448
  */
package/dist/client.js CHANGED
@@ -292,6 +292,10 @@ export class Client {
292
292
  this.webUrl = "https://dev.smith.langchain.com";
293
293
  return this.webUrl;
294
294
  }
295
+ else if (this.apiUrl.split(".", 1)[0].includes("eu")) {
296
+ this.webUrl = "https://eu.smith.langchain.com";
297
+ return this.webUrl;
298
+ }
295
299
  else {
296
300
  this.webUrl = "https://smith.langchain.com";
297
301
  return this.webUrl;
@@ -1632,6 +1636,81 @@ export class Client {
1632
1636
  const result = await response.json();
1633
1637
  return result;
1634
1638
  }
1639
+ async updateExamples(update) {
1640
+ const response = await this.caller.call(fetch, `${this.apiUrl}/examples/bulk`, {
1641
+ method: "PATCH",
1642
+ headers: { ...this.headers, "Content-Type": "application/json" },
1643
+ body: JSON.stringify(update),
1644
+ signal: AbortSignal.timeout(this.timeout_ms),
1645
+ ...this.fetchOptions,
1646
+ });
1647
+ if (!response.ok) {
1648
+ throw new Error(`Failed to update examples: ${response.status} ${response.statusText}`);
1649
+ }
1650
+ const result = await response.json();
1651
+ return result;
1652
+ }
1653
+ async listDatasetSplits({ datasetId, datasetName, asOf, }) {
1654
+ let datasetId_;
1655
+ if (datasetId === undefined && datasetName === undefined) {
1656
+ throw new Error("Must provide dataset name or ID");
1657
+ }
1658
+ else if (datasetId !== undefined && datasetName !== undefined) {
1659
+ throw new Error("Must provide either datasetName or datasetId, not both");
1660
+ }
1661
+ else if (datasetId === undefined) {
1662
+ const dataset = await this.readDataset({ datasetName });
1663
+ datasetId_ = dataset.id;
1664
+ }
1665
+ else {
1666
+ datasetId_ = datasetId;
1667
+ }
1668
+ assertUuid(datasetId_);
1669
+ const params = new URLSearchParams();
1670
+ const dataset_version = asOf
1671
+ ? typeof asOf === "string"
1672
+ ? asOf
1673
+ : asOf?.toISOString()
1674
+ : undefined;
1675
+ if (dataset_version) {
1676
+ params.append("as_of", dataset_version);
1677
+ }
1678
+ const response = await this._get(`/datasets/${datasetId_}/splits`, params);
1679
+ return response;
1680
+ }
1681
+ async updateDatasetSplits({ datasetId, datasetName, splitName, exampleIds, remove = false, }) {
1682
+ let datasetId_;
1683
+ if (datasetId === undefined && datasetName === undefined) {
1684
+ throw new Error("Must provide dataset name or ID");
1685
+ }
1686
+ else if (datasetId !== undefined && datasetName !== undefined) {
1687
+ throw new Error("Must provide either datasetName or datasetId, not both");
1688
+ }
1689
+ else if (datasetId === undefined) {
1690
+ const dataset = await this.readDataset({ datasetName });
1691
+ datasetId_ = dataset.id;
1692
+ }
1693
+ else {
1694
+ datasetId_ = datasetId;
1695
+ }
1696
+ assertUuid(datasetId_);
1697
+ const data = {
1698
+ split_name: splitName,
1699
+ examples: exampleIds.map((id) => {
1700
+ assertUuid(id);
1701
+ return id;
1702
+ }),
1703
+ remove,
1704
+ };
1705
+ const response = await this.caller.call(fetch, `${this.apiUrl}/datasets/${datasetId_}/splits`, {
1706
+ method: "PUT",
1707
+ headers: { ...this.headers, "Content-Type": "application/json" },
1708
+ body: JSON.stringify(data),
1709
+ signal: AbortSignal.timeout(this.timeout_ms),
1710
+ ...this.fetchOptions,
1711
+ });
1712
+ await raiseForStatus(response, "update dataset splits");
1713
+ }
1635
1714
  /**
1636
1715
  * @deprecated This method is deprecated and will be removed in future LangSmith versions, use `evaluate` from `langsmith/evaluation` instead.
1637
1716
  */
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.36";
9
+ exports.__version__ = "0.1.38";
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.36";
4
+ export declare const __version__ = "0.1.38";
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.36";
4
+ export const __version__ = "0.1.38";
package/dist/schemas.d.ts CHANGED
@@ -178,6 +178,9 @@ export interface ExampleUpdate {
178
178
  metadata?: KVMap;
179
179
  split?: string | string[];
180
180
  }
181
+ export interface ExampleUpdateWithId extends ExampleUpdate {
182
+ id: string;
183
+ }
181
184
  export interface BaseDataset {
182
185
  name: string;
183
186
  description: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langsmith",
3
- "version": "0.1.36",
3
+ "version": "0.1.38",
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": [