langsmith 0.3.9-rc.2 → 0.3.9-rc.3

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.
@@ -43,15 +43,20 @@ function wrapEvaluator(evaluator) {
43
43
  else {
44
44
  evalResult = await evaluator(input);
45
45
  }
46
- if (isEvaluationResult(evalResult)) {
47
- (0, globals_js_1._logTestFeedback)({
48
- exampleId: context?.currentExample?.id,
49
- feedback: evalResult,
50
- context,
51
- runTree: currentRunTree,
52
- client: context.client,
53
- sourceRunId: evalRunId,
54
- });
46
+ if (!Array.isArray(evalResult)) {
47
+ evalResult = [evalResult];
48
+ }
49
+ for (const result of evalResult) {
50
+ if (isEvaluationResult(result)) {
51
+ (0, globals_js_1._logTestFeedback)({
52
+ exampleId: context?.currentExample?.id,
53
+ feedback: result,
54
+ context,
55
+ runTree: currentRunTree,
56
+ client: context.client,
57
+ sourceRunId: evalRunId,
58
+ });
59
+ }
55
60
  }
56
61
  return evalResult;
57
62
  };
@@ -73,6 +78,9 @@ async function evaluatedBy(outputs, evaluator) {
73
78
  referenceOutputs: context?.currentExample?.outputs ?? {},
74
79
  outputs,
75
80
  }, { runId: evalRunId });
81
+ if (Array.isArray(evalResult)) {
82
+ return evalResult.map((result) => result.score);
83
+ }
76
84
  return evalResult.score;
77
85
  }
78
86
  exports.evaluatedBy = evaluatedBy;
@@ -6,7 +6,7 @@ export type SimpleEvaluatorParams = {
6
6
  outputs: Record<string, any>;
7
7
  };
8
8
  export type SimpleEvaluator = (params: SimpleEvaluatorParams) => SimpleEvaluationResult | Promise<SimpleEvaluationResult>;
9
- export declare function wrapEvaluator<I>(evaluator: (input: I) => SimpleEvaluationResult | Promise<SimpleEvaluationResult>): (input: I, config?: Partial<RunTreeConfig> & {
9
+ export declare function wrapEvaluator<I>(evaluator: (input: I) => SimpleEvaluationResult | SimpleEvaluationResult[] | Promise<SimpleEvaluationResult | SimpleEvaluationResult[]>): (input: I, config?: Partial<RunTreeConfig> & {
10
10
  runId?: string;
11
- }) => Promise<SimpleEvaluationResult>;
12
- export declare function evaluatedBy(outputs: any, evaluator: SimpleEvaluator): Promise<NonNullable<import("../../../schemas.js").ScoreType | undefined>>;
11
+ }) => Promise<SimpleEvaluationResult | SimpleEvaluationResult[]>;
12
+ export declare function evaluatedBy(outputs: any, evaluator: SimpleEvaluator): Promise<NonNullable<import("../../../schemas.js").ScoreType | undefined> | NonNullable<import("../../../schemas.js").ScoreType | undefined>[]>;
@@ -40,15 +40,20 @@ export function wrapEvaluator(evaluator) {
40
40
  else {
41
41
  evalResult = await evaluator(input);
42
42
  }
43
- if (isEvaluationResult(evalResult)) {
44
- _logTestFeedback({
45
- exampleId: context?.currentExample?.id,
46
- feedback: evalResult,
47
- context,
48
- runTree: currentRunTree,
49
- client: context.client,
50
- sourceRunId: evalRunId,
51
- });
43
+ if (!Array.isArray(evalResult)) {
44
+ evalResult = [evalResult];
45
+ }
46
+ for (const result of evalResult) {
47
+ if (isEvaluationResult(result)) {
48
+ _logTestFeedback({
49
+ exampleId: context?.currentExample?.id,
50
+ feedback: result,
51
+ context,
52
+ runTree: currentRunTree,
53
+ client: context.client,
54
+ sourceRunId: evalRunId,
55
+ });
56
+ }
52
57
  }
53
58
  return evalResult;
54
59
  };
@@ -69,5 +74,8 @@ export async function evaluatedBy(outputs, evaluator) {
69
74
  referenceOutputs: context?.currentExample?.outputs ?? {},
70
75
  outputs,
71
76
  }, { runId: evalRunId });
77
+ if (Array.isArray(evalResult)) {
78
+ return evalResult.map((result) => result.score);
79
+ }
72
80
  return evalResult.score;
73
81
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langsmith",
3
- "version": "0.3.9-rc.2",
3
+ "version": "0.3.9-rc.3",
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": [