Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/google/adk/tools/base_toolset.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@
from typing import Optional
from typing import Protocol
from typing import runtime_checkable
from typing import Type
from typing import TYPE_CHECKING
from typing import TypeVar
from typing import Union

from ..agents.readonly_context import ReadonlyContext
from .base_tool import BaseTool

if TYPE_CHECKING:
from ..models.llm_request import LlmRequest
from .tool_configs import ToolArgsConfig
from .tool_context import ToolContext


Expand All @@ -53,6 +56,9 @@ def __call__(
"""


SelfToolset = TypeVar("SelfToolset", bound="BaseToolset")


class BaseToolset(ABC):
"""Base class for toolset.

Expand Down Expand Up @@ -152,6 +158,22 @@ async def close(self) -> None:
resources are properly released to prevent leaks.
"""

@classmethod
def from_config(
cls: Type[SelfToolset], config: ToolArgsConfig, config_abs_path: str
) -> SelfToolset:
"""Creates a toolset instance from a config.

Args:
config: The config for the tool.
config_abs_path: The absolute path to the config file that contains the
tool config.

Returns:
The toolset instance.
"""
raise ValueError(f"from_config() not implemented for toolset: {cls}")

def _is_tool_selected(
self, tool: BaseTool, readonly_context: ReadonlyContext
) -> bool:
Expand Down
Loading