langsmith 0.3.9-rc.2 → 0.3.9-rc.4

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.
@@ -372,7 +372,7 @@ function generateWrapperFromJestlikeMethods(methods, testRunnerName) {
372
372
  }
373
373
  const { dataset, createdAt, project, client, experimentUrl } = datasetSetupInfo.get(context.suiteUuid);
374
374
  const testInput = inputs;
375
- const testOutput = referenceOutputs;
375
+ const testOutput = referenceOutputs ?? {};
376
376
  const testFeedback = [];
377
377
  const onFeedbackLogged = (feedback) => testFeedback.push(feedback);
378
378
  let loggedOutput;
@@ -459,7 +459,7 @@ function generateWrapperFromJestlikeMethods(methods, testRunnerName) {
459
459
  exampleId,
460
460
  datasetId: dataset.id,
461
461
  inputs,
462
- outputs: referenceOutputs,
462
+ outputs: referenceOutputs ?? {},
463
463
  metadata: {},
464
464
  createdAt,
465
465
  }));
@@ -337,7 +337,7 @@ export function generateWrapperFromJestlikeMethods(methods, testRunnerName) {
337
337
  }
338
338
  const { dataset, createdAt, project, client, experimentUrl } = datasetSetupInfo.get(context.suiteUuid);
339
339
  const testInput = inputs;
340
- const testOutput = referenceOutputs;
340
+ const testOutput = referenceOutputs ?? {};
341
341
  const testFeedback = [];
342
342
  const onFeedbackLogged = (feedback) => testFeedback.push(feedback);
343
343
  let loggedOutput;
@@ -424,7 +424,7 @@ export function generateWrapperFromJestlikeMethods(methods, testRunnerName) {
424
424
  exampleId,
425
425
  datasetId: dataset.id,
426
426
  inputs,
427
- outputs: referenceOutputs,
427
+ outputs: referenceOutputs ?? {},
428
428
  metadata: {},
429
429
  createdAt,
430
430
  }));
@@ -10,7 +10,7 @@ export type LangSmithJestlikeWrapperConfig = Partial<Omit<RunTreeConfig, "client
10
10
  };
11
11
  export type LangSmithJestlikeWrapperParams<I, O> = {
12
12
  inputs: I;
13
- referenceOutputs: O;
13
+ referenceOutputs?: O;
14
14
  config?: LangSmithJestlikeWrapperConfig;
15
15
  };
16
16
  export type LangSmithJestlikeDescribeWrapperConfig = {
@@ -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.4",
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": [