langsmith 0.1.33 → 0.1.35

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.
@@ -37,19 +37,14 @@ function extractStringNodes(data, options) {
37
37
  return result;
38
38
  }
39
39
  function deepClone(data) {
40
- if ("structuredClone" in globalThis) {
41
- return globalThis.structuredClone(data);
42
- }
43
40
  return JSON.parse(JSON.stringify(data));
44
41
  }
45
42
  function createAnonymizer(replacer, options) {
46
43
  return (data) => {
47
- const nodes = extractStringNodes(data, {
44
+ let mutateValue = deepClone(data);
45
+ const nodes = extractStringNodes(mutateValue, {
48
46
  maxDepth: options?.maxDepth,
49
47
  });
50
- // by default we opt-in to mutate the value directly
51
- // to improve performance
52
- let mutateValue = options?.deepClone ? deepClone(data) : data;
53
48
  const processor = Array.isArray(replacer)
54
49
  ? (() => {
55
50
  const replacers = replacer.map(({ pattern, type, replace }) => {
@@ -13,5 +13,4 @@ export interface StringNodeRule {
13
13
  export type ReplacerType = ((value: string, path?: string) => string) | StringNodeRule[] | StringNodeProcessor;
14
14
  export declare function createAnonymizer(replacer: ReplacerType, options?: {
15
15
  maxDepth?: number;
16
- deepClone?: boolean;
17
16
  }): <T>(data: T) => T;
@@ -31,19 +31,14 @@ function extractStringNodes(data, options) {
31
31
  return result;
32
32
  }
33
33
  function deepClone(data) {
34
- if ("structuredClone" in globalThis) {
35
- return globalThis.structuredClone(data);
36
- }
37
34
  return JSON.parse(JSON.stringify(data));
38
35
  }
39
36
  export function createAnonymizer(replacer, options) {
40
37
  return (data) => {
41
- const nodes = extractStringNodes(data, {
38
+ let mutateValue = deepClone(data);
39
+ const nodes = extractStringNodes(mutateValue, {
42
40
  maxDepth: options?.maxDepth,
43
41
  });
44
- // by default we opt-in to mutate the value directly
45
- // to improve performance
46
- let mutateValue = options?.deepClone ? deepClone(data) : data;
47
42
  const processor = Array.isArray(replacer)
48
43
  ? (() => {
49
44
  const replacers = replacer.map(({ pattern, type, replace }) => {
package/dist/client.cjs CHANGED
@@ -1570,7 +1570,7 @@ class Client {
1570
1570
  const path = `/examples/${exampleId}`;
1571
1571
  return await this._get(path);
1572
1572
  }
1573
- async *listExamples({ datasetId, datasetName, exampleIds, asOf, splits, inlineS3Urls, metadata, } = {}) {
1573
+ async *listExamples({ datasetId, datasetName, exampleIds, asOf, splits, inlineS3Urls, metadata, limit, offset, filter, } = {}) {
1574
1574
  let datasetId_;
1575
1575
  if (datasetId !== undefined && datasetName !== undefined) {
1576
1576
  throw new Error("Must provide either datasetName or datasetId, not both");
@@ -1610,8 +1610,24 @@ class Client {
1610
1610
  const serializedMetadata = JSON.stringify(metadata);
1611
1611
  params.append("metadata", serializedMetadata);
1612
1612
  }
1613
+ if (limit !== undefined) {
1614
+ params.append("limit", limit.toString());
1615
+ }
1616
+ if (offset !== undefined) {
1617
+ params.append("offset", offset.toString());
1618
+ }
1619
+ if (filter !== undefined) {
1620
+ params.append("filter", filter);
1621
+ }
1622
+ let i = 0;
1613
1623
  for await (const examples of this._getPaginated("/examples", params)) {
1614
- yield* examples;
1624
+ for (const example of examples) {
1625
+ yield example;
1626
+ i++;
1627
+ }
1628
+ if (limit !== undefined && i >= limit) {
1629
+ break;
1630
+ }
1615
1631
  }
1616
1632
  }
1617
1633
  async deleteExample(exampleId) {
package/dist/client.d.ts CHANGED
@@ -416,7 +416,7 @@ export declare class Client {
416
416
  createLLMExample(input: string, generation: string | undefined, options: CreateExampleOptions): Promise<Example>;
417
417
  createChatExample(input: KVMap[] | LangChainBaseMessage[], generations: KVMap | LangChainBaseMessage | undefined, options: CreateExampleOptions): Promise<Example>;
418
418
  readExample(exampleId: string): Promise<Example>;
419
- listExamples({ datasetId, datasetName, exampleIds, asOf, splits, inlineS3Urls, metadata, }?: {
419
+ listExamples({ datasetId, datasetName, exampleIds, asOf, splits, inlineS3Urls, metadata, limit, offset, filter, }?: {
420
420
  datasetId?: string;
421
421
  datasetName?: string;
422
422
  exampleIds?: string[];
@@ -424,6 +424,9 @@ export declare class Client {
424
424
  splits?: string[];
425
425
  inlineS3Urls?: boolean;
426
426
  metadata?: KVMap;
427
+ limit?: number;
428
+ offset?: number;
429
+ filter?: string;
427
430
  }): AsyncIterable<Example>;
428
431
  deleteExample(exampleId: string): Promise<void>;
429
432
  updateExample(exampleId: string, update: ExampleUpdate): Promise<object>;
package/dist/client.js CHANGED
@@ -1543,7 +1543,7 @@ export class Client {
1543
1543
  const path = `/examples/${exampleId}`;
1544
1544
  return await this._get(path);
1545
1545
  }
1546
- async *listExamples({ datasetId, datasetName, exampleIds, asOf, splits, inlineS3Urls, metadata, } = {}) {
1546
+ async *listExamples({ datasetId, datasetName, exampleIds, asOf, splits, inlineS3Urls, metadata, limit, offset, filter, } = {}) {
1547
1547
  let datasetId_;
1548
1548
  if (datasetId !== undefined && datasetName !== undefined) {
1549
1549
  throw new Error("Must provide either datasetName or datasetId, not both");
@@ -1583,8 +1583,24 @@ export class Client {
1583
1583
  const serializedMetadata = JSON.stringify(metadata);
1584
1584
  params.append("metadata", serializedMetadata);
1585
1585
  }
1586
+ if (limit !== undefined) {
1587
+ params.append("limit", limit.toString());
1588
+ }
1589
+ if (offset !== undefined) {
1590
+ params.append("offset", offset.toString());
1591
+ }
1592
+ if (filter !== undefined) {
1593
+ params.append("filter", filter);
1594
+ }
1595
+ let i = 0;
1586
1596
  for await (const examples of this._getPaginated("/examples", params)) {
1587
- yield* examples;
1597
+ for (const example of examples) {
1598
+ yield example;
1599
+ i++;
1600
+ }
1601
+ if (limit !== undefined && i >= limit) {
1602
+ break;
1603
+ }
1588
1604
  }
1589
1605
  }
1590
1606
  async deleteExample(exampleId) {
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.33";
9
+ exports.__version__ = "0.1.35";
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.33";
4
+ export declare const __version__ = "0.1.35";
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.33";
4
+ export const __version__ = "0.1.35";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langsmith",
3
- "version": "0.1.33",
3
+ "version": "0.1.35",
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": [