-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b62ba45
commit 9d1b2c6
Showing
3 changed files
with
25 additions
and
28 deletions.
There are no files selected for viewing
26 changes: 6 additions & 20 deletions
26
autogen/agentchat/contrib/capabilities/tools_capability.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,22 @@ | ||
# Copyright (c) 2023 - 2025, Owners of https://github.com/ag2ai | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
from dataclasses import dataclass | ||
from typing import Any, Callable, Optional | ||
|
||
from autogen.agentchat import ConversableAgent, register_function | ||
|
||
|
||
@dataclass | ||
class ToolSpecs: | ||
tool_func: Callable[..., Any] | ||
tool_description: str | ||
tool_name: Optional[str] = None | ||
from autogen.agentchat import ConversableAgent | ||
from autogen.tools import Tool | ||
|
||
|
||
class ToolsCapability: | ||
"""Adding a list of tools as composable capabilities to a single agent. | ||
Note: both caller and executor of the tools are the same agent. | ||
""" | ||
|
||
def __init__(self, tool_list: list[ToolSpecs]): | ||
self.tools = [specs for specs in tool_list] | ||
def __init__(self, tool_list: list[Tool]): | ||
self.tools = [tool for tool in tool_list] | ||
|
||
def add_to_agent(self, agent: ConversableAgent): | ||
""" | ||
Add tools to the given agent. | ||
""" | ||
for specs in self.tools: | ||
register_function( | ||
f=specs.tool_func, | ||
caller=agent, | ||
executor=agent, | ||
description=specs.tool_description, | ||
name=specs.tool_name, | ||
) | ||
for tool in self.tools: | ||
tool.register_tool(agent=agent) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters