mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-11 09:08:31 +00:00
* move base_tool to main package and consolidate tool desscription generation * update import path * update tests * update doc * add base_tool test * migrate agent delegation tools to use BaseTool * update tests * update import path for tool * fix lint * update param signature * add from_langchain to BaseTool for backwards support of langchain tools * fix the case where StructuredTool doesn't have func --------- Co-authored-by: c0dez <li@vitablehealth.com> Co-authored-by: Brandon Hancock (bhancock_ai) <109994880+bhancockio@users.noreply.github.com>
33 lines
1020 B
Python
33 lines
1020 B
Python
from crewai.tools.base_tool import BaseTool
|
|
from crewai.agents.agent_builder.base_agent import BaseAgent
|
|
from crewai.utilities import I18N
|
|
|
|
from .delegate_work_tool import DelegateWorkTool
|
|
from .ask_question_tool import AskQuestionTool
|
|
|
|
|
|
class AgentTools:
|
|
"""Manager class for agent-related tools"""
|
|
|
|
def __init__(self, agents: list[BaseAgent], i18n: I18N = I18N()):
|
|
self.agents = agents
|
|
self.i18n = i18n
|
|
|
|
def tools(self) -> list[BaseTool]:
|
|
"""Get all available agent tools"""
|
|
coworkers = ", ".join([f"{agent.role}" for agent in self.agents])
|
|
|
|
delegate_tool = DelegateWorkTool(
|
|
agents=self.agents,
|
|
i18n=self.i18n,
|
|
description=self.i18n.tools("delegate_work").format(coworkers=coworkers),
|
|
)
|
|
|
|
ask_tool = AskQuestionTool(
|
|
agents=self.agents,
|
|
i18n=self.i18n,
|
|
description=self.i18n.tools("ask_question").format(coworkers=coworkers),
|
|
)
|
|
|
|
return [delegate_tool, ask_tool]
|