feat: Added an Fast API new endpoint to serve eval metric info

This endpoint could be used by ADK Web to dynamically know:
- What are the available eval metrics in an App
- A description of those metrics
- A value range supported by those metrics

We also update the metric registry to make it mandatory to supply these details. The goal is to improve usability and interpretability of the eval metrics.

PiperOrigin-RevId: 787277695
This commit is contained in:
Ankur Sharma
2025-07-25 16:25:20 -07:00
committed by Copybara-Service
parent ec7d9b0ff6
commit c69dcf8779
16 changed files with 394 additions and 54 deletions
@@ -16,6 +16,7 @@
import math
from google.adk.evaluation.eval_metrics import PrebuiltMetrics
from google.adk.evaluation.trajectory_evaluator import TrajectoryEvaluator
import pytest
@@ -270,3 +271,13 @@ def test_are_tools_equal_one_empty_one_not():
list_a = []
list_b = [TOOL_GET_WEATHER]
assert not TrajectoryEvaluator.are_tools_equal(list_a, list_b)
def test_get_metric_info():
"""Test get_metric_info function for tool trajectory avg metric."""
metric_info = TrajectoryEvaluator.get_metric_info()
assert (
metric_info.metric_name == PrebuiltMetrics.TOOL_TRAJECTORY_AVG_SCORE.value
)
assert metric_info.metric_value_info.interval.min_value == 0.0
assert metric_info.metric_value_info.interval.max_value == 1.0