You've already forked adk-python
mirror of
https://github.com/encounter/adk-python.git
synced 2026-03-30 10:57:20 -07:00
chore: Removes unused to_agent_config method in BaseAgentConfig
PiperOrigin-RevId: 797502656
This commit is contained in:
committed by
Copybara-Service
parent
54ed079100
commit
e93f861cde
@@ -79,12 +79,3 @@ Example:
|
||||
default=None,
|
||||
description='Optional. The after_agent_callbacks of the agent.',
|
||||
)
|
||||
|
||||
def to_agent_config(
|
||||
self, custom_agent_config_cls: Type[TBaseAgentConfig]
|
||||
) -> TBaseAgentConfig:
|
||||
"""Converts this config to the concrete agent config type.
|
||||
|
||||
NOTE: this is for ADK framework use only.
|
||||
"""
|
||||
return custom_agent_config_cls.model_validate(self.model_dump())
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
# Copyright 2025 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from typing import Literal
|
||||
|
||||
from google.adk.agents.agent_config import AgentConfig
|
||||
@@ -115,9 +129,12 @@ other_field: other value
|
||||
|
||||
config = AgentConfig.model_validate(config_data)
|
||||
|
||||
assert isinstance(config.root, BaseAgentConfig)
|
||||
# pylint: disable=unidiomatic-typecheck Needs exact class matching.
|
||||
assert type(config.root) is BaseAgentConfig
|
||||
assert config.root.agent_class == "mylib.agents.MyCustomAgent"
|
||||
assert config.root.model_extra == {"other_field": "other value"}
|
||||
|
||||
my_custom_config = config.root.to_agent_config(MyCustomAgentConfig)
|
||||
my_custom_config = MyCustomAgentConfig.model_validate(
|
||||
config.root.model_dump()
|
||||
)
|
||||
assert my_custom_config.other_field == "other value"
|
||||
|
||||
Reference in New Issue
Block a user