Add a function tool to the set.
(
self,
name: str,
func_args: list,
desc: str,
handler: Callable[..., Awaitable[Any]],
)
| 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: |
no test coverage detected