langsmith 0.3.10 → 0.3.11

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
@@ -2464,6 +2464,9 @@ class Client {
2464
2464
  if ("results" in results) {
2465
2465
  results_ = results.results;
2466
2466
  }
2467
+ else if (Array.isArray(results)) {
2468
+ results_ = results;
2469
+ }
2467
2470
  else {
2468
2471
  results_ = [results];
2469
2472
  }
package/dist/client.d.ts CHANGED
@@ -679,11 +679,11 @@ export declare class Client implements LangSmithTracingClientInterface {
679
679
  * @returns An async iterable of FeedbackIngestToken objects.
680
680
  */
681
681
  listPresignedFeedbackTokens(runId: string): AsyncIterable<FeedbackIngestToken>;
682
- _selectEvalResults(results: EvaluationResult | EvaluationResults): Array<EvaluationResult>;
683
- _logEvaluationFeedback(evaluatorResponse: EvaluationResult | EvaluationResults, run?: Run, sourceInfo?: {
682
+ _selectEvalResults(results: EvaluationResult | EvaluationResult[] | EvaluationResults): Array<EvaluationResult>;
683
+ _logEvaluationFeedback(evaluatorResponse: EvaluationResult | EvaluationResult[] | EvaluationResults, run?: Run, sourceInfo?: {
684
684
  [key: string]: any;
685
685
  }): Promise<[results: EvaluationResult[], feedbacks: Feedback[]]>;
686
- logEvaluationFeedback(evaluatorResponse: EvaluationResult | EvaluationResults, run?: Run, sourceInfo?: {
686
+ logEvaluationFeedback(evaluatorResponse: EvaluationResult | EvaluationResult[] | EvaluationResults, run?: Run, sourceInfo?: {
687
687
  [key: string]: any;
688
688
  }): Promise<EvaluationResult[]>;
689
689
  /**
package/dist/client.js CHANGED
@@ -2436,6 +2436,9 @@ export class Client {
2436
2436
  if ("results" in results) {
2437
2437
  results_ = results.results;
2438
2438
  }
2439
+ else if (Array.isArray(results)) {
2440
+ results_ = results;
2441
+ }
2439
2442
  else {
2440
2443
  results_ = [results];
2441
2444
  }
@@ -15,28 +15,28 @@ type ComparativeTargetT = Array<string> | Array<Promise<ExperimentResults> | Exp
15
15
  export type TargetT<TInput = any, TOutput = KVMap> = StandardTargetT<TInput, TOutput> | ComparativeTargetT;
16
16
  export type DataT = string | AsyncIterable<Example> | Example[];
17
17
  /** @deprecated Use object parameter version instead: (args: { runs, examples, inputs, outputs, referenceOutputs }) => ... */
18
- type DeprecatedSyncSummaryEvaluator = (runs: Array<Run>, examples: Array<Example>) => EvaluationResult | EvaluationResults;
18
+ type DeprecatedSyncSummaryEvaluator = (runs: Array<Run>, examples: Array<Example>) => EvaluationResult | EvaluationResult[] | EvaluationResults;
19
19
  /** @deprecated Use object parameter version instead: (args: { runs, examples, inputs, outputs, referenceOutputs }) => ... */
20
- type DeprecatedAsyncSummaryEvaluator = (runs: Array<Run>, examples: Array<Example>) => Promise<EvaluationResult | EvaluationResults>;
20
+ type DeprecatedAsyncSummaryEvaluator = (runs: Array<Run>, examples: Array<Example>) => Promise<EvaluationResult | EvaluationResult[] | EvaluationResults>;
21
21
  export type SummaryEvaluatorT = DeprecatedSyncSummaryEvaluator | DeprecatedAsyncSummaryEvaluator | ((args: {
22
22
  runs: Array<Run>;
23
23
  examples: Array<Example>;
24
24
  inputs: Array<Record<string, any>>;
25
25
  outputs: Array<Record<string, any>>;
26
26
  referenceOutputs?: Array<Record<string, any>>;
27
- }) => EvaluationResult | EvaluationResults) | ((args: {
27
+ }) => EvaluationResult | EvaluationResult[] | EvaluationResults) | ((args: {
28
28
  runs: Array<Run>;
29
29
  examples: Array<Example>;
30
30
  inputs: Array<Record<string, any>>;
31
31
  outputs: Array<Record<string, any>>;
32
32
  referenceOutputs?: Array<Record<string, any>>;
33
- }) => Promise<EvaluationResult | EvaluationResults>);
33
+ }) => Promise<EvaluationResult | EvaluationResult[] | EvaluationResults>);
34
34
  /** @deprecated Use object parameter version instead: (args: { run, example, inputs, outputs, referenceOutputs }) => ... */
35
35
  type DeprecatedRunEvaluator = RunEvaluator;
36
36
  /** @deprecated Use object parameter version instead: (args: { run, example, inputs, outputs, referenceOutputs }) => ... */
37
- type DeprecatedFunctionEvaluator = (run: Run, example?: Example) => EvaluationResult | EvaluationResults;
37
+ type DeprecatedFunctionEvaluator = (run: Run, example?: Example) => EvaluationResult | EvaluationResult[] | EvaluationResults;
38
38
  /** @deprecated Use object parameter version instead: (args: { run, example, inputs, outputs, referenceOutputs }) => ... */
39
- type DeprecatedAsyncFunctionEvaluator = (run: Run, example?: Example) => Promise<EvaluationResult | EvaluationResults>;
39
+ type DeprecatedAsyncFunctionEvaluator = (run: Run, example?: Example) => Promise<EvaluationResult | EvaluationResult[] | EvaluationResults>;
40
40
  export type EvaluatorT = DeprecatedRunEvaluator | DeprecatedFunctionEvaluator | DeprecatedAsyncFunctionEvaluator | ((args: {
41
41
  run: Run;
42
42
  example: Example;
@@ -44,14 +44,14 @@ export type EvaluatorT = DeprecatedRunEvaluator | DeprecatedFunctionEvaluator |
44
44
  outputs: Record<string, any>;
45
45
  referenceOutputs?: Record<string, any>;
46
46
  attachments?: Record<string, any>;
47
- }) => EvaluationResult | EvaluationResults) | ((args: {
47
+ }) => EvaluationResult | EvaluationResult[] | EvaluationResults) | ((args: {
48
48
  run: Run;
49
49
  example: Example;
50
50
  inputs: Record<string, any>;
51
51
  outputs: Record<string, any>;
52
52
  referenceOutputs?: Record<string, any>;
53
53
  attachments?: Record<string, any>;
54
- }) => Promise<EvaluationResult | EvaluationResults>);
54
+ }) => Promise<EvaluationResult | EvaluationResult[] | EvaluationResults>);
55
55
  interface _ForwardResults {
56
56
  run: Run;
57
57
  example: Example;
@@ -82,11 +82,11 @@ class DynamicRunEvaluator {
82
82
  id: sourceRunId,
83
83
  ...options,
84
84
  });
85
- const result = (await wrappedTraceableFunc(
85
+ const result = await wrappedTraceableFunc(
86
86
  // Pass data via `langSmithRunAndExample` key to avoid conflicts with other
87
87
  // inputs. This key is extracted in the wrapped function, with `run` and
88
88
  // `example` passed to evaluator function as arguments.
89
- { langSmithRunAndExample: { run, example } }, { metadata }));
89
+ { langSmithRunAndExample: { run, example } }, { metadata });
90
90
  // Check the one required property of EvaluationResult since 'instanceof' is not possible
91
91
  if ("key" in result) {
92
92
  if (!result.sourceRunId) {
@@ -94,6 +94,11 @@ class DynamicRunEvaluator {
94
94
  }
95
95
  return result;
96
96
  }
97
+ if (Array.isArray(result)) {
98
+ return {
99
+ results: result.map((r) => this.coerceEvaluationResult(r, sourceRunId, false)),
100
+ };
101
+ }
97
102
  if (typeof result !== "object") {
98
103
  throw new Error("Evaluator function must return an object.");
99
104
  }
@@ -72,19 +72,19 @@ export type EvaluationResults = {
72
72
  export interface RunEvaluator {
73
73
  evaluateRun(run: Run, example?: Example, options?: Partial<RunTreeConfig>): Promise<EvaluationResult | EvaluationResults>;
74
74
  }
75
- export type RunEvaluatorLike = ((run: Run, example?: Example) => Promise<EvaluationResult | EvaluationResults>) | ((run: Run, example?: Example) => EvaluationResult | EvaluationResults) | ((run: Run, example: Example) => Promise<EvaluationResult | EvaluationResults>) | ((run: Run, example: Example) => EvaluationResult | EvaluationResults) | ((args: {
75
+ export type RunEvaluatorLike = ((run: Run, example?: Example) => Promise<EvaluationResult | EvaluationResult[] | EvaluationResults>) | ((run: Run, example?: Example) => EvaluationResult | EvaluationResult[] | EvaluationResults) | ((run: Run, example: Example) => Promise<EvaluationResult | EvaluationResult[] | EvaluationResults>) | ((run: Run, example: Example) => EvaluationResult | EvaluationResult[] | EvaluationResults) | ((args: {
76
76
  run: Run;
77
77
  example: Example;
78
78
  inputs: Record<string, any>;
79
79
  outputs: Record<string, any>;
80
80
  referenceOutputs?: Record<string, any>;
81
- }) => EvaluationResult | EvaluationResults) | ((args: {
81
+ }) => EvaluationResult | EvaluationResult[] | EvaluationResults) | ((args: {
82
82
  run: Run;
83
83
  example: Example;
84
84
  inputs: Record<string, any>;
85
85
  outputs: Record<string, any>;
86
86
  referenceOutputs?: Record<string, any>;
87
- }) => Promise<EvaluationResult | EvaluationResults>);
87
+ }) => Promise<EvaluationResult | EvaluationResult[] | EvaluationResults>);
88
88
  /**
89
89
  * Wraps an evaluator function + implements the RunEvaluator interface.
90
90
  */
@@ -79,11 +79,11 @@ export class DynamicRunEvaluator {
79
79
  id: sourceRunId,
80
80
  ...options,
81
81
  });
82
- const result = (await wrappedTraceableFunc(
82
+ const result = await wrappedTraceableFunc(
83
83
  // Pass data via `langSmithRunAndExample` key to avoid conflicts with other
84
84
  // inputs. This key is extracted in the wrapped function, with `run` and
85
85
  // `example` passed to evaluator function as arguments.
86
- { langSmithRunAndExample: { run, example } }, { metadata }));
86
+ { langSmithRunAndExample: { run, example } }, { metadata });
87
87
  // Check the one required property of EvaluationResult since 'instanceof' is not possible
88
88
  if ("key" in result) {
89
89
  if (!result.sourceRunId) {
@@ -91,6 +91,11 @@ export class DynamicRunEvaluator {
91
91
  }
92
92
  return result;
93
93
  }
94
+ if (Array.isArray(result)) {
95
+ return {
96
+ results: result.map((r) => this.coerceEvaluationResult(r, sourceRunId, false)),
97
+ };
98
+ }
94
99
  if (typeof result !== "object") {
95
100
  throw new Error("Evaluator function must return an object.");
96
101
  }
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.3.10";
11
+ exports.__version__ = "0.3.11";
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.3.10";
5
+ export declare const __version__ = "0.3.11";
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.3.10";
5
+ export const __version__ = "0.3.11";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langsmith",
3
- "version": "0.3.10",
3
+ "version": "0.3.11",
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": [