mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-25 16:18:13 +00:00
Update inner tool usage logic to support both regular and function calling
This commit is contained in:
@@ -20,24 +20,24 @@ class AgentTools(BaseModel):
|
||||
func=self.delegate_work,
|
||||
name="Delegate work to co-worker",
|
||||
description=self.i18n.tools("delegate_work").format(
|
||||
coworkers="\n".join([f"- {agent.role}" for agent in self.agents])
|
||||
coworkers=[f"{agent.role}" for agent in self.agents]
|
||||
),
|
||||
),
|
||||
StructuredTool.from_function(
|
||||
func=self.ask_question,
|
||||
name="Ask question to co-worker",
|
||||
description=self.i18n.tools("ask_question").format(
|
||||
coworkers="\n".join([f"- {agent.role}" for agent in self.agents])
|
||||
coworkers=[f"{agent.role}" for agent in self.agents]
|
||||
),
|
||||
),
|
||||
]
|
||||
|
||||
def delegate_work(self, coworker: str, task: str, context: str):
|
||||
"""Useful to delegate a specific task to a coworker."""
|
||||
"""Useful to delegate a specific task to a coworker passing all necessary context and names."""
|
||||
return self._execute(coworker, task, context)
|
||||
|
||||
def ask_question(self, coworker: str, question: str, context: str):
|
||||
"""Useful to ask a question, opinion or take from a coworker."""
|
||||
"""Useful to ask a question, opinion or take from a coworker passing all necessary context and names."""
|
||||
return self._execute(coworker, question, context)
|
||||
|
||||
def _execute(self, agent, task, context):
|
||||
@@ -59,5 +59,9 @@ class AgentTools(BaseModel):
|
||||
)
|
||||
|
||||
agent = agent[0]
|
||||
task = Task(description=task, agent=agent)
|
||||
task = Task(
|
||||
description=task,
|
||||
agent=agent,
|
||||
expected_output="Your best answer to your coworker asking you this, accounting for the context shared.",
|
||||
)
|
||||
return agent.execute_task(task, context)
|
||||
|
||||
Reference in New Issue
Block a user