MCPcopy Index your code
hub / github.com/AstrBotDevs/AstrBot / add_func

Method add_func

astrbot/core/agent/tool.py:163–186  ·  view source on GitHub ↗

Add a function tool to the set.

(
        self,
        name: str,
        func_args: list,
        desc: str,
        handler: Callable[..., Awaitable[Any]],
    )

Source from the content-addressed store, hash-verified

161
162 @deprecated(reason="Use add_tool() instead", version="4.0.0")
163 def add_func(
164 self,
165 name: str,
166 func_args: list,
167 desc: str,
168 handler: Callable[..., Awaitable[Any]],
169 ) -> None:
170 """Add a function tool to the set."""
171 params = {
172 "type": "object", # hard-coded here
173 "properties": {},
174 }
175 for param in func_args:
176 params["properties"][param["name"]] = {
177 "type": param["type"],
178 "description": param["description"],
179 }
180 _func = FunctionTool(
181 name=name,
182 parameters=params,
183 description=desc,
184 handler=handler,
185 )
186 self.add_tool(_func)
187
188 @deprecated(reason="Use remove_tool() instead", version="4.0.0")
189 def remove_func(self, name: str) -> None:

Callers 2

register_llm_toolMethod · 0.45
decoratorFunction · 0.45

Calls 2

add_toolMethod · 0.95
FunctionToolClass · 0.85

Tested by

no test coverage detected