@@ -841,13 +841,21 @@ const result = await optimizer.compile(
841841 multiMetric as any ,
842842 {
843843 validationExamples: val ,
844+ feedbackExamples: val ,
845+ feedbackFn : ({ prediction , example }) =>
846+ prediction ?.isSafe === example ?.isSafe
847+ ? ' ✅ Matched label'
848+ : [
849+ ` Expected: ${example ?.isSafe ?? ' unknown' } ` ,
850+ ` Received: ${prediction ?.isSafe ?? ' unknown' } ` ,
851+ ],
844852 // Required to bound evaluation cost
845853 maxMetricCalls: 200 ,
846854 // Optional: provide a tie-break scalarizer for selection logic
847855 // paretoMetricKey: 'accuracy',
848856 // or
849857 // paretoScalarize: (s) => 0.7*s.accuracy + 0.3*s.brevity,
850- } as any
858+ }
851859);
852860
853861console .log (` ✅ Found ${result .paretoFrontSize } Pareto points ` );
@@ -904,6 +912,10 @@ if (result.optimizedProgram) {
904912}
905913```
906914
915+ > 💡 ** Feedback hook** : ` feedbackFn ` lets you surface rich guidance for each evaluation, whether it's a short string or multiple
916+ > bullet points. The hook receives the raw ` prediction ` and original ` example ` , making it easy to emit reviewer-style comments
917+ > alongside scores. Pair it with ` feedbackExamples ` to keep cost-efficient review sets separate from validation metrics.
918+
907919#### GEPA-Flow (Multi-Module)
908920
909921``` typescript
@@ -917,7 +929,7 @@ const pipeline = flow<{ emailText: string }>()
917929 .m ((s ) => ({ priority: s .classifierResult .priority , rationale: s .rationaleResult .rationale }));
918930
919931const optimizer = new AxGEPAFlow ({ studentAI: ai ({ name: ' openai' , apiKey: process .env .OPENAI_APIKEY ! , config: { model: ' gpt-4o-mini' } }), numTrials: 16 });
920- const result = await optimizer .compile (pipeline as any , train , multiMetric as any , { validationExamples: val , maxMetricCalls: 240 } as any );
932+ const result = await optimizer .compile (pipeline as any , train , multiMetric as any , { validationExamples: val , maxMetricCalls: 240 });
921933console .log (` Front size: ${result .paretoFrontSize }, Hypervolume: ${result .hypervolume } ` );
922934```
923935
@@ -976,7 +988,7 @@ const multiMetric = ({ prediction, example }) => ({
976988#### Understanding the Results
977989
978990``` typescript
979- const result = await optimizer .compile (program , examples , multiMetric , { maxMetricCalls: 200 } as any );
991+ const result = await optimizer .compile (program , examples , multiMetric , { maxMetricCalls: 200 });
980992
981993// Key properties of AxParetoResult:
982994console .log (` Pareto frontier size: ${result .paretoFrontSize } ` );
0 commit comments