feat: add RAGAS adapter for third-party eval metrics - #618
Conversation
jariy17
left a comment
There was a problem hiding this comment.
YOu have merge conflicts and small nit
| assert result.value is not None | ||
|
|
||
|
|
||
| def _make_ragas_evaluator_input(user_prompt, agent_response): |
There was a problem hiding this comment.
Good catch — switched to _make_agent_evaluator_input in the latest push. The separate helper was a leftover from earlier development when the shared one used a span format the mappers couldn't parse, but that's been fixed on main since. All ragas integ tests should now use the shared helper.
Remove the ragas-specific _make_ragas_evaluator_input helper — the shared _make_agent_evaluator_input now uses the correct CloudWatch span format that the span mappers support.
309f760 to
8823edf
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #618 +/- ##
=======================================
Coverage ? 88.56%
=======================================
Files ? 120
Lines ? 10023
Branches ? 1527
=======================================
Hits ? 8877
Misses ? 763
Partials ? 383
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Adds
RAGASAdapterto the third-party evaluation adapters, alongside the existingDeepEvalAdapterandAutoEvalsAdapter. Wraps any RAGAS metric as an AgentCore code-based Lambda evaluator with the sameBaseAdapterpattern.Design
Scores metrics through RAGAS's per-sample APIs (
metric.single_turn_score()/metric.multi_turn_score()for legacy metrics,metric.score(**kwargs)forragas.metrics.collectionsmetrics) rather than the batchragas.evaluate()pipeline. This means the adapter itself adds no dependency ondatasets/pyarrow/pandas, which makes it compatible with slim ragas builds for size-constrained Lambda deployments.Three-way dispatch:
SingleTurnSample+single_turn_score()MultiTurnSample+multi_turn_score()ragas.metrics.collections,@discrete_metric,@numeric_metric):metric.score(**fields)with signature-based field filteringFeatures
metric.required_columnsbefore scoring — returnsMISSING_REQUIRED_FIELDwith actionable guidance instead of letting ragas return silent 0.0 scores\n\nReference Answer:\nand\n\nContext:\nseparators) since ADOT trace formats have no dedicated fields for thesethreshold=Nonemetrics (e.g. SemanticSimilarity) and provides an adapter-levelthreshold=override for collections metrics which carry noneMetricResult.reasonas the explanationImportErrorat score time returnsMISSING_DEPENDENCY(not a generic crash)RAGASAdapteris the canonical class;RagasAdapteralias providedUsage
Known Limitations
reference_contexts(ground-truth contexts for reference-comparison metrics) is not defaulted from retrieved contexts — supply it viacustom_mapperwhen a genuine ground-truth source existsreference_tool_callsbuilt fromexpected_trajectory.toolNamescarry names without arguments; arg-accurate comparison needs acustom_mapperwith fullToolCallobjectsreference_topics(TopicAdherenceScore) has no span source — requirescustom_mapperdatasetswhen the ragas package is imported; the adapter is compatible with trimmed builds but does not solve that import itselfDependency Notes
ragas>=0.4.3,<1.0.0— the tested version rangelangchain-community>=0.3.0,<0.4.2— langchain-community 0.4.2 removedchat_models.vertexai, which ragas <1.0 imports unconditionallyragasto the evaluation integ testextra-depsin CIuv.lockregenerated for the new extra; incidental bumps tolangchain-communityresolution onlyTesting
@discrete_metric, ToolCallAccuracy match/mismatch, adapter-imports-without-datasets)uv lock --checkpasses