8000 Adding Pydantic data models for eval set and eval case. · calvingiles/adk-python@1237d53 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1237d53

Browse files
ankursharmascopybara-github
authored andcommitted
Adding Pydantic data models for eval set and eval case.
PiperOrigin-RevId: 757920694
1 parent 993f997 commit 1237d53

File tree

2 files changed

+123
-0
lines changed

2 files changed

+123
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
16+
from typing import Any, Optional
17+
18+
from google.genai import types as genai_types
19+
from pydantic import BaseModel
20+
from pydantic import Field
21+
22+
23+
class IntermediateData(BaseModel):
24+
"""Container for intermediate data that an agent would generate as it responds with a final answer."""
25+
26+
tool_uses: list[genai_types.FunctionCall]
27+
"""Tool use trajectory in chronological order."""
28+
29+
intermediate_responses: list[genai_types.Part]
30+
"""Intermediate responses generated by sub-agents to convey progress or status
31+
in a multi-agent system, distinct from the final response."""
32+
33+
34+
class Invocation(BaseModel):
35+
"""Represents a single invocation."""
36+
37+
invocation_id: str = ''
38+
"""Unique identifier for the invocation."""
39+
40+
user_content: genai_types.Content
41+
"""Content provided by the user in this invocation."""
42+
43+
final_response: Optional[genai_types.Content]
44+
"""Final response from the agent that acts a reference or benchmark."""
45+
46+
intermediate_data: IntermediateData
47+
"""Reference intermediate steps generated as a part of Agent execution.
48+
49+
For a multi-agent system, it is also helpful to inspect the route that
50+
the agent took to generate final response.
51+
"""
52+
53+
creation_timestamp: float = 0.0
54+
"""Timestamp for the current invocation, primarily intended for debugging purposes."""
55+
56+
57+
class SessionInput(BaseModel):
58+
"""Values that help initialize a Session."""
59+
60+
app_name: str
61+
"""The name of the app."""
62+
63+
user_id: str
64+
"""The user id."""
65+
66+
state: dict[str, Any] = Field(default_factory=dict)
67+
"""The state of the session."""
68+
69+
70+
class EvalCase(BaseModel):
71+
"""An eval case."""
72+
73+
eval_id: str
74+
"""Unique identifier for the evaluation case."""
75+
76+
conversation: list[Invocation]
77+
"""A conversation between the user and the Agent. The conversation can have any number of invocations."""
78+
79+
session_input: SessionInput
80+
"""Session input that will be passed on to the Agent during eval.
81+
It is common for Agents state to be initialized to some initial/default value,
82+
for example, your agent may need to know today's date.
83+
"""
84+
85+
creation_timestamp: float = 0.0
86+
"""The time at which this eval case was created."""

src/google/adk/evaluation/eval_set.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from typing import Optional
16+
from pydantic import BaseModel
17+
from .eval_case import EvalCase
18+
19+
20+
class EvalSet(BaseModel):
21+
"""A set of eval cases."""
22+
23+
eval_set_id: str
24+
"""Unique identifier for the eval set."""
25+
26+
name: Optional[str]
27+
"""Name of the dataset."""
28+
29+
description: Optional[str]
30+
"""Description of the dataset."""
31+
32+
eval_cases: list[EvalCase]
33+
"""List of eval cases in the dataset. Each case represents a single
34+
interaction to be evaluated."""
35+
36+
creation_timestamp: float = 0.0
37+
"""The time at which this eval set was created."""

0 commit comments

Comments
 (0)
0