Adding verbose option for crew

This commit is contained in:
Joao Moura
2023-11-15 17:29:47 -03:00
parent 62b65401bb
commit f1b3875073
3 changed files with 55 additions and 4 deletions

View File

@@ -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."

View File

@@ -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 == ""