chore: Migrate json field names to camelCase (4/4)

PiperOrigin-RevId: 758423361
This commit is contained in:
Google Team Member 2025-05-13 16:35:58 -07:00 committed by Copybara-Service
parent 931fb338f8
commit d6cf660506
6 changed files with 30 additions and 10 deletions

View File

@ -15,13 +15,18 @@
from enum import Enum from enum import Enum
from typing import Any, Dict, List, Optional from typing import Any, Dict, List, Optional
from pydantic import alias_generators
from pydantic import BaseModel from pydantic import BaseModel
from pydantic import ConfigDict from pydantic import ConfigDict
from pydantic import Field from pydantic import Field
class BaseModelWithConfig(BaseModel): class BaseModelWithConfig(BaseModel):
model_config = ConfigDict(extra="allow") model_config = ConfigDict(
extra="allow",
alias_generator=alias_generators.to_camel,
populate_by_name=True,
)
"""The pydantic model config.""" """The pydantic model config."""

View File

@ -12,13 +12,12 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from pydantic import BaseModel
from .auth_credential import AuthCredential from .auth_credential import AuthCredential
from .auth_credential import BaseModelWithConfig
from .auth_schemes import AuthScheme from .auth_schemes import AuthScheme
class AuthConfig(BaseModel): class AuthConfig(BaseModelWithConfig):
"""The auth config sent by tool asking client to collect auth credentials and """The auth config sent by tool asking client to collect auth credentials and
adk and client will help to fill in the response adk and client will help to fill in the response
@ -45,7 +44,7 @@ class AuthConfig(BaseModel):
this field""" this field"""
class AuthToolArguments(BaseModel): class AuthToolArguments(BaseModelWithConfig):
"""the arguments for the special long running function tool that is used to """the arguments for the special long running function tool that is used to
request end user credentials. request end user credentials.

View File

@ -30,6 +30,7 @@ from pydantic import Field
from ..agents import Agent from ..agents import Agent
from ..sessions.session import Session from ..sessions.session import Session
from .utils import common
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -50,7 +51,7 @@ class EvalMetricResult(BaseModel):
eval_status: EvalStatus eval_status: EvalStatus
class EvalCaseResult(BaseModel): class EvalCaseResult(common.BaseModel):
eval_set_file: str eval_set_file: str
eval_id: str eval_id: str
final_eval_status: EvalStatus final_eval_status: EvalStatus
@ -60,7 +61,7 @@ class EvalCaseResult(BaseModel):
user_id: Optional[str] = None user_id: Optional[str] = None
class EvalSetResult(BaseModel): class EvalSetResult(common.BaseModel):
eval_set_result_id: str eval_set_result_id: str
eval_set_result_name: str eval_set_result_name: str
eval_set_id: str eval_set_id: str

View File

@ -19,6 +19,7 @@ import string
from typing import Optional from typing import Optional
from google.genai import types from google.genai import types
from pydantic import alias_generators
from pydantic import ConfigDict from pydantic import ConfigDict
from pydantic import Field from pydantic import Field
@ -46,7 +47,11 @@ class Event(LlmResponse):
""" """
model_config = ConfigDict( model_config = ConfigDict(
extra='forbid', ser_json_bytes='base64', val_json_bytes='base64' extra='forbid',
ser_json_bytes='base64',
val_json_bytes='base64',
alias_generator=alias_generators.to_camel,
populate_by_name=True,
) )
"""The pydantic model config.""" """The pydantic model config."""

View File

@ -16,6 +16,7 @@ from __future__ import annotations
from typing import Optional from typing import Optional
from pydantic import alias_generators
from pydantic import BaseModel from pydantic import BaseModel
from pydantic import ConfigDict from pydantic import ConfigDict
from pydantic import Field from pydantic import Field
@ -26,7 +27,11 @@ from ..auth.auth_tool import AuthConfig
class EventActions(BaseModel): class EventActions(BaseModel):
"""Represents the actions attached to an event.""" """Represents the actions attached to an event."""
model_config = ConfigDict(extra='forbid') model_config = ConfigDict(
extra='forbid',
alias_generator=alias_generators.to_camel,
populate_by_name=True,
)
"""The pydantic model config.""" """The pydantic model config."""
skip_summarization: Optional[bool] = None skip_summarization: Optional[bool] = None

View File

@ -17,6 +17,7 @@ from __future__ import annotations
from typing import Any, Optional from typing import Any, Optional
from google.genai import types from google.genai import types
from pydantic import alias_generators
from pydantic import BaseModel from pydantic import BaseModel
from pydantic import ConfigDict from pydantic import ConfigDict
@ -40,7 +41,11 @@ class LlmResponse(BaseModel):
custom_metadata: The custom metadata of the LlmResponse. custom_metadata: The custom metadata of the LlmResponse.
""" """
model_config = ConfigDict(extra='forbid') model_config = ConfigDict(
extra='forbid',
alias_generator=alias_generators.to_camel,
populate_by_name=True,
)
"""The pydantic model config.""" """The pydantic model config."""
content: Optional[types.Content] = None content: Optional[types.Content] = None