chore: Add alias_generators to new Eval pydantic models

PiperOrigin-RevId: 759346603
This commit is contained in:
Google Team Member 2025-05-15 16:20:48 -07:00 committed by Copybara-Service
parent d27fe90d37
commit 4d5760917d
2 changed files with 15 additions and 6 deletions

View File

@ -38,7 +38,7 @@ from .utils import common
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
class EvalMetric(BaseModel): class EvalMetric(common.BaseModel):
"""A metric used to evaluate a particular aspect of an eval case.""" """A metric used to evaluate a particular aspect of an eval case."""
metric_name: str metric_name: str
@ -55,7 +55,7 @@ class EvalMetricResult(EvalMetric):
eval_status: EvalStatus eval_status: EvalStatus
class EvalMetricResultPerInvocation(BaseModel): class EvalMetricResultPerInvocation(common.BaseModel):
"""Eval metric results per invocation.""" """Eval metric results per invocation."""
actual_invocation: Invocation actual_invocation: Invocation

View File

@ -16,11 +16,20 @@
from typing import Any, Optional, Tuple from typing import Any, Optional, Tuple
from google.genai import types as genai_types from google.genai import types as genai_types
from pydantic import alias_generators
from pydantic import BaseModel from pydantic import BaseModel
from pydantic import ConfigDict
from pydantic import Field from pydantic import Field
class IntermediateData(BaseModel): class EvalBaseModel(BaseModel):
model_config = ConfigDict(
alias_generator=alias_generators.to_camel,
populate_by_name=True,
)
class IntermediateData(EvalBaseModel):
"""Container for intermediate data that an agent would generate as it responds with a final answer.""" """Container for intermediate data that an agent would generate as it responds with a final answer."""
tool_uses: list[genai_types.FunctionCall] = [] tool_uses: list[genai_types.FunctionCall] = []
@ -38,7 +47,7 @@ class IntermediateData(BaseModel):
""" """
class Invocation(BaseModel): class Invocation(EvalBaseModel):
"""Represents a single invocation.""" """Represents a single invocation."""
invocation_id: str = '' invocation_id: str = ''
@ -61,7 +70,7 @@ class Invocation(BaseModel):
"""Timestamp for the current invocation, primarily intended for debugging purposes.""" """Timestamp for the current invocation, primarily intended for debugging purposes."""
class SessionInput(BaseModel): class SessionInput(EvalBaseModel):
"""Values that help initialize a Session.""" """Values that help initialize a Session."""
app_name: str app_name: str
@ -74,7 +83,7 @@ class SessionInput(BaseModel):
"""The state of the session.""" """The state of the session."""
class EvalCase(BaseModel): class EvalCase(EvalBaseModel):
"""An eval case.""" """An eval case."""
eval_id: str eval_id: str