🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org
Python agentai-societiesartificial-intelligencecommunicative-aicooperative-aideep-learninglarge-language-modelsmulti-agent-systemsnatural-language-processing
fix: update workforce example code
Wendong6a415eac9fe6
diff --git a/examples/workforce/hackathon_judges.py b/examples/workforce/hackathon_judges.pyindex dc67fb3ab..55b2538fa 100644--- a/examples/workforce/hackathon_judges.py+++ b/examples/workforce/hackathon_judges.py@@ -11,6 +11,7 @@# See the License for the specific language governing permissions and# limitations under the License.# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========+import asyncioimport textwrapfrom camel.agents import ChatAgent@@ -57,7 +58,7 @@ def make_judge(return agent-def main():+async def main():proj_content = textwrap.dedent("""\Project name: CAMEL-Powered Adaptive Learning Assistant@@ -251,7 +252,7 @@ def main():worker=researcher_agent,)- task = workforce.process_task(task)+ await workforce.process_task(task)# Test WorkforceLogger featuresprint("\n--- Workforce Log Tree ---")@@ -269,7 +270,7 @@ def main():if __name__ == "__main__":- main()+ asyncio.run(main())'''===============================================================================diff --git a/examples/workforce/multiple_single_agents.py b/examples/workforce/multiple_single_agents.pyindex 99fd08bf9..ac4ae56d8 100644--- a/examples/workforce/multiple_single_agents.py+++ b/examples/workforce/multiple_single_agents.py@@ -12,6 +12,8 @@# limitations under the License.# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========+import asyncio+from camel.agents.chat_agent import ChatAgentfrom camel.messages.base import BaseMessagefrom camel.models import ModelFactory@@ -21,7 +23,7 @@ from camel.toolkits import SearchToolkitfrom camel.types import ModelPlatformType, ModelType-def main():+async def main():# 1. Set up a Research agent with search toolssearch_agent = ChatAgent(system_message=BaseMessage.make_assistant_message(@@ -92,10 +94,22 @@ def main():id='0',)- task = workforce.process_task(human_task)+ await workforce.process_task(human_task)++ # Test WorkforceLogger features+ print("\n--- Workforce Log Tree ---")+ print(workforce.get_workforce_log_tree())++ print("\n--- Workforce KPIs ---")+ kpis = workforce.get_workforce_kpis()+ for key, value in kpis.items():+ print(f"{key}: {value}")- print('Final Result of Original task:\n', task.result)+ log_file_path = "hackathon_judges_logs.json"+ print(f"\n--- Dumping Workforce Logs to {log_file_path} ---")+ workforce.dump_workforce_logs(log_file_path)+ print(f"Logs dumped. Please check the file: {log_file_path}")if __name__ == "__main__":- main()+ asyncio.run(main())diff --git a/examples/workforce/role_playing_with_agents.py b/examples/workforce/role_playing_with_agents.pyindex 466979063..9807ffbb4 100644--- a/examples/workforce/role_playing_with_agents.py+++ b/examples/workforce/role_playing_with_agents.py@@ -12,6 +12,8 @@# limitations under the License.# ========= Copyright 2023-2024 @ CAMEL-AI.org. All Rights Reserved. =========+import asyncio+from camel.agents.chat_agent import ChatAgentfrom camel.messages.base import BaseMessagefrom camel.models import ModelFactory@@ -21,7 +23,7 @@ from camel.toolkits import GoogleMapsToolkit, SearchToolkit, WeatherToolkitfrom camel.types import ModelPlatformType, ModelType-def main():+async def main():guide_sysmsg = BaseMessage.make_assistant_message(role_name="tour guide",content="You have to lead everyone to have fun",@@ -76,10 +78,22 @@ def main():content="research history of Paris and plan a tour.",id='0',)- task = workforce.process_task(human_task)+ await workforce.process_task(human_task)++ # Test WorkforceLogger features+ print("\n--- Workforce Log Tree ---")+ print(workforce.get_workforce_log_tree())++ print("\n--- Workforce KPIs ---")+ kpis = workforce.get_workforce_kpis()+ for key, value in kpis.items():+ print(f"{key}: {value}")- print('Final result of original task:\n', task.result)+ log_file_path = "hackathon_judges_logs.json"+ print(f"\n--- Dumping Workforce Logs to {log_file_path} ---")+ workforce.dump_workforce_logs(log_file_path)+ print(f"Logs dumped. Please check the file: {log_file_path}")if __name__ == "__main__":- main()+ asyncio.run(main())