File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 2222from typing import Optional
2323from typing import Protocol
2424from typing import runtime_checkable
25+ from typing import Type
2526from typing import TYPE_CHECKING
27+ from typing import TypeVar
2628from typing import Union
2729
2830from ..agents .readonly_context import ReadonlyContext
2931from .base_tool import BaseTool
3032
3133if 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+
5662class 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 :
You can’t perform that action at this time.
0 commit comments