Skip to content

Commit

Permalink
pnpm format
Browse files Browse the repository at this point in the history
  • Loading branch information
hunterheston committed Nov 21, 2024
1 parent c445814 commit 631234e
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions js/plugins/checks/src/evaluation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,19 @@ export function checksEvaluators(

// Individual evaluators, one per configured metric.
const evaluators = policy_configs.map((policy_config) => {
return createPolicyEvaluator(projectId, auth, ai, [policy_config], policy_config.type as string);
return createPolicyEvaluator(
projectId,
auth,
ai,
[policy_config],
policy_config.type as string
);
});

// Single evaluator instnace with all configured policies.
evaluators.push(createPolicyEvaluator(projectId, auth, ai, policy_configs, "all_metrics"))
evaluators.push(
createPolicyEvaluator(projectId, auth, ai, policy_configs, 'all_metrics')
);

return evaluators;
}
Expand All @@ -109,9 +117,8 @@ function createPolicyEvaluator(
auth: GoogleAuth,
ai: Genkit,
policy_config: ChecksEvaluationMetricConfig[],
name: string,
name: string
): EvaluatorAction {

return ai.defineEvaluator(
{
name: `checks/${name.toLowerCase()}`,
Expand All @@ -125,11 +132,11 @@ function createPolicyEvaluator(
content: datapoint.output as string,
},
},
policies: policy_config.map(config => {
policies: policy_config.map((config) => {
return {
policy_type: config.type,
threshold: config.threshold,
}
};
}),
};

Expand All @@ -140,20 +147,20 @@ function createPolicyEvaluator(
ResponseSchema
);

const evaluationResults = response.policyResults.map(result => {
const evaluationResults = response.policyResults.map((result) => {
return {
id: result.policyType,
score: result.score,
details: {
reasoning: `Status ${result.violationResult}`,
},
}
};
});

return {
evaluation: evaluationResults,
testCaseId: datapoint.testCaseId
}
testCaseId: datapoint.testCaseId,
};
}
);
}
Expand Down

0 comments on commit 631234e

Please sign in to comment.