mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-11 17:18:29 +00:00
adding new docs and smaller fixes
This commit is contained in:
@@ -155,7 +155,10 @@ class Crew(BaseModel):
|
||||
task_output = ""
|
||||
for task in self.tasks:
|
||||
if task.agent is not None and task.agent.allow_delegation:
|
||||
task.tools += AgentTools(agents=self.agents).tools()
|
||||
agents_for_delegation = [
|
||||
agent for agent in self.agents if agent != task.agent
|
||||
]
|
||||
task.tools += AgentTools(agents=agents_for_delegation).tools()
|
||||
|
||||
role = task.agent.role if task.agent is not None else "None"
|
||||
self._logger.log("debug", f"Working Agent: {role}")
|
||||
@@ -187,9 +190,12 @@ class Crew(BaseModel):
|
||||
|
||||
task_output = ""
|
||||
for task in self.tasks:
|
||||
self._logger.log("debug", f"Working Agent: {manager.role}")
|
||||
self._logger.log("info", f"Starting Task: {task.description}")
|
||||
|
||||
task_output = task.execute(agent=manager, context=task_output)
|
||||
task_output = task.execute(
|
||||
agent=manager, context=task_output, tools=manager.tools
|
||||
)
|
||||
|
||||
self._logger.log(
|
||||
"debug", f"[{manager.role}] Task output: {task_output}\n\n"
|
||||
|
||||
@@ -66,7 +66,12 @@ class Task(BaseModel):
|
||||
self.tools.extend(self.agent.tools)
|
||||
return self
|
||||
|
||||
def execute(self, agent: Agent | None = None, context: Optional[str] = None) -> str:
|
||||
def execute(
|
||||
self,
|
||||
agent: Agent | None = None,
|
||||
context: Optional[str] = None,
|
||||
tools: Optional[List[Any]] = None,
|
||||
) -> str:
|
||||
"""Execute the task.
|
||||
|
||||
Returns:
|
||||
@@ -87,9 +92,11 @@ class Task(BaseModel):
|
||||
context.append(task.output.result)
|
||||
context = "\n".join(context)
|
||||
|
||||
tools = tools or self.tools
|
||||
|
||||
if self.async_execution:
|
||||
self.thread = threading.Thread(
|
||||
target=self._execute, args=(agent, self._prompt(), context, self.tools)
|
||||
target=self._execute, args=(agent, self._prompt(), context, tools)
|
||||
)
|
||||
self.thread.start()
|
||||
else:
|
||||
@@ -97,7 +104,7 @@ class Task(BaseModel):
|
||||
agent=agent,
|
||||
task_prompt=self._prompt(),
|
||||
context=context,
|
||||
tools=self.tools,
|
||||
tools=tools,
|
||||
)
|
||||
return result
|
||||
|
||||
|
||||
Reference in New Issue
Block a user