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 22
22
from typing import Optional
23
23
from typing import Protocol
24
24
from typing import runtime_checkable
25
+ from typing import Type
25
26
from typing import TYPE_CHECKING
27
+ from typing import TypeVar
26
28
from typing import Union
27
29
28
30
from ..agents .readonly_context import ReadonlyContext
29
31
from .base_tool import BaseTool
30
32
31
33
if TYPE_CHECKING :
32
34
from ..models .llm_request import LlmRequest
35
+ from .tool_configs import ToolArgsConfig
33
36
from .tool_context import ToolContext
34
37
35
38
@@ -53,6 +56,9 @@ def __call__(
53
56
"""
54
57
55
58
59
+ SelfToolset = TypeVar ("SelfToolset" , bound = "BaseToolset" )
60
+
61
+
56
62
class BaseToolset (ABC ):
57
63
"""Base class for toolset.
58
64
@@ -152,6 +158,22 @@ async def close(self) -> None:
152
158
resources are properly released to prevent leaks.
153
159
"""
154
160
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
+
155
177
def _is_tool_selected (
156
178
self , tool : BaseTool , readonly_context : ReadonlyContext
157
179
) -> bool :
You can’t perform that action at this time.
0 commit comments