@outputai/evals 0.10.0 → 0.10.1-next.09ed166.0

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.
@@ -20,14 +20,14 @@ export function evalWorkflow({ name, evals, fn, config = {} }) {
20
20
  };
21
21
  });
22
22
  const defaultFn = async function (input) {
23
- const { invokeEvaluator } = this;
23
+ const invoke = globalThis[Symbol.for('@outputai/core:__invoke_activity')];
24
24
  const jobs = input.datasets.map((dataset) => async () => {
25
25
  const evaluatorResults = [];
26
26
  for (const evalDef of evalDefs) {
27
27
  const { evals: perEvalTruth, ...globalTruth } = dataset.ground_truth ?? {};
28
28
  const evalTruth = perEvalTruth?.[evalDef.name] ?? {};
29
29
  const mergedTruth = { ...globalTruth, ...evalTruth };
30
- const result = await invokeEvaluator(evalDef.name, {
30
+ const result = await invoke(evalDef.name, {
31
31
  input: dataset.input,
32
32
  output: dataset.last_output?.output,
33
33
  ground_truth: mergedTruth
@@ -1,5 +1,6 @@
1
1
  import { describe, it, expect, vi, beforeEach } from 'vitest';
2
2
  import { evalWorkflow } from './eval_workflow.js';
3
+ const INVOKE_ACTIVITY_SYMBOL = Symbol.for('@outputai/core:__invoke_activity');
3
4
  const workflowMock = vi.hoisted(() => vi.fn(({ fn }) => fn));
4
5
  const executeInParallelMock = vi.hoisted(() => vi.fn(async ({ jobs }) => {
5
6
  const results = await Promise.all(jobs.map(async (job) => ({ ok: true, result: await job() })));
@@ -24,6 +25,7 @@ vi.mock('@outputai/core/sdk/helpers', () => ({
24
25
  describe('evalWorkflow', () => {
25
26
  beforeEach(() => {
26
27
  vi.clearAllMocks();
28
+ delete globalThis[INVOKE_ACTIVITY_SYMBOL];
27
29
  hasMock.mockReturnValue(true);
28
30
  getNameMock.mockReturnValue('quality_eval');
29
31
  });
@@ -36,8 +38,9 @@ describe('evalWorkflow', () => {
36
38
  interpret: { type: 'boolean' }
37
39
  }]
38
40
  });
39
- const invokeEvaluator = vi.fn().mockResolvedValue({ value: true, confidence: 1, feedback: [], dimensions: [] });
40
- const output = await workflowFn.call({ invokeEvaluator }, {
41
+ const invokeActivity = vi.fn().mockResolvedValue({ value: true, confidence: 1, feedback: [], dimensions: [] });
42
+ globalThis[INVOKE_ACTIVITY_SYMBOL] = invokeActivity;
43
+ const output = await workflowFn({
41
44
  datasets: [{
42
45
  name: 'case_1',
43
46
  input: { prompt: 'hello' },
@@ -52,7 +55,7 @@ describe('evalWorkflow', () => {
52
55
  });
53
56
  expect(hasMock).toHaveBeenCalledWith(evaluator);
54
57
  expect(getNameMock).toHaveBeenCalledWith(evaluator);
55
- expect(invokeEvaluator).toHaveBeenCalledWith('quality_eval', {
58
+ expect(invokeActivity).toHaveBeenCalledWith('quality_eval', {
56
59
  input: { prompt: 'hello' },
57
60
  output: { answer: 'hello' },
58
61
  ground_truth: { shared: 'value', expected: 'hello' }
@@ -9,8 +9,8 @@
9
9
  * The webpack rewriter (workflow_rewriter/index.mjs) is supposed to strip evaluator
10
10
  * imports from the AST via collectTargetImports(), which calls path.remove() on each
11
11
  * matched import declaration. However, after collecting imports, the rewriter checks
12
- * if rewriteFnBodies() performed any rewrites. For eval workflows — which have no
13
- * fn body, only a config object — rewriteFnBodies() returns false. When that happens,
12
+ * if rewriteActivityCalls() performed any rewrites. For eval workflows — which have no
13
+ * function-body activity calls, only a config object — rewriteActivityCalls() returns false. When that happens,
14
14
  * the rewriter returns the original source string unchanged (lines 46-48), discarding
15
15
  * the import stripping that collectTargetImports() already applied to the AST.
16
16
  *
@@ -26,8 +26,8 @@
26
26
  *
27
27
  * Remove when:
28
28
  * The workflow rewriter in sdk/core/src/worker/webpack_loaders/workflow_rewriter/index.mjs
29
- * is fixed to generate output from the modified AST even when rewriteFnBodies() returns
30
- * false — i.e. when collectTargetImports() stripped imports but no fn bodies needed
29
+ * is fixed to generate output from the modified AST even when rewriteActivityCalls() returns
30
+ * false — i.e. when collectTargetImports() stripped imports but no activity calls needed
31
31
  * rewriting. This also requires injecting metadata stubs for the stripped evaluator
32
32
  * references, since evalWorkflow() calls ComponentMetadata.getName(def.evaluator) at
33
33
  * module init time and the identifiers would otherwise be undefined. Once the rewriter
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@outputai/evals",
3
- "version": "0.10.0",
3
+ "version": "0.10.1-next.09ed166.0",
4
4
  "description": "Offline evaluation framework for Output.ai workflows",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -19,8 +19,8 @@
19
19
  "./dist"
20
20
  ],
21
21
  "dependencies": {
22
- "@outputai/core": "0.10.0",
23
- "@outputai/llm": "0.10.0"
22
+ "@outputai/core": "0.10.1-next.09ed166.0",
23
+ "@outputai/llm": "0.10.1-next.09ed166.0"
24
24
  },
25
25
  "license": "Apache-2.0",
26
26
  "publishConfig": {