🐫 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
enhance: added more logging and exception handling to workforce (#2671)
Hesam Sheikha74062ada551
diff --git a/camel/societies/workforce/single_agent_worker.py b/camel/societies/workforce/single_agent_worker.pyindex 027ff4f8e..2b4d3cd12 100644--- a/camel/societies/workforce/single_agent_worker.py+++ b/camel/societies/workforce/single_agent_worker.py@@ -286,8 +286,8 @@ class SingleAgentWorker(Worker):)except Exception as e:print(- f"{Fore.RED}Error occurred while processing task {task.id}:"- f"\n{e}{Fore.RESET}"+ f"{Fore.RED}Error processing task {task.id}: "+ f"{type(e).__name__}: {e}{Fore.RESET}")return TaskState.FAILEDfinally:@@ -336,8 +336,15 @@ class SingleAgentWorker(Worker):print(f"======\n{Fore.GREEN}Reply from {self}:{Fore.RESET}")- result_dict = json.loads(response.msg.content)- task_result = TaskResult(**result_dict)+ try:+ result_dict = json.loads(response.msg.content)+ task_result = TaskResult(**result_dict)+ except json.JSONDecodeError as e:+ print(+ f"{Fore.RED}JSON parsing error for task {task.id}: "+ f"Invalid response format - {e}{Fore.RESET}"+ )+ return TaskState.FAILEDcolor = Fore.RED if task_result.failed else Fore.GREENprint(