langsmith 0.2.16-rc.9 → 0.3.0

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
@@ -1784,6 +1784,40 @@ class Client {
1784
1784
  await (0, error_js_1.raiseForStatus)(response, "update dataset");
1785
1785
  return (await response.json());
1786
1786
  }
1787
+ /**
1788
+ * Updates a tag on a dataset.
1789
+ *
1790
+ * If the tag is already assigned to a different version of this dataset,
1791
+ * the tag will be moved to the new version. The as_of parameter is used to
1792
+ * determine which version of the dataset to apply the new tags to.
1793
+ *
1794
+ * It must be an exact version of the dataset to succeed. You can
1795
+ * use the "readDatasetVersion" method to find the exact version
1796
+ * to apply the tags to.
1797
+ * @param params.datasetId The ID of the dataset to update. Must be provided if "datasetName" is not provided.
1798
+ * @param params.datasetName The name of the dataset to update. Must be provided if "datasetId" is not provided.
1799
+ * @param params.asOf The timestamp of the dataset to apply the new tags to.
1800
+ * @param params.tag The new tag to apply to the dataset.
1801
+ */
1802
+ async updateDatasetTag(props) {
1803
+ const { datasetId, datasetName, asOf, tag } = props;
1804
+ if (!datasetId && !datasetName) {
1805
+ throw new Error("Must provide either datasetName or datasetId");
1806
+ }
1807
+ const _datasetId = datasetId ?? (await this.readDataset({ datasetName })).id;
1808
+ (0, _uuid_js_1.assertUuid)(_datasetId);
1809
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/datasets/${_datasetId}/tags`, {
1810
+ method: "PUT",
1811
+ headers: { ...this.headers, "Content-Type": "application/json" },
1812
+ body: JSON.stringify({
1813
+ as_of: typeof asOf === "string" ? asOf : asOf.toISOString(),
1814
+ tag,
1815
+ }),
1816
+ signal: AbortSignal.timeout(this.timeout_ms),
1817
+ ...this.fetchOptions,
1818
+ });
1819
+ await (0, error_js_1.raiseForStatus)(response, "update dataset tags");
1820
+ }
1787
1821
  async deleteDataset({ datasetId, datasetName, }) {
1788
1822
  let path = "/datasets";
1789
1823
  let datasetId_ = datasetId;
@@ -2099,6 +2133,47 @@ class Client {
2099
2133
  const result = await response.json();
2100
2134
  return result;
2101
2135
  }
2136
+ /**
2137
+ * Get dataset version by closest date or exact tag.
2138
+ *
2139
+ * Use this to resolve the nearest version to a given timestamp or for a given tag.
2140
+ *
2141
+ * @param options The options for getting the dataset version
2142
+ * @param options.datasetId The ID of the dataset
2143
+ * @param options.datasetName The name of the dataset
2144
+ * @param options.asOf The timestamp of the dataset to retrieve
2145
+ * @param options.tag The tag of the dataset to retrieve
2146
+ * @returns The dataset version
2147
+ */
2148
+ async readDatasetVersion({ datasetId, datasetName, asOf, tag, }) {
2149
+ let resolvedDatasetId;
2150
+ if (!datasetId) {
2151
+ const dataset = await this.readDataset({ datasetName });
2152
+ resolvedDatasetId = dataset.id;
2153
+ }
2154
+ else {
2155
+ resolvedDatasetId = datasetId;
2156
+ }
2157
+ (0, _uuid_js_1.assertUuid)(resolvedDatasetId);
2158
+ if ((asOf && tag) || (!asOf && !tag)) {
2159
+ throw new Error("Exactly one of asOf and tag must be specified.");
2160
+ }
2161
+ const params = new URLSearchParams();
2162
+ if (asOf !== undefined) {
2163
+ params.append("as_of", typeof asOf === "string" ? asOf : asOf.toISOString());
2164
+ }
2165
+ if (tag !== undefined) {
2166
+ params.append("tag", tag);
2167
+ }
2168
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(), `${this.apiUrl}/datasets/${resolvedDatasetId}/version?${params.toString()}`, {
2169
+ method: "GET",
2170
+ headers: { ...this.headers },
2171
+ signal: AbortSignal.timeout(this.timeout_ms),
2172
+ ...this.fetchOptions,
2173
+ });
2174
+ await (0, error_js_1.raiseForStatus)(response, "read dataset version");
2175
+ return await response.json();
2176
+ }
2102
2177
  async listDatasetSplits({ datasetId, datasetName, asOf, }) {
2103
2178
  let datasetId_;
2104
2179
  if (datasetId === undefined && datasetName === undefined) {
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, ExampleUpdateWithId, Feedback, FeedbackConfig, FeedbackIngestToken, KVMap, LangChainBaseMessage, LangSmithSettings, LikePromptResponse, Prompt, PromptCommit, PromptSortField, Run, RunCreate, RunUpdate, ScoreType, ExampleSearch, TimeDelta, TracerSession, TracerSessionResult, ValueType, AnnotationQueue, RunWithAnnotationQueueInfo, Attachments, ExampleUploadWithAttachments, UploadExamplesResponse, ExampleUpdateWithAttachments, UpdateExamplesResponse } from "./schemas.js";
2
+ import { ComparativeExperiment, DataType, Dataset, DatasetDiffInfo, DatasetShareSchema, Example, ExampleUpdate, ExampleUpdateWithId, Feedback, FeedbackConfig, FeedbackIngestToken, KVMap, LangChainBaseMessage, LangSmithSettings, LikePromptResponse, Prompt, PromptCommit, PromptSortField, Run, RunCreate, RunUpdate, ScoreType, ExampleSearch, TimeDelta, TracerSession, TracerSessionResult, ValueType, AnnotationQueue, RunWithAnnotationQueueInfo, Attachments, ExampleUploadWithAttachments, UploadExamplesResponse, ExampleUpdateWithAttachments, UpdateExamplesResponse, DatasetVersion } from "./schemas.js";
3
3
  import { EvaluationResult, EvaluationResults, RunEvaluator } from "./evaluation/evaluator.js";
4
4
  export interface ClientConfig {
5
5
  apiUrl?: string;
@@ -487,6 +487,27 @@ export declare class Client implements LangSmithTracingClientInterface {
487
487
  name?: string;
488
488
  description?: string;
489
489
  }): Promise<Dataset>;
490
+ /**
491
+ * Updates a tag on a dataset.
492
+ *
493
+ * If the tag is already assigned to a different version of this dataset,
494
+ * the tag will be moved to the new version. The as_of parameter is used to
495
+ * determine which version of the dataset to apply the new tags to.
496
+ *
497
+ * It must be an exact version of the dataset to succeed. You can
498
+ * use the "readDatasetVersion" method to find the exact version
499
+ * to apply the tags to.
500
+ * @param params.datasetId The ID of the dataset to update. Must be provided if "datasetName" is not provided.
501
+ * @param params.datasetName The name of the dataset to update. Must be provided if "datasetId" is not provided.
502
+ * @param params.asOf The timestamp of the dataset to apply the new tags to.
503
+ * @param params.tag The new tag to apply to the dataset.
504
+ */
505
+ updateDatasetTag(props: {
506
+ datasetId?: string;
507
+ datasetName?: string;
508
+ asOf: string | Date;
509
+ tag: string;
510
+ }): Promise<void>;
490
511
  deleteDataset({ datasetId, datasetName, }: {
491
512
  datasetId?: string;
492
513
  datasetName?: string;
@@ -559,6 +580,24 @@ export declare class Client implements LangSmithTracingClientInterface {
559
580
  deleteExample(exampleId: string): Promise<void>;
560
581
  updateExample(exampleId: string, update: ExampleUpdate): Promise<object>;
561
582
  updateExamples(update: ExampleUpdateWithId[]): Promise<object>;
583
+ /**
584
+ * Get dataset version by closest date or exact tag.
585
+ *
586
+ * Use this to resolve the nearest version to a given timestamp or for a given tag.
587
+ *
588
+ * @param options The options for getting the dataset version
589
+ * @param options.datasetId The ID of the dataset
590
+ * @param options.datasetName The name of the dataset
591
+ * @param options.asOf The timestamp of the dataset to retrieve
592
+ * @param options.tag The tag of the dataset to retrieve
593
+ * @returns The dataset version
594
+ */
595
+ readDatasetVersion({ datasetId, datasetName, asOf, tag, }: {
596
+ datasetId?: string;
597
+ datasetName?: string;
598
+ asOf?: string | Date;
599
+ tag?: string;
600
+ }): Promise<DatasetVersion>;
562
601
  listDatasetSplits({ datasetId, datasetName, asOf, }: {
563
602
  datasetId?: string;
564
603
  datasetName?: string;
package/dist/client.js CHANGED
@@ -1756,6 +1756,40 @@ export class Client {
1756
1756
  await raiseForStatus(response, "update dataset");
1757
1757
  return (await response.json());
1758
1758
  }
1759
+ /**
1760
+ * Updates a tag on a dataset.
1761
+ *
1762
+ * If the tag is already assigned to a different version of this dataset,
1763
+ * the tag will be moved to the new version. The as_of parameter is used to
1764
+ * determine which version of the dataset to apply the new tags to.
1765
+ *
1766
+ * It must be an exact version of the dataset to succeed. You can
1767
+ * use the "readDatasetVersion" method to find the exact version
1768
+ * to apply the tags to.
1769
+ * @param params.datasetId The ID of the dataset to update. Must be provided if "datasetName" is not provided.
1770
+ * @param params.datasetName The name of the dataset to update. Must be provided if "datasetId" is not provided.
1771
+ * @param params.asOf The timestamp of the dataset to apply the new tags to.
1772
+ * @param params.tag The new tag to apply to the dataset.
1773
+ */
1774
+ async updateDatasetTag(props) {
1775
+ const { datasetId, datasetName, asOf, tag } = props;
1776
+ if (!datasetId && !datasetName) {
1777
+ throw new Error("Must provide either datasetName or datasetId");
1778
+ }
1779
+ const _datasetId = datasetId ?? (await this.readDataset({ datasetName })).id;
1780
+ assertUuid(_datasetId);
1781
+ const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/datasets/${_datasetId}/tags`, {
1782
+ method: "PUT",
1783
+ headers: { ...this.headers, "Content-Type": "application/json" },
1784
+ body: JSON.stringify({
1785
+ as_of: typeof asOf === "string" ? asOf : asOf.toISOString(),
1786
+ tag,
1787
+ }),
1788
+ signal: AbortSignal.timeout(this.timeout_ms),
1789
+ ...this.fetchOptions,
1790
+ });
1791
+ await raiseForStatus(response, "update dataset tags");
1792
+ }
1759
1793
  async deleteDataset({ datasetId, datasetName, }) {
1760
1794
  let path = "/datasets";
1761
1795
  let datasetId_ = datasetId;
@@ -2071,6 +2105,47 @@ export class Client {
2071
2105
  const result = await response.json();
2072
2106
  return result;
2073
2107
  }
2108
+ /**
2109
+ * Get dataset version by closest date or exact tag.
2110
+ *
2111
+ * Use this to resolve the nearest version to a given timestamp or for a given tag.
2112
+ *
2113
+ * @param options The options for getting the dataset version
2114
+ * @param options.datasetId The ID of the dataset
2115
+ * @param options.datasetName The name of the dataset
2116
+ * @param options.asOf The timestamp of the dataset to retrieve
2117
+ * @param options.tag The tag of the dataset to retrieve
2118
+ * @returns The dataset version
2119
+ */
2120
+ async readDatasetVersion({ datasetId, datasetName, asOf, tag, }) {
2121
+ let resolvedDatasetId;
2122
+ if (!datasetId) {
2123
+ const dataset = await this.readDataset({ datasetName });
2124
+ resolvedDatasetId = dataset.id;
2125
+ }
2126
+ else {
2127
+ resolvedDatasetId = datasetId;
2128
+ }
2129
+ assertUuid(resolvedDatasetId);
2130
+ if ((asOf && tag) || (!asOf && !tag)) {
2131
+ throw new Error("Exactly one of asOf and tag must be specified.");
2132
+ }
2133
+ const params = new URLSearchParams();
2134
+ if (asOf !== undefined) {
2135
+ params.append("as_of", typeof asOf === "string" ? asOf : asOf.toISOString());
2136
+ }
2137
+ if (tag !== undefined) {
2138
+ params.append("tag", tag);
2139
+ }
2140
+ const response = await this.caller.call(_getFetchImplementation(), `${this.apiUrl}/datasets/${resolvedDatasetId}/version?${params.toString()}`, {
2141
+ method: "GET",
2142
+ headers: { ...this.headers },
2143
+ signal: AbortSignal.timeout(this.timeout_ms),
2144
+ ...this.fetchOptions,
2145
+ });
2146
+ await raiseForStatus(response, "read dataset version");
2147
+ return await response.json();
2148
+ }
2074
2149
  async listDatasetSplits({ datasetId, datasetName, asOf, }) {
2075
2150
  let datasetId_;
2076
2151
  if (datasetId === undefined && datasetName === undefined) {
package/dist/index.cjs CHANGED
@@ -8,4 +8,4 @@ Object.defineProperty(exports, "RunTree", { enumerable: true, get: function () {
8
8
  var fetch_js_1 = require("./singletons/fetch.cjs");
9
9
  Object.defineProperty(exports, "overrideFetchImplementation", { enumerable: true, get: function () { return fetch_js_1.overrideFetchImplementation; } });
10
10
  // Update using yarn bump-version
11
- exports.__version__ = "0.2.16-rc.9";
11
+ exports.__version__ = "0.3.0";
package/dist/index.d.ts CHANGED
@@ -2,4 +2,4 @@ export { Client, type ClientConfig, type LangSmithTracingClientInterface, } from
2
2
  export type { Dataset, Example, TracerSession, Run, Feedback, RetrieverOutput, } from "./schemas.js";
3
3
  export { RunTree, type RunTreeConfig } from "./run_trees.js";
4
4
  export { overrideFetchImplementation } from "./singletons/fetch.js";
5
- export declare const __version__ = "0.2.16-rc.9";
5
+ export declare const __version__ = "0.3.0";
package/dist/index.js CHANGED
@@ -2,4 +2,4 @@ export { Client, } from "./client.js";
2
2
  export { RunTree } from "./run_trees.js";
3
3
  export { overrideFetchImplementation } from "./singletons/fetch.js";
4
4
  // Update using yarn bump-version
5
- export const __version__ = "0.2.16-rc.9";
5
+ export const __version__ = "0.3.0";
@@ -16,15 +16,17 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
17
17
  };
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.logOutput = exports.logFeedback = exports.toBeSemanticCloseTo = exports.toBeAbsoluteCloseTo = exports.toBeRelativeCloseTo = exports.expect = exports.describe = exports.it = exports.test = void 0;
19
+ exports.wrapEvaluator = exports.logOutputs = exports.logFeedback = exports.toBeSemanticCloseTo = exports.toBeAbsoluteCloseTo = exports.toBeRelativeCloseTo = exports.expect = exports.describe = exports.it = exports.test = void 0;
20
20
  const globals_1 = require("@jest/globals");
21
21
  const matchers_js_1 = require("../utils/jestlike/matchers.cjs");
22
22
  Object.defineProperty(exports, "toBeRelativeCloseTo", { enumerable: true, get: function () { return matchers_js_1.toBeRelativeCloseTo; } });
23
23
  Object.defineProperty(exports, "toBeAbsoluteCloseTo", { enumerable: true, get: function () { return matchers_js_1.toBeAbsoluteCloseTo; } });
24
24
  Object.defineProperty(exports, "toBeSemanticCloseTo", { enumerable: true, get: function () { return matchers_js_1.toBeSemanticCloseTo; } });
25
+ const evaluatedBy_js_1 = require("../utils/jestlike/vendor/evaluatedBy.cjs");
26
+ Object.defineProperty(exports, "wrapEvaluator", { enumerable: true, get: function () { return evaluatedBy_js_1.wrapEvaluator; } });
25
27
  const index_js_1 = require("../utils/jestlike/index.cjs");
26
28
  Object.defineProperty(exports, "logFeedback", { enumerable: true, get: function () { return index_js_1.logFeedback; } });
27
- Object.defineProperty(exports, "logOutput", { enumerable: true, get: function () { return index_js_1.logOutput; } });
29
+ Object.defineProperty(exports, "logOutputs", { enumerable: true, get: function () { return index_js_1.logOutputs; } });
28
30
  const index_js_2 = require("../utils/jestlike/index.cjs");
29
31
  globals_1.expect.extend({
30
32
  toBeRelativeCloseTo: matchers_js_1.toBeRelativeCloseTo,