mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-09 08:08:32 +00:00
Merge pull request #2 from joaomdmoura/joaomdmoura/adding-crew-specific-verbose-logs
Adding crew specific verbose logs
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
The power of AI collaboration has too much to offer.
|
||||
CrewAI is designed to enable AI agents to assume roles, share goals, and operate in a cohesive unit - much like a well-oiled crew. Whether you're building a smart assistant platform, an automated customer service ensemble, or a multi-agent research team, CrewAI provides the backbone for sophisticated multi-agent interactions.
|
||||
|
||||
[Talk with the Docs](https://chat.openai.com/g/g-qqTuUWsBY-crewai-assistant)
|
||||
[Documention Wiki](https://github.com/joaomdmoura/CrewAI/wiki)
|
||||
|
||||
## Getting Started
|
||||
@@ -35,7 +36,7 @@ writer = Agent(
|
||||
role='Writer',
|
||||
goal='Create engaging content',
|
||||
backstory="You're a famous technical writer, specialized on writing data related content"
|
||||
verbose=True
|
||||
verbose=True
|
||||
)
|
||||
|
||||
# Create tasks for your agents
|
||||
@@ -46,11 +47,12 @@ task2 = Task(description='Write a blog post on AI advancements', agent=writer)
|
||||
crew = Crew(
|
||||
agents=[researcher, writer],
|
||||
tasks=[task1, task2],
|
||||
verbose=True # Crew verbose more will let you know what tasks arebeing worked on
|
||||
process=Process.sequential # Sequential process will have tasks executed one after the other and the outcome of the previous one is passed as extra content into this next.
|
||||
)
|
||||
|
||||
# Get your crew to work!
|
||||
crew.kickoff()
|
||||
result = crew.kickoff()
|
||||
```
|
||||
|
||||
Currently the only supported process is `Process.sequential`, where one task is executed after the other and the outcome of one is passed as extra content into this next.
|
||||
|
||||
@@ -19,6 +19,10 @@ class Crew(BaseModel):
|
||||
description="Process that the crew will follow.",
|
||||
default=Process.sequential
|
||||
)
|
||||
verbose: bool = Field(
|
||||
description="Verbose mode for the Agent Execution",
|
||||
default=False
|
||||
)
|
||||
|
||||
@root_validator(pre=True)
|
||||
def check_config(_cls, values):
|
||||
@@ -54,7 +58,6 @@ class Crew(BaseModel):
|
||||
"""
|
||||
if self.process == Process.sequential:
|
||||
return self.__sequential_loop()
|
||||
return "Crew is executing task"
|
||||
|
||||
def __sequential_loop(self) -> str:
|
||||
"""
|
||||
@@ -68,6 +71,14 @@ class Crew(BaseModel):
|
||||
if task.agent.allow_delegation:
|
||||
tools = AgentTools(agents=self.agents).tools()
|
||||
task.tools += tools
|
||||
|
||||
if self.verbose:
|
||||
print(f"Working Agent: {task.agent.role}")
|
||||
print(f"Starting Task: {task.description} ...")
|
||||
|
||||
task_outcome = task.execute(task_outcome)
|
||||
|
||||
if self.verbose:
|
||||
print(f"Task output: {task_outcome}")
|
||||
|
||||
return task_outcome
|
||||
@@ -45,12 +45,12 @@ class AgentTools(BaseModel):
|
||||
"""Execute the command."""
|
||||
agent, task, information = command.split("|")
|
||||
if not agent or not task or not information:
|
||||
return "Error executing tool."
|
||||
return "Error executing tool. Missing 3 pipe (|) separated values."
|
||||
|
||||
agent = [available_agent for available_agent in self.agents if available_agent.role == agent]
|
||||
|
||||
if len(agent) == 0:
|
||||
return "Error executing tool."
|
||||
return "Error executing tool. Co-worker not found, double check the co-worker."
|
||||
|
||||
agent = agent[0]
|
||||
result = agent.execute_task(task, information)
|
||||
|
||||
@@ -34,13 +34,13 @@ def test_delegate_work_to_wrong_agent():
|
||||
command="writer|share your take on AI Agents|I heard you hate them"
|
||||
)
|
||||
|
||||
assert result == "Error executing tool."
|
||||
assert result == "Error executing tool. Co-worker not found, double check the co-worker."
|
||||
|
||||
def test_ask_question_to_wrong_agent():
|
||||
result = tools.ask_question(
|
||||
command="writer|do you hate AI Agents?|I heard you LOVE them"
|
||||
)
|
||||
|
||||
assert result == "Error executing tool."
|
||||
assert result == "Error executing tool. Co-worker not found, double check the co-worker."
|
||||
|
||||
|
||||
|
||||
@@ -133,4 +133,44 @@ def test_crew_with_delegating_agents():
|
||||
tasks=tasks,
|
||||
)
|
||||
|
||||
assert crew.kickoff() == 'The Senior Writer produced an amazing paragraph about AI Agents: "Artificial Intelligence (AI) agents, the cutting-edge technology that is reshaping the digital landscape, are software entities that autonomously perform tasks to achieve specific goals. These agents, programmed to make decisions based on their environment, are the driving force behind a multitude of innovations, from self-driving cars to personalized recommendations in e-commerce. They are pushing boundaries in various sectors, mitigating human error, increasing efficiency, and revolutionizing customer experience. The importance of AI agents is underscored by their ability to adapt and learn, ushering in a new era of technology where machines can mimic, and often surpass, human intelligence. Understanding AI agents is akin to peering into the future, a future where technology is seamless, intuitive, and astoundingly smart."'
|
||||
assert crew.kickoff() == 'The Senior Writer produced an amazing paragraph about AI Agents: "Artificial Intelligence (AI) agents, the cutting-edge technology that is reshaping the digital landscape, are software entities that autonomously perform tasks to achieve specific goals. These agents, programmed to make decisions based on their environment, are the driving force behind a multitude of innovations, from self-driving cars to personalized recommendations in e-commerce. They are pushing boundaries in various sectors, mitigating human error, increasing efficiency, and revolutionizing customer experience. The importance of AI agents is underscored by their ability to adapt and learn, ushering in a new era of technology where machines can mimic, and often surpass, human intelligence. Understanding AI agents is akin to peering into the future, a future where technology is seamless, intuitive, and astoundingly smart."'
|
||||
|
||||
@pytest.mark.vcr()
|
||||
def test_crew_verbose_output(capsys):
|
||||
tasks = [
|
||||
Task(
|
||||
description="Research AI advancements.",
|
||||
agent=researcher
|
||||
),
|
||||
Task(
|
||||
description="Write about AI in healthcare.",
|
||||
agent=writer
|
||||
)
|
||||
]
|
||||
|
||||
crew = Crew(
|
||||
agents=[researcher, writer],
|
||||
tasks=tasks,
|
||||
process=Process.sequential,
|
||||
verbose=True
|
||||
)
|
||||
|
||||
crew.kickoff()
|
||||
captured = capsys.readouterr()
|
||||
expected_strings = [
|
||||
"Working Agent: Researcher",
|
||||
"Starting Task: Research AI advancements. ...",
|
||||
"Task output:",
|
||||
"Working Agent: Senior Writer",
|
||||
"Starting Task: Write about AI in healthcare. ...",
|
||||
"Task output:"
|
||||
]
|
||||
|
||||
for expected_string in expected_strings:
|
||||
assert expected_string in captured.out
|
||||
|
||||
# Now test with verbose set to False
|
||||
crew.verbose = False
|
||||
crew.kickoff()
|
||||
captured = capsys.readouterr()
|
||||
assert captured.out == ""
|
||||
Reference in New Issue
Block a user