8000 chore: Migrate json field names to camelCase (4/4) · Syntax404-coder/adk-python@d6cf660 · GitHub
[go: up one dir, main page]

Skip to content

Commit d6cf660

Browse files
google-genai-botcopybara-github
authored andcommitted
chore: Migrate json field names to camelCase (4/4)
PiperOrigin-RevId: 758423361
1 parent 931fb33 commit d6cf660

File tree

6 files changed

+30
-10
lines changed

6 files changed

+30
-10
lines changed

src/google/adk/auth/auth_credential.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,18 @@
1515
from enum import Enum
1616
from typing import Any, Dict, List, Optional
1717

18+
from pydantic import alias_generators
1819
from pydantic import BaseModel
1920
from pydantic import ConfigDict
2021
from pydantic import Field
2122

2223

2324
class BaseModelWithConfig(BaseModel):
24-
model_config = ConfigDict(extra="allow")
25+
model_config = ConfigDict(
26+
extra="allow",
27+
alias_generator=alias_generators.to_camel,
28+
populate_by_name=True,
29+
)
2530
"""The pydantic model config."""
2631

2732

src/google/adk/auth/auth_tool.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
from pydantic import BaseModel
16-
1715
from .auth_credential import AuthCredential
16+
from .auth_credential import BaseModelWithConfig
1817
from .auth_schemes import AuthScheme
1918

2019

21-
class AuthConfig(BaseModel):
20+
class AuthConfig(BaseModelWithConfig):
2221
"""The auth config sent by tool asking client to collect auth credentials and
2322
2423
adk and client will help to fill in the response
@@ -45,7 +44,7 @@ class AuthConfig(BaseModel):
4544
this field"""
4645

4746

48-
class AuthToolArguments(BaseModel):
47+
class AuthToolArguments(BaseModelWithConfig):
4948
"""the arguments for the special long running function tool that is used to
5049
5150
request end user credentials.

src/google/adk/cli/cli_eval.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
from ..agents import Agent
3232
from ..sessions.session import Session
33+
from .utils import common
3334

3435
logger = logging.getLogger(__name__)
3536

@@ -50,7 +51,7 @@ class EvalMetricResult(BaseModel):
5051
eval_status: EvalStatus
5152

5253

53-
class EvalCaseResult(BaseModel):
54+
class EvalCaseResult(common.BaseModel):
5455
eval_set_file: str
5556
eval_id: str
5657
final_eval_status: EvalStatus
@@ -60,7 +61,7 @@ class EvalCaseResult(BaseModel):
6061
user_id: Optional[str] = None
6162

6263

63-
class EvalSetResult(BaseModel):
64+
class EvalSetResult(common.BaseModel):
6465
eval_set_result_id: str
6566
eval_set_result_name: str
6667
eval_set_id: str

src/google/adk/events/event.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from typing import Optional
2020

2121
from google.genai import types
22+
from pydantic import alias_generators
2223
from pydantic import ConfigDict
2324
from pydantic import Field
2425

@@ -46,7 +47,11 @@ class Event(LlmResponse):
4647
"""
4748

4849
model_config = ConfigDict(
49-
extra='forbid', ser_json_bytes='base64', val_json_bytes='base64'
50+
extra='forbid',
51+
ser_json_bytes='base64',
52+
val_json_bytes='base64',
53+
alias_generator=alias_generators.to_camel,
54+
populate_by_name=True,
5055
)
5156
"""The pydantic model config."""
5257

src/google/adk/events/event_actions.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
from typing import Optional
1818

19+
from pydantic import alias_generators
1920
from pydantic import BaseModel
2021
from pydantic import ConfigDict
2122
from pydantic import Field
@@ -26,7 +27,11 @@
2627
class EventActions(BaseModel):
2728
"""Represents the actions attached to an event."""
2829

29-
model_config = ConfigDict(extra='forbid')
30+
model_config = ConfigDict(
31+
extra='forbid',
32+
alias_generator=alias_generators.to_camel,
33+
populate_by_name=True,
34+
)
3035
"""The pydantic model config."""
3136

3237
skip_summarization: Optional[bool] = None

src/google/adk/models/llm_response.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from typing import Any, Optional
1818

1919
from google.genai import types
20+
from pydantic import alias_generators
2021
from pydantic import BaseModel
2122
from pydantic import ConfigDict
2223

@@ -40,7 +41,11 @@ class LlmResponse(BaseModel):
4041
custom_metadata: The custom metadata of the LlmResponse.
4142
"""
4243

43-
model_config = ConfigDict(extra='forbid')
44+
model_config = ConfigDict(
45+
extra='forbid',
46+
alias_generator=alias_generators.to_camel,
47+
populate_by_name=True,
48+
)
4449
"""The pydantic model config."""
4550

4651
content: Optional[types.Content] = None

0 commit comments

Comments
 (0)
0