Skip to content

Commit 28d853d

Browse files
Jacksunweicopybara-github
authored andcommitted
fix: add the missing from_config class method in BaseToolset
PiperOrigin-RevId: 799393801
1 parent 3b997a0 commit 28d853d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/google/adk/tools/base_toolset.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,17 @@
2222
from typing import Optional
2323
from typing import Protocol
2424
from typing import runtime_checkable
25+
from typing import Type
2526
from typing import TYPE_CHECKING
27+
from typing import TypeVar
2628
from typing import Union
2729

2830
from ..agents.readonly_context import ReadonlyContext
2931
from .base_tool import BaseTool
3032

3133
if TYPE_CHECKING:
3234
from ..models.llm_request import LlmRequest
35+
from .tool_configs import ToolArgsConfig
3336
from .tool_context import ToolContext
3437

3538

@@ -53,6 +56,9 @@ def __call__(
5356
"""
5457

5558

59+
SelfToolset = TypeVar("SelfToolset", bound="BaseToolset")
60+
61+
5662
class BaseToolset(ABC):
5763
"""Base class for toolset.
5864
@@ -152,6 +158,22 @@ async def close(self) -> None:
152158
resources are properly released to prevent leaks.
153159
"""
154160

161+
@classmethod
162+
def from_config(
163+
cls: Type[SelfToolset], config: ToolArgsConfig, config_abs_path: str
164+
) -> SelfToolset:
165+
"""Creates a toolset instance from a config.
166+
167+
Args:
168+
config: The config for the tool.
169+
config_abs_path: The absolute path to the config file that contains the
170+
tool config.
171+
172+
Returns:
173+
The toolset instance.
174+
"""
175+
raise ValueError(f"from_config() not implemented for toolset: {cls}")
176+
155177
def _is_tool_selected(
156178
self, tool: BaseTool, readonly_context: ReadonlyContext
157179
) -> bool:

0 commit comments

Comments
 (0)