mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-15 17:30:13 +08:00
fix: add missing add_tool and merge methods to base ToolSet
The internal ToolSet (base.py) was missing add_tool() and merge() methods that the agent code expects. When tmgr.get_full_tool_set() returned a base.py ToolSet, calls to add_tool() and merge() failed. Added: - add_tool() as alias to add() - merge() method to merge another ToolSet This fixes runtime crash: AttributeError: 'ToolSet' object has no attribute 'add_tool'
This commit is contained in:
@@ -100,6 +100,10 @@ class ToolSet:
|
||||
"""Add a tool to the set."""
|
||||
self._tools[tool.name] = tool
|
||||
|
||||
def add_tool(self, tool: FunctionTool) -> None:
|
||||
"""Add a tool to the set (alias for add())."""
|
||||
self.add(tool)
|
||||
|
||||
def remove(self, name: str) -> FunctionTool | None:
|
||||
"""Remove and return a tool by name."""
|
||||
return self._tools.pop(name, None)
|
||||
@@ -126,6 +130,11 @@ class ToolSet:
|
||||
def __len__(self) -> int:
|
||||
return len(self._tools)
|
||||
|
||||
def merge(self, other: "ToolSet") -> None:
|
||||
"""Merge another ToolSet into this one."""
|
||||
for tool in other.tools:
|
||||
self.add(tool)
|
||||
|
||||
@property
|
||||
def tools(self) -> list[FunctionTool]:
|
||||
"""List all tools in this set."""
|
||||
|
||||
Reference in New Issue
Block a user