langsmith 0.1.49 → 0.1.51

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
@@ -202,7 +202,7 @@ class Client {
202
202
  writable: true,
203
203
  value: void 0
204
204
  });
205
- Object.defineProperty(this, "sampledPostUuids", {
205
+ Object.defineProperty(this, "filteredPostUuids", {
206
206
  enumerable: true,
207
207
  configurable: true,
208
208
  writable: true,
@@ -449,9 +449,11 @@ class Client {
449
449
  if (patch) {
450
450
  const sampled = [];
451
451
  for (const run of runs) {
452
- if (this.sampledPostUuids.has(run.id)) {
452
+ if (!this.filteredPostUuids.has(run.id)) {
453
453
  sampled.push(run);
454
- this.sampledPostUuids.delete(run.id);
454
+ }
455
+ else {
456
+ this.filteredPostUuids.delete(run.id);
455
457
  }
456
458
  }
457
459
  return sampled;
@@ -459,14 +461,13 @@ class Client {
459
461
  else {
460
462
  const sampled = [];
461
463
  for (const run of runs) {
462
- if (run.id !== run.trace_id) {
464
+ if ((run.id !== run.trace_id &&
465
+ !this.filteredPostUuids.has(run.trace_id)) ||
466
+ Math.random() < this.tracingSampleRate) {
463
467
  sampled.push(run);
464
- this.sampledPostUuids.add(run.id);
465
- continue;
466
468
  }
467
- if (Math.random() < this.tracingSampleRate) {
468
- sampled.push(run);
469
- this.sampledPostUuids.add(run.id);
469
+ else {
470
+ this.filteredPostUuids.add(run.id);
470
471
  }
471
472
  }
472
473
  return sampled;
@@ -1596,6 +1597,13 @@ class Client {
1596
1597
  * similar examples in order of most similar to least similar. If no similar
1597
1598
  * examples are found, random examples will be returned.
1598
1599
  *
1600
+ * @param filter A filter string to apply to the search. Only examples will be returned that
1601
+ * match the filter string. Some examples of filters
1602
+ *
1603
+ * - eq(metadata.mykey, "value")
1604
+ * - and(neq(metadata.my.nested.key, "value"), neq(metadata.mykey, "value"))
1605
+ * - or(eq(metadata.mykey, "value"), eq(metadata.mykey, "othervalue"))
1606
+ *
1599
1607
  * @returns A list of similar examples.
1600
1608
  *
1601
1609
  *
@@ -1605,11 +1613,14 @@ class Client {
1605
1613
  * limit = 5
1606
1614
  * examples = await client.similarExamples(inputs, dataset_id, limit)
1607
1615
  */
1608
- async similarExamples(inputs, datasetId, limit) {
1616
+ async similarExamples(inputs, datasetId, limit, { filter, } = {}) {
1609
1617
  const data = {
1610
1618
  limit: limit,
1611
1619
  inputs: inputs,
1612
1620
  };
1621
+ if (filter !== undefined) {
1622
+ data["filter"] = filter;
1623
+ }
1613
1624
  (0, _uuid_js_1.assertUuid)(datasetId);
1614
1625
  const response = await this.caller.call(fetch, `${this.apiUrl}/datasets/${datasetId}/search`, {
1615
1626
  method: "POST",
package/dist/client.d.ts CHANGED
@@ -166,7 +166,7 @@ export declare class Client {
166
166
  private hideInputs?;
167
167
  private hideOutputs?;
168
168
  private tracingSampleRate?;
169
- private sampledPostUuids;
169
+ private filteredPostUuids;
170
170
  private autoBatchTracing;
171
171
  private batchEndpointSupported?;
172
172
  private autoBatchQueue;
@@ -457,6 +457,13 @@ export declare class Client {
457
457
  * similar examples in order of most similar to least similar. If no similar
458
458
  * examples are found, random examples will be returned.
459
459
  *
460
+ * @param filter A filter string to apply to the search. Only examples will be returned that
461
+ * match the filter string. Some examples of filters
462
+ *
463
+ * - eq(metadata.mykey, "value")
464
+ * - and(neq(metadata.my.nested.key, "value"), neq(metadata.mykey, "value"))
465
+ * - or(eq(metadata.mykey, "value"), eq(metadata.mykey, "othervalue"))
466
+ *
460
467
  * @returns A list of similar examples.
461
468
  *
462
469
  *
@@ -466,7 +473,9 @@ export declare class Client {
466
473
  * limit = 5
467
474
  * examples = await client.similarExamples(inputs, dataset_id, limit)
468
475
  */
469
- similarExamples(inputs: KVMap, datasetId: string, limit: number): Promise<ExampleSearch[]>;
476
+ similarExamples(inputs: KVMap, datasetId: string, limit: number, { filter, }?: {
477
+ filter?: string;
478
+ }): Promise<ExampleSearch[]>;
470
479
  createExample(inputs: KVMap, outputs: KVMap, { datasetId, datasetName, createdAt, exampleId, metadata, split, }: CreateExampleOptions): Promise<Example>;
471
480
  createExamples(props: {
472
481
  inputs: Array<KVMap>;
package/dist/client.js CHANGED
@@ -175,7 +175,7 @@ export class Client {
175
175
  writable: true,
176
176
  value: void 0
177
177
  });
178
- Object.defineProperty(this, "sampledPostUuids", {
178
+ Object.defineProperty(this, "filteredPostUuids", {
179
179
  enumerable: true,
180
180
  configurable: true,
181
181
  writable: true,
@@ -422,9 +422,11 @@ export class Client {
422
422
  if (patch) {
423
423
  const sampled = [];
424
424
  for (const run of runs) {
425
- if (this.sampledPostUuids.has(run.id)) {
425
+ if (!this.filteredPostUuids.has(run.id)) {
426
426
  sampled.push(run);
427
- this.sampledPostUuids.delete(run.id);
427
+ }
428
+ else {
429
+ this.filteredPostUuids.delete(run.id);
428
430
  }
429
431
  }
430
432
  return sampled;
@@ -432,14 +434,13 @@ export class Client {
432
434
  else {
433
435
  const sampled = [];
434
436
  for (const run of runs) {
435
- if (run.id !== run.trace_id) {
437
+ if ((run.id !== run.trace_id &&
438
+ !this.filteredPostUuids.has(run.trace_id)) ||
439
+ Math.random() < this.tracingSampleRate) {
436
440
  sampled.push(run);
437
- this.sampledPostUuids.add(run.id);
438
- continue;
439
441
  }
440
- if (Math.random() < this.tracingSampleRate) {
441
- sampled.push(run);
442
- this.sampledPostUuids.add(run.id);
442
+ else {
443
+ this.filteredPostUuids.add(run.id);
443
444
  }
444
445
  }
445
446
  return sampled;
@@ -1569,6 +1570,13 @@ export class Client {
1569
1570
  * similar examples in order of most similar to least similar. If no similar
1570
1571
  * examples are found, random examples will be returned.
1571
1572
  *
1573
+ * @param filter A filter string to apply to the search. Only examples will be returned that
1574
+ * match the filter string. Some examples of filters
1575
+ *
1576
+ * - eq(metadata.mykey, "value")
1577
+ * - and(neq(metadata.my.nested.key, "value"), neq(metadata.mykey, "value"))
1578
+ * - or(eq(metadata.mykey, "value"), eq(metadata.mykey, "othervalue"))
1579
+ *
1572
1580
  * @returns A list of similar examples.
1573
1581
  *
1574
1582
  *
@@ -1578,11 +1586,14 @@ export class Client {
1578
1586
  * limit = 5
1579
1587
  * examples = await client.similarExamples(inputs, dataset_id, limit)
1580
1588
  */
1581
- async similarExamples(inputs, datasetId, limit) {
1589
+ async similarExamples(inputs, datasetId, limit, { filter, } = {}) {
1582
1590
  const data = {
1583
1591
  limit: limit,
1584
1592
  inputs: inputs,
1585
1593
  };
1594
+ if (filter !== undefined) {
1595
+ data["filter"] = filter;
1596
+ }
1586
1597
  assertUuid(datasetId);
1587
1598
  const response = await this.caller.call(fetch, `${this.apiUrl}/datasets/${datasetId}/search`, {
1588
1599
  method: "POST",
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.49";
9
+ exports.__version__ = "0.1.51";
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { Client, type ClientConfig } 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.49";
4
+ export declare const __version__ = "0.1.51";
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.49";
4
+ export const __version__ = "0.1.51";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langsmith",
3
- "version": "0.1.49",
3
+ "version": "0.1.51",
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": [