From 7cb13cae0e48d8ed36206ebbd9f28f0f888f1432 Mon Sep 17 00:00:00 2001 From: Joao Moura Date: Wed, 15 Nov 2023 00:39:52 -0300 Subject: [PATCH 1/5] Updating README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 98cca5b34..f0e002343 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ crew = Crew( ) # 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. From 492f3616343d43f0e649d4a7432a35d37442fe76 Mon Sep 17 00:00:00 2001 From: Joao Moura Date: Wed, 15 Nov 2023 00:41:17 -0300 Subject: [PATCH 2/5] adding extra detail on delegtion errors so LLM can recover --- crewai/tools/agent_tools.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crewai/tools/agent_tools.py b/crewai/tools/agent_tools.py index 06ea9f68e..53ea92b3b 100644 --- a/crewai/tools/agent_tools.py +++ b/crewai/tools/agent_tools.py @@ -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) From 62b65401bb566b92950750949e6e8dc215c39077 Mon Sep 17 00:00:00 2001 From: Joao Moura Date: Wed, 15 Nov 2023 17:29:25 -0300 Subject: [PATCH 3/5] Adding Assistante to the README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f0e002343..2b2fedf0d 100644 --- a/README.md +++ b/README.md @@ -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 From f1b387507307e6f8bccabf5241ea787398a440c1 Mon Sep 17 00:00:00 2001 From: Joao Moura Date: Wed, 15 Nov 2023 17:29:47 -0300 Subject: [PATCH 4/5] Adding verbose option for crew --- crewai/crew.py | 13 ++++++++- tests/agent_tools/agent_tools_test.py | 4 +-- tests/crew_test.py | 42 ++++++++++++++++++++++++++- 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/crewai/crew.py b/crewai/crew.py index 72f78fcf2..0a3bdc0c2 100644 --- a/crewai/crew.py +++ b/crewai/crew.py @@ -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 \ No newline at end of file diff --git a/tests/agent_tools/agent_tools_test.py b/tests/agent_tools/agent_tools_test.py index 46aa4d276..43278bfc5 100644 --- a/tests/agent_tools/agent_tools_test.py +++ b/tests/agent_tools/agent_tools_test.py @@ -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." diff --git a/tests/crew_test.py b/tests/crew_test.py index a4072c067..52e66e079 100644 --- a/tests/crew_test.py +++ b/tests/crew_test.py @@ -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."' \ No newline at end of file + 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 == "" \ No newline at end of file From afca1a585e77858e169678cbb053852a261029dc Mon Sep 17 00:00:00 2001 From: Joao Moura Date: Thu, 16 Nov 2023 18:51:48 -0300 Subject: [PATCH 5/5] Updating README tro include crew verbose more --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2b2fedf0d..b0ac562f3 100644 --- a/README.md +++ b/README.md @@ -30,13 +30,13 @@ researcher = Agent( role='Researcher', goal='Discover new insights', backstory="You're a world class researcher working on a amjor data science company", - verbose=True + verbose=True # Agent verbose mode will show you the chain of thought for an Agent. ) 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 @@ -47,6 +47,7 @@ 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. )