mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
feat: Add HallucinationsV1 evaluation metric
PiperOrigin-RevId: 813456369
This commit is contained in:
committed by
Copybara-Service
parent
a239716930
commit
8c73d29c75
@@ -39,7 +39,7 @@ class AgentDetails(EvalBaseModel):
|
||||
class AppDetails(EvalBaseModel):
|
||||
"""Contains details about the App (the agentic system).
|
||||
|
||||
This structure is only a projection of the acutal app. Only details
|
||||
This structure is only a projection of the actual app. Only details
|
||||
that are relevant to the Eval System are captured here.
|
||||
"""
|
||||
|
||||
|
||||
@@ -52,6 +52,8 @@ class PrebuiltMetrics(Enum):
|
||||
"rubric_based_final_response_quality_v1"
|
||||
)
|
||||
|
||||
HALLUCINATIONS_V1 = "hallucinations_v1"
|
||||
|
||||
RUBRIC_BASED_TOOL_USE_QUALITY_V1 = "rubric_based_tool_use_quality_v1"
|
||||
|
||||
|
||||
@@ -130,6 +132,24 @@ class RubricsBasedCriterion(BaseCriterion):
|
||||
)
|
||||
|
||||
|
||||
class HallucinationsCriterion(BaseCriterion):
|
||||
"""Criterion to use when evaluating agents response for hallucinations."""
|
||||
|
||||
judge_model_options: JudgeModelOptions = Field(
|
||||
default_factory=JudgeModelOptions,
|
||||
description="Options for the judge model.",
|
||||
)
|
||||
|
||||
evaluate_intermediate_nl_responses: bool = Field(
|
||||
default=False,
|
||||
description=(
|
||||
"Whether any intermediate NL responses should be evaluated"
|
||||
" for hallucinations or not. By default, the metric only evaluates"
|
||||
" final response from the Agent for hallucinations."
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
class EvalMetric(EvalBaseModel):
|
||||
"""A metric used to evaluate a particular aspect of an eval case."""
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -23,6 +23,7 @@ from .eval_metrics import MetricInfo
|
||||
from .eval_metrics import PrebuiltMetrics
|
||||
from .evaluator import Evaluator
|
||||
from .final_response_match_v2 import FinalResponseMatchV2Evaluator
|
||||
from .hallucinations_v1 import HallucinationsV1Evaluator
|
||||
from .response_evaluator import ResponseEvaluator
|
||||
from .rubric_based_final_response_quality_v1 import RubricBasedFinalResponseQualityV1Evaluator
|
||||
from .rubric_based_tool_use_quality_v1 import RubricBasedToolUseV1Evaluator
|
||||
@@ -117,6 +118,10 @@ def _get_default_metric_evaluator_registry() -> MetricEvaluatorRegistry:
|
||||
metric_info=RubricBasedFinalResponseQualityV1Evaluator.get_metric_info(),
|
||||
evaluator=RubricBasedFinalResponseQualityV1Evaluator,
|
||||
)
|
||||
metric_evaluator_registry.register_evaluator(
|
||||
metric_info=HallucinationsV1Evaluator.get_metric_info(),
|
||||
evaluator=HallucinationsV1Evaluator,
|
||||
)
|
||||
metric_evaluator_registry.register_evaluator(
|
||||
metric_info=RubricBasedToolUseV1Evaluator.get_metric_info(),
|
||||
evaluator=RubricBasedToolUseV1Evaluator,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user