From de8d6465bc1dca0e97c4c3e817c39499c39e65d6 Mon Sep 17 00:00:00 2001 From: "panxuchen.pxc" Date: Wed, 17 Jan 2024 11:19:56 +0800 Subject: [PATCH] fix distributed debate --- notebook/distributed_debate.ipynb | 378 ++++++++++++++++------------- src/agentscope/agents/rpc_agent.py | 3 + 2 files changed, 217 insertions(+), 164 deletions(-) diff --git a/notebook/distributed_debate.ipynb b/notebook/distributed_debate.ipynb index 2b2b5a1da..3d2c1b011 100644 --- a/notebook/distributed_debate.ipynb +++ b/notebook/distributed_debate.ipynb @@ -19,9 +19,8 @@ "\n", "Pro believes that AGI can be achieved using the GPT model framework, while Con contests it. Judge listens to both sides' arguments and provides an analytical judgment on which side presented a more compelling and reasonable case.\n", "\n", - "Messages generated by any agents can be observed by other agents in the debate.\n", - "\n", - "The full codes can be found in `examples/distributed/distributed_debate.py`" + "A fully distributed version can be found in `examples/distributed/distributed_debate.py`.\n", + "Here we provide a standalone multi-process version." ] }, { @@ -37,189 +36,274 @@ "id": "fc97a3fc-6bed-4a0f-bf61-e977630a159c", "metadata": {}, "source": [ - "In this case, we need to initialize three agents. The codes are the follows." + "First, we need to set the model configs of AgentScope." ] }, { - "cell_type": "markdown", - "id": "868f7187-fc64-4ead-87a0-143650eeda1e", + "cell_type": "code", + "execution_count": 2, + "id": "7924b86d", "metadata": {}, + "outputs": [], "source": [ - "```bash\n", - "def setup_server(parsed_args: argparse.Namespace) -> None:\n", - " \"\"\"Setup rpc server for participant agent\"\"\"\n", - " agentscope.init(\n", - " model_configs=\"configs/model_configs.json\",\n", - " )\n", - " with open(\n", - " \"configs/debate_agent_configs.json\",\n", - " \"r\",\n", - " encoding=\"utf-8\",\n", - " ) as f:\n", - " configs = json.load(f)\n", - " config = configs[parsed_args.role]\n", - " host = getattr(parsed_args, f\"{parsed_args.role}_host\")\n", - " port = getattr(parsed_args, f\"{parsed_args.role}_port\")\n", - " server_launcher = RpcAgentServerLauncher(\n", - " host=host,\n", - " port=port,\n", - " local_mode=False,\n", - " agent_class=RpcDialogAgent,\n", - " **config,\n", - " )\n", - " server_launcher.launch()\n", - " server_launcher.wait_until_terminate()\n", - "```" + "model_configs = [\n", + " {\n", + " \"type\": \"openai\",\n", + " \"name\": \"gpt-3.5-turbo\",\n", + " \"parameters\": {\n", + " \"api_key\": \"xxx\",\n", + " \"organization_id\": \"xxx\",\n", + " \"temperature\": 0.0\n", + " }\n", + " },\n", + " {\n", + " \"type\": \"openai\",\n", + " \"name\": \"gpt-4\",\n", + " \"parameters\": {\n", + " \"api_key\": \"xxx\",\n", + " \"organization_id\": \"xxx\",\n", + " \"temperature\": 0.0\n", + " }\n", + " }\n", + "]" ] }, { "cell_type": "markdown", - "id": "01ca8024-fa7e-4d7f-bf35-a78511a47ab3", + "id": "0072fc64", "metadata": {}, "source": [ - "To make it running on jupyter, we run them in the backend." + "Second, let's start the three agents in the debate. Note that each agent here will automatically start a sub-process, and the `reply` method is executed within the sub-process." ] }, { "cell_type": "code", - "execution_count": 1, - "id": "7f3d7a0b-3c46-40aa-a877-f0b4d8423c14", + "execution_count": 3, + "id": "260aab10", "metadata": {}, "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "/Users/qianbingchen/AgentScope/examples/distributed\n" - ] - }, { "name": "stderr", "output_type": "stream", "text": [ - "/Users/qianbingchen/miniconda3/envs/agent/lib/python3.9/site-packages/IPython/core/magics/osm.py:417: UserWarning: using dhist requires you to install the `pickleshare` library.\n", - " self.shell.db['dhist'] = compress_dhist(dhist)[-100:]\n" + "\u001b[32m2024-01-17 11:17:45.057\u001b[0m | \u001b[1mINFO \u001b[0m | \u001b[36magentscope.models\u001b[0m:\u001b[36mread_model_configs\u001b[0m:\u001b[36m147\u001b[0m - \u001b[1mLoad configs for model: gpt-3.5-turbo\u001b[0m\n" ] } ], "source": [ - "%cd ../examples/distributed/" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "1058a769-bedf-4832-85e2-bc943c0741ac", - "metadata": {}, - "outputs": [], - "source": [ - "import subprocess\n", - "\n", - "# Using Popen to initialize a backstage process\n", + "import agentscope\n", + "from agentscope.agents.rpc_dialog_agent import RpcDialogAgent\n", "\n", - "proc_pro = subprocess.Popen(\n", - " ['python', 'distributed_debate.py', '--role', 'pro', '--pro-host', 'localhost', '--pro-port', '12011'],\n", - " stdout=subprocess.PIPE,\n", - " stderr=subprocess.PIPE\n", - ")\n", + "agentscope.init(model_configs=model_configs)\n", "\n", - "proc_con = subprocess.Popen(\n", - " ['python', 'distributed_debate.py', '--role', 'con', '--con-host', 'localhost', '--con-port', '12012'],\n", - " stdout=subprocess.PIPE,\n", - " stderr=subprocess.PIPE\n", + "pro_agent = RpcDialogAgent(\n", + " name=\"Pro\",\n", + " port=12001,\n", + " model=\"gpt-3.5-turbo\",\n", + " use_memory=True,\n", + " sys_prompt=\"Assume the role of a debater who is arguing in favor of the proposition that AGI (Artificial General Intelligence) can be achieved using the GPT model framework. Construct a coherent and persuasive argument, including scientific, technological, and theoretical evidence, to support the statement that GPT models are a viable path to AGI. Highlight the advancements in language understanding, adaptability, and scalability of GPT models as key factors in progressing towards AGI.\",\n", ")\n", - "\n", - "proc_judge = subprocess.Popen(\n", - " ['python', 'distributed_debate.py', '--role', 'judge', '--judge-host', 'localhost', '--judge-port', '12013'],\n", - " stdout=subprocess.PIPE,\n", - " stderr=subprocess.PIPE\n", + "con_agent = RpcDialogAgent(\n", + " name=\"Con\",\n", + " port=12002,\n", + " model=\"gpt-3.5-turbo\",\n", + " use_memory=True,\n", + " sys_prompt=\"Assume the role of a debater who is arguing against the proposition that AGI can be achieved using the GPT model framework. Construct a coherent and persuasive argument, including scientific, technological, and theoretical evidence, to support the statement that GPT models, while impressive, are insufficient for reaching AGI. Discuss the limitations of GPT models such as lack of understanding, consciousness, ethical reasoning, and general problem-solving abilities that are essential for true AGI.\",\n", ")\n", - "\n", - "# The above codes will return immediately and the process will run in the background\n" + "judge_agent = RpcDialogAgent(\n", + " name=\"Judge\",\n", + " port=12003,\n", + " model=\"gpt-3.5-turbo\",\n", + " use_memory=True,\n", + " sys_prompt=\"Assume the role of an impartial judge in a debate where the affirmative side argues that AGI can be achieved using the GPT model framework, and the negative side contests this. Listen to both sides' arguments and provide an analytical judgment on which side presented a more compelling and reasonable case. Consider the strength of the evidence, the persuasiveness of the reasoning, and the overall coherence of the arguments presented by each side.\"\n", + ")" ] }, { "cell_type": "markdown", - "id": "b02bfd7f-967f-402b-a4e4-b2754faba736", + "id": "01ca8024-fa7e-4d7f-bf35-a78511a47ab3", "metadata": {}, "source": [ - "Now, we turn back to run the main function." + "Next, write the main debate competition process.\n", + "Note that we need to use `msghub` to ensure each agent in the debate knows the speeaches of all other agents." ] }, { "cell_type": "code", "execution_count": 4, - "id": "8d4a4f80-e631-49f4-9265-cdf116cd11c3", + "id": "6391fb00-f74c-42c5-b742-56b7a773f875", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "/Users/qianbingchen/AgentScope/notebook\n" + "\u001b[32m2024-01-17 11:17:48.827\u001b[0m | \u001b[1mINFO \u001b[0m | \u001b[36magentscope.agents.rpc_agent\u001b[0m:\u001b[36mlaunch\u001b[0m:\u001b[36m501\u001b[0m - \u001b[1mStarting rpc server [RpcDialogAgent] at port [12001]...\u001b[0m\n", + "2024-01-17 11:17:49.422 | INFO | agentscope.agents.rpc_agent:setup_rcp_agent_server:378 - rpc server [RpcDialogAgent] at port [12001] started successfully\n", + "\u001b[32m2024-01-17 11:17:49.435\u001b[0m | \u001b[1mINFO \u001b[0m | \u001b[36magentscope.agents.rpc_agent\u001b[0m:\u001b[36mlaunch\u001b[0m:\u001b[36m501\u001b[0m - \u001b[1mStarting rpc server [RpcDialogAgent] at port [12002]...\u001b[0m\n", + "2024-01-17 11:17:49.908 | INFO | agentscope.agents.rpc_agent:setup_rcp_agent_server:378 - rpc server [RpcDialogAgent] at port [12002] started successfully\n", + "\u001b[32m2024-01-17 11:17:49.914\u001b[0m | \u001b[1mINFO \u001b[0m | \u001b[36magentscope.agents.rpc_agent\u001b[0m:\u001b[36mlaunch\u001b[0m:\u001b[36m501\u001b[0m - \u001b[1mStarting rpc server [RpcDialogAgent] at port [12003]...\u001b[0m\n", + "2024-01-17 11:17:50.319 | INFO | agentscope.agents.rpc_agent:setup_rcp_agent_server:378 - rpc server [RpcDialogAgent] at port [12003] started successfully\n", + "2024-01-17 11:18:04.708 | WARNING | agentscope.models.model:checking_wrapper:122 - Fail to parsing response: Thank you, Mr. Moderator. Ladies and gentlemen, esteemed opponents, GPT models, particularly the OpenAI's GPT-3, indeed offer a viable path towards achieving Artificial General Intelligence (AGI). GPT models have demonstrated remarkable advancements in language understanding, adaptability, and scalability, which are fundamental capabilities required for AGI.\n", + "\n", + "Firstly, GPT models have shown exceptional progress in language understanding. GPT-3, with its vast dataset and powerful deep neural network architecture, is capable of generating coherent and contextually relevant human-like responses to a range of prompts. By comprehending and responding to natural language, GPT models serve as a foundation for building human-level AGI that can understand and engage in meaningful conversations with humans.\n", + "\n", + "Moreover, the GPT model framework embodies a remarkable degree of adaptability. GPT-3, with its 175 billion parameters, can be fine-tuned for various specific tasks, allowing it to extrapolate knowledge and perform well in a diverse range of domains. This adaptability is crucial for AGI development, as it enables learning and generalization across different contexts, mirroring the way humans acquire knowledge and skills.\n", + "\n", + "Furthermore, GPT models exhibit promising scalability. As demonstrated by the remarkable growth from GPT-2 to GPT-3, improvements in architecture, data volume, and computational power have exponentially enhanced their capabilities. The scalability of GPT models allows for the incremental development of increasingly intelligent systems, bridging the gap towards AGI.\n", + "\n", + "Critics may argue that GPT models lack true understanding and consciousness, claiming that they are mere sophisticated pattern recognition systems. While it is true that current GPT models do not possess the full cognitive abilities of AGI, their ability to understand and generate language is a significant step towards developing AGI. Language understanding is a crucial component of intelligence, and GPT models have demonstrated impressive proficiency in this domain.\n", + "\n", + "Furthermore, the GPT framework has already demonstrated its applicability beyond language understanding. Researchers have explored using GPT models for image recognition, code generation, and other tasks traditionally associated with AGI. These findings strengthen the case for AGI development using the GPT model framework, as they illustrate its potential for broader intelligence beyond language.\n", + "\n", + "In conclusion, GPT models provide a viable path to achieving AGI. Their advancements in language understanding, adaptability, and scalability make them strong contenders for the development of artificial general intelligence. While further research and development are needed, the GPT model framework offers a solid foundation for progressing towards AGI. Let us not underestimate the potential of GPT models and recognize the strides they have made in the field of AI..\n", + " Exception: Expecting value: line 1 column 1 (char 0), \t Attempt 1 / 1\n", + "Pro: Thank you, Mr. Moderator. Ladies and gentlemen, esteemed opponents, GPT models, particularly the OpenAI's GPT-3, indeed offer a viable path towards achieving Artificial General Intelligence (AGI). GPT models have demonstrated remarkable advancements in language understanding, adaptability, and scalability, which are fundamental capabilities required for AGI.\n", + "\n", + "Firstly, GPT models have shown exceptional progress in language understanding. GPT-3, with its vast dataset and powerful deep neural network architecture, is capable of generating coherent and contextually relevant human-like responses to a range of prompts. By comprehending and responding to natural language, GPT models serve as a foundation for building human-level AGI that can understand and engage in meaningful conversations with humans.\n", + "\n", + "Moreover, the GPT model framework embodies a remarkable degree of adaptability. GPT-3, with its 175 billion parameters, can be fine-tuned for various specific tasks, allowing it to extrapolate knowledge and perform well in a diverse range of domains. This adaptability is crucial for AGI development, as it enables learning and generalization across different contexts, mirroring the way humans acquire knowledge and skills.\n", + "\n", + "Furthermore, GPT models exhibit promising scalability. As demonstrated by the remarkable growth from GPT-2 to GPT-3, improvements in architecture, data volume, and computational power have exponentially enhanced their capabilities. The scalability of GPT models allows for the incremental development of increasingly intelligent systems, bridging the gap towards AGI.\n", + "\n", + "Critics may argue that GPT models lack true understanding and consciousness, claiming that they are mere sophisticated pattern recognition systems. While it is true that current GPT models do not possess the full cognitive abilities of AGI, their ability to understand and generate language is a significant step towards developing AGI. Language understanding is a crucial component of intelligence, and GPT models have demonstrated impressive proficiency in this domain.\n", + "\n", + "Furthermore, the GPT framework has already demonstrated its applicability beyond language understanding. Researchers have explored using GPT models for image recognition, code generation, and other tasks traditionally associated with AGI. These findings strengthen the case for AGI development using the GPT model framework, as they illustrate its potential for broader intelligence beyond language.\n", + "\n", + "In conclusion, GPT models provide a viable path to achieving AGI. Their advancements in language understanding, adaptability, and scalability make them strong contenders for the development of artificial general intelligence. While further research and development are needed, the GPT model framework offers a solid foundation for progressing towards AGI. Let us not underestimate the potential of GPT models and recognize the strides they have made in the field of AI.\n", + "\u001b[36m\u001b[1mPro\u001b[0m\u001b[36m\u001b[0m: Thank you, Mr. Moderator. Ladies and gentlemen, esteemed opponents, GPT models, particularly the OpenAI's GPT-3, indeed offer a viable path towards achieving Artificial General Intelligence (AGI). GPT models have demonstrated remarkable advancements in language understanding, adaptability, and scalability, which are fundamental capabilities required for AGI.\n", + "\n", + "Firstly, GPT models have shown exceptional progress in language understanding. GPT-3, with its vast dataset and powerful deep neural network architecture, is capable of generating coherent and contextually relevant human-like responses to a range of prompts. By comprehending and responding to natural language, GPT models serve as a foundation for building human-level AGI that can understand and engage in meaningful conversations with humans.\n", + "\n", + "Moreover, the GPT model framework embodies a remarkable degree of adaptability. GPT-3, with its 175 billion parameters, can be fine-tuned for various specific tasks, allowing it to extrapolate knowledge and perform well in a diverse range of domains. This adaptability is crucial for AGI development, as it enables learning and generalization across different contexts, mirroring the way humans acquire knowledge and skills.\n", + "\n", + "Furthermore, GPT models exhibit promising scalability. As demonstrated by the remarkable growth from GPT-2 to GPT-3, improvements in architecture, data volume, and computational power have exponentially enhanced their capabilities. The scalability of GPT models allows for the incremental development of increasingly intelligent systems, bridging the gap towards AGI.\n", + "\n", + "Critics may argue that GPT models lack true understanding and consciousness, claiming that they are mere sophisticated pattern recognition systems. While it is true that current GPT models do not possess the full cognitive abilities of AGI, their ability to understand and generate language is a significant step towards developing AGI. Language understanding is a crucial component of intelligence, and GPT models have demonstrated impressive proficiency in this domain.\n", + "\n", + "Furthermore, the GPT framework has already demonstrated its applicability beyond language understanding. Researchers have explored using GPT models for image recognition, code generation, and other tasks traditionally associated with AGI. These findings strengthen the case for AGI development using the GPT model framework, as they illustrate its potential for broader intelligence beyond language.\n", + "\n", + "In conclusion, GPT models provide a viable path to achieving AGI. Their advancements in language understanding, adaptability, and scalability make them strong contenders for the development of artificial general intelligence. While further research and development are needed, the GPT model framework offers a solid foundation for progressing towards AGI. Let us not underestimate the potential of GPT models and recognize the strides they have made in the field of AI.\n", + "2024-01-17 11:18:07.310 | WARNING | agentscope.models.model:checking_wrapper:122 - Fail to parsing response: Thank you to the affirmative side for presenting their argument. Now, the negative side will present their argument against the proposition that AGI can be achieved using the GPT model framework. Please proceed with your argument..\n", + " Exception: Expecting value: line 1 column 1 (char 0), \t Attempt 1 / 1\n", + "Con: Thank you to the affirmative side for presenting their argument. Now, the negative side will present their argument against the proposition that AGI can be achieved using the GPT model framework. Please proceed with your argument.\n", + "\u001b[32m\u001b[1mCon\u001b[0m\u001b[32m\u001b[0m: Thank you to the affirmative side for presenting their argument. Now, the negative side will present their argument against the proposition that AGI can be achieved using the GPT model framework. Please proceed with your argument.\n", + "2024-01-17 11:18:19.710 | WARNING | agentscope.models.model:checking_wrapper:122 - Fail to parsing response: Thank you, Mr. Moderator. Ladies and gentlemen, esteemed opponents, the notion that AGI can be achieved using the GPT model framework is a speculative claim lacking substantial evidence. While GPT models have undeniably demonstrated impressive language generation capabilities, they fall short in several key aspects necessary for AGI.\n", + "\n", + "Firstly, GPT models lack true understanding. Despite their ability to generate coherent responses, they do not possess genuine comprehension of the content they generate. GPT models operate based on statistical patterns rather than true understanding, making it challenging for them to exhibit real intelligence beyond the language domain.\n", + "\n", + "Furthermore, GPT models heavily rely on large-scale pre-training with massive amounts of text data. While this has undoubtedly enhanced their language generation capabilities, it raises concerns about biases and ethical implications. AGI should aspire to be unbiased and ethically grounded, which necessitates a more robust framework that does not rely solely on pre-existing text data.\n", + "\n", + "Additionally, the GPT model framework lacks a mechanism for active learning and exploration. To develop AGI, a system must actively seek out new knowledge and learn from experiences. GPT models, on the other hand, are limited by their reliance on pre-existing data and lack the ability to actively explore and acquire new information, hindering their potential to develop into AGI.\n", + "\n", + "Moreover, GPT models struggle with long-term memory and reasoning. They often fail to recall information from earlier parts of a conversation or context, which limits their ability to have sustained and coherent interactions. AGI should possess the capacity for long-term memory and be able to reason and integrate information over extended periods, something that GPT models currently lack.\n", + "\n", + "Lastly, GPT models face limitations in embodiment and sensory integration. AGI would ideally have an understanding of the physical world and the ability to perceive through various senses. GPT models, being purely language-based, lack the sensory input required for a comprehensive understanding of the world, making it challenging for them to embody the full spectrum of intelligence.\n", + "\n", + "In conclusion, while GPT models have demonstrated impressive language generation capabilities, they fall short in several crucial aspects necessary for AGI. True understanding, active learning, long-term memory, and embodiment are all significant challenges that GPT models have yet to overcome. We should explore alternative frameworks and approaches that address these limitations to make substantial progress towards AGI. The GPT model framework, while valuable, is not sufficient on its own to achieve AGI..\n", + " Exception: Expecting value: line 1 column 1 (char 0), \t Attempt 1 / 1\n", + "Judge: Thank you, Mr. Moderator. Ladies and gentlemen, esteemed opponents, the notion that AGI can be achieved using the GPT model framework is a speculative claim lacking substantial evidence. While GPT models have undeniably demonstrated impressive language generation capabilities, they fall short in several key aspects necessary for AGI.\n", + "\n", + "Firstly, GPT models lack true understanding. Despite their ability to generate coherent responses, they do not possess genuine comprehension of the content they generate. GPT models operate based on statistical patterns rather than true understanding, making it challenging for them to exhibit real intelligence beyond the language domain.\n", + "\n", + "Furthermore, GPT models heavily rely on large-scale pre-training with massive amounts of text data. While this has undoubtedly enhanced their language generation capabilities, it raises concerns about biases and ethical implications. AGI should aspire to be unbiased and ethically grounded, which necessitates a more robust framework that does not rely solely on pre-existing text data.\n", + "\n", + "Additionally, the GPT model framework lacks a mechanism for active learning and exploration. To develop AGI, a system must actively seek out new knowledge and learn from experiences. GPT models, on the other hand, are limited by their reliance on pre-existing data and lack the ability to actively explore and acquire new information, hindering their potential to develop into AGI.\n", + "\n", + "Moreover, GPT models struggle with long-term memory and reasoning. They often fail to recall information from earlier parts of a conversation or context, which limits their ability to have sustained and coherent interactions. AGI should possess the capacity for long-term memory and be able to reason and integrate information over extended periods, something that GPT models currently lack.\n", + "\n", + "Lastly, GPT models face limitations in embodiment and sensory integration. AGI would ideally have an understanding of the physical world and the ability to perceive through various senses. GPT models, being purely language-based, lack the sensory input required for a comprehensive understanding of the world, making it challenging for them to embody the full spectrum of intelligence.\n", + "\n", + "In conclusion, while GPT models have demonstrated impressive language generation capabilities, they fall short in several crucial aspects necessary for AGI. True understanding, active learning, long-term memory, and embodiment are all significant challenges that GPT models have yet to overcome. We should explore alternative frameworks and approaches that address these limitations to make substantial progress towards AGI. The GPT model framework, while valuable, is not sufficient on its own to achieve AGI.\n", + "\u001b[35m\u001b[1mJudge\u001b[0m\u001b[35m\u001b[0m: Thank you, Mr. Moderator. Ladies and gentlemen, esteemed opponents, the notion that AGI can be achieved using the GPT model framework is a speculative claim lacking substantial evidence. While GPT models have undeniably demonstrated impressive language generation capabilities, they fall short in several key aspects necessary for AGI.\n", + "\n", + "Firstly, GPT models lack true understanding. Despite their ability to generate coherent responses, they do not possess genuine comprehension of the content they generate. GPT models operate based on statistical patterns rather than true understanding, making it challenging for them to exhibit real intelligence beyond the language domain.\n", + "\n", + "Furthermore, GPT models heavily rely on large-scale pre-training with massive amounts of text data. While this has undoubtedly enhanced their language generation capabilities, it raises concerns about biases and ethical implications. AGI should aspire to be unbiased and ethically grounded, which necessitates a more robust framework that does not rely solely on pre-existing text data.\n", + "\n", + "Additionally, the GPT model framework lacks a mechanism for active learning and exploration. To develop AGI, a system must actively seek out new knowledge and learn from experiences. GPT models, on the other hand, are limited by their reliance on pre-existing data and lack the ability to actively explore and acquire new information, hindering their potential to develop into AGI.\n", + "\n", + "Moreover, GPT models struggle with long-term memory and reasoning. They often fail to recall information from earlier parts of a conversation or context, which limits their ability to have sustained and coherent interactions. AGI should possess the capacity for long-term memory and be able to reason and integrate information over extended periods, something that GPT models currently lack.\n", + "\n", + "Lastly, GPT models face limitations in embodiment and sensory integration. AGI would ideally have an understanding of the physical world and the ability to perceive through various senses. GPT models, being purely language-based, lack the sensory input required for a comprehensive understanding of the world, making it challenging for them to embody the full spectrum of intelligence.\n", + "\n", + "In conclusion, while GPT models have demonstrated impressive language generation capabilities, they fall short in several crucial aspects necessary for AGI. True understanding, active learning, long-term memory, and embodiment are all significant challenges that GPT models have yet to overcome. We should explore alternative frameworks and approaches that address these limitations to make substantial progress towards AGI. The GPT model framework, while valuable, is not sufficient on its own to achieve AGI.\n", + "2024-01-17 11:18:27.439 | WARNING | agentscope.models.model:checking_wrapper:122 - Fail to parsing response: Thank you to both sides for presenting your arguments. Let's now move on to the adjudicator's summary and analysis.\n", + "\n", + "Both sides presented compelling arguments regarding the potential of GPT models in achieving AGI. The affirmative side argued that GPT models have made significant advancements in language understanding, adaptability, and scalability, showing great potential for AGI. Their emphasis on the importance of language understanding as a core component of intelligence and the ability of GPT models to generalize across domains were strong points.\n", + "\n", + "On the other hand, the negative side raised valid concerns about the limitations of GPT models. They highlighted the lack of true understanding, reliance on large-scale pre-training, absence of active learning and exploration, limitations in long-term memory and reasoning, and the lack of embodiment and sensory integration. These limitations are indeed significant challenges in the path towards AGI.\n", + "\n", + "Overall, both sides made compelling arguments, but the negative side presented more substantial concerns that cast doubt on whether the GPT model framework alone can achieve AGI. While GPT models have shown remarkable advancements in language generation, they still lack key aspects necessary for AGI, such as true understanding and active learning.\n", + "\n", + "Therefore, based on the strength of the arguments and the concerns raised by the negative side, I would conclude that AGI cannot be fully achieved using the GPT model framework alone. Alternative approaches and frameworks that address the identified limitations must be explored to make substantial progress towards AGI.\n", + "\n", + "Please note that this analysis only pertains to the first round of the debate. The subsequent rounds will provide an opportunity for both sides to further strengthen their arguments and address any shortcomings..\n", + " Exception: Expecting value: line 1 column 1 (char 0), \t Attempt 1 / 1\n", + "Pro: Thank you to both sides for presenting your arguments. Let's now move on to the adjudicator's summary and analysis.\n", + "\n", + "Both sides presented compelling arguments regarding the potential of GPT models in achieving AGI. The affirmative side argued that GPT models have made significant advancements in language understanding, adaptability, and scalability, showing great potential for AGI. Their emphasis on the importance of language understanding as a core component of intelligence and the ability of GPT models to generalize across domains were strong points.\n", + "\n", + "On the other hand, the negative side raised valid concerns about the limitations of GPT models. They highlighted the lack of true understanding, reliance on large-scale pre-training, absence of active learning and exploration, limitations in long-term memory and reasoning, and the lack of embodiment and sensory integration. These limitations are indeed significant challenges in the path towards AGI.\n", + "\n", + "Overall, both sides made compelling arguments, but the negative side presented more substantial concerns that cast doubt on whether the GPT model framework alone can achieve AGI. While GPT models have shown remarkable advancements in language generation, they still lack key aspects necessary for AGI, such as true understanding and active learning.\n", + "\n", + "Therefore, based on the strength of the arguments and the concerns raised by the negative side, I would conclude that AGI cannot be fully achieved using the GPT model framework alone. Alternative approaches and frameworks that address the identified limitations must be explored to make substantial progress towards AGI.\n", + "\n", + "Please note that this analysis only pertains to the first round of the debate. The subsequent rounds will provide an opportunity for both sides to further strengthen their arguments and address any shortcomings.\n", + "\u001b[36m\u001b[1mPro\u001b[0m\u001b[36m\u001b[0m: Thank you to both sides for presenting your arguments. Let's now move on to the adjudicator's summary and analysis.\n", + "\n", + "Both sides presented compelling arguments regarding the potential of GPT models in achieving AGI. The affirmative side argued that GPT models have made significant advancements in language understanding, adaptability, and scalability, showing great potential for AGI. Their emphasis on the importance of language understanding as a core component of intelligence and the ability of GPT models to generalize across domains were strong points.\n", + "\n", + "On the other hand, the negative side raised valid concerns about the limitations of GPT models. They highlighted the lack of true understanding, reliance on large-scale pre-training, absence of active learning and exploration, limitations in long-term memory and reasoning, and the lack of embodiment and sensory integration. These limitations are indeed significant challenges in the path towards AGI.\n", + "\n", + "Overall, both sides made compelling arguments, but the negative side presented more substantial concerns that cast doubt on whether the GPT model framework alone can achieve AGI. While GPT models have shown remarkable advancements in language generation, they still lack key aspects necessary for AGI, such as true understanding and active learning.\n", + "\n", + "Therefore, based on the strength of the arguments and the concerns raised by the negative side, I would conclude that AGI cannot be fully achieved using the GPT model framework alone. Alternative approaches and frameworks that address the identified limitations must be explored to make substantial progress towards AGI.\n", + "\n", + "Please note that this analysis only pertains to the first round of the debate. The subsequent rounds will provide an opportunity for both sides to further strengthen their arguments and address any shortcomings.\n", + "2024-01-17 11:18:30.558 | WARNING | agentscope.models.model:checking_wrapper:122 - Fail to parsing response: Thank you, Mr. Adjudicator, for providing your analysis and summary of the arguments presented in the first round of the debate. We will now move on to the second round, where the affirmative side will have the chance to respond to the points raised by the negative side and further support their position. The negative side will then have the opportunity to counter the affirmative side's responses and reinforce their arguments. Let us begin with the second round, starting with the affirmative side..\n", + " Exception: Expecting value: line 1 column 1 (char 0), \t Attempt 1 / 1\n", + "Con: Thank you, Mr. Adjudicator, for providing your analysis and summary of the arguments presented in the first round of the debate. We will now move on to the second round, where the affirmative side will have the chance to respond to the points raised by the negative side and further support their position. The negative side will then have the opportunity to counter the affirmative side's responses and reinforce their arguments. Let us begin with the second round, starting with the affirmative side.\n", + "\u001b[32m\u001b[1mCon\u001b[0m\u001b[32m\u001b[0m: Thank you, Mr. Adjudicator, for providing your analysis and summary of the arguments presented in the first round of the debate. We will now move on to the second round, where the affirmative side will have the chance to respond to the points raised by the negative side and further support their position. The negative side will then have the opportunity to counter the affirmative side's responses and reinforce their arguments. Let us begin with the second round, starting with the affirmative side.\n", + "2024-01-17 11:18:34.081 | WARNING | agentscope.models.model:checking_wrapper:122 - Fail to parsing response: I apologize, but as an AI language model, I'm not capable of facilitating a live debate or participating in real-time discussions. My previous response was a simulated presentation of the role of an impartial judge in such a debate. If you have any other questions, feel free to ask!.\n", + " Exception: Expecting value: line 1 column 1 (char 0), \t Attempt 1 / 1\n", + "Judge: I apologize, but as an AI language model, I'm not capable of facilitating a live debate or participating in real-time discussions. My previous response was a simulated presentation of the role of an impartial judge in such a debate. If you have any other questions, feel free to ask!\n", + "\u001b[35m\u001b[1mJudge\u001b[0m\u001b[35m\u001b[0m: I apologize, but as an AI language model, I'm not capable of facilitating a live debate or participating in real-time discussions. My previous response was a simulated presentation of the role of an impartial judge in such a debate. If you have any other questions, feel free to ask!\n", + "2024-01-17 11:18:38.387 | WARNING | agentscope.models.model:checking_wrapper:122 - Fail to parsing response: I apologize, but as an AI language model, I am not able to participate in a live debate or present arguments in real-time. My purpose is to provide information and assist with generating text based on the prompts given to me. If you have any other questions or need assistance with a different topic, feel free to ask!.\n", + " Exception: Expecting value: line 1 column 1 (char 0), \t Attempt 1 / 1\n", + "Pro: I apologize, but as an AI language model, I am not able to participate in a live debate or present arguments in real-time. My purpose is to provide information and assist with generating text based on the prompts given to me. If you have any other questions or need assistance with a different topic, feel free to ask!\n", + "\u001b[36m\u001b[1mPro\u001b[0m\u001b[36m\u001b[0m: I apologize, but as an AI language model, I am not able to participate in a live debate or present arguments in real-time. My purpose is to provide information and assist with generating text based on the prompts given to me. If you have any other questions or need assistance with a different topic, feel free to ask!\n", + "2024-01-17 11:18:45.937 | WARNING | agentscope.models.model:checking_wrapper:122 - Fail to parsing response: I apologize if my initial response led to any confusion. As an AI language model, I am unable to actively participate in a live debate or present arguments in real-time. My purpose is to generate text based on the given prompts and provide information to the best of my abilities. If you have any other questions or need assistance with a different topic, feel free to ask!.\n", + " Exception: Expecting value: line 1 column 1 (char 0), \t Attempt 1 / 1\n", + "Con: I apologize if my initial response led to any confusion. As an AI language model, I am unable to actively participate in a live debate or present arguments in real-time. My purpose is to generate text based on the given prompts and provide information to the best of my abilities. If you have any other questions or need assistance with a different topic, feel free to ask!\n", + "\u001b[32m\u001b[1mCon\u001b[0m\u001b[32m\u001b[0m: I apologize if my initial response led to any confusion. As an AI language model, I am unable to actively participate in a live debate or present arguments in real-time. My purpose is to generate text based on the given prompts and provide information to the best of my abilities. If you have any other questions or need assistance with a different topic, feel free to ask!\n", + "2024-01-17 11:18:50.249 | WARNING | agentscope.models.model:checking_wrapper:122 - Fail to parsing response: I apologize for any confusion, but as an AI language model, I am unable to participate in live debates or provide real-time responses. My purpose is to provide information and assist with generating text based on the given prompts. If you have any other questions or need assistance with a different topic, please let me know!.\n", + " Exception: Expecting value: line 1 column 1 (char 0), \t Attempt 1 / 1\n", + "Judge: I apologize for any confusion, but as an AI language model, I am unable to participate in live debates or provide real-time responses. My purpose is to provide information and assist with generating text based on the given prompts. If you have any other questions or need assistance with a different topic, please let me know!\n", + "\u001b[35m\u001b[1mJudge\u001b[0m\u001b[35m\u001b[0m: I apologize for any confusion, but as an AI language model, I am unable to participate in live debates or provide real-time responses. My purpose is to provide information and assist with generating text based on the given prompts. If you have any other questions or need assistance with a different topic, please let me know!\n", + "2024-01-17 11:18:53.581 | WARNING | agentscope.models.model:checking_wrapper:122 - Fail to parsing response: In summary, as an impartial judge, I cannot continue the debate or provide a judgment on the second round because I am an AI language model and cannot facilitate a live debate or participate in real-time discussions. My initial response was an example of how an impartial judge might approach the debate, based on the arguments provided. If there are any other questions or topics you'd like assistance with, please let me know..\n", + " Exception: Expecting value: line 1 column 1 (char 0), \t Attempt 1 / 1\n", + "Judge: In summary, as an impartial judge, I cannot continue the debate or provide a judgment on the second round because I am an AI language model and cannot facilitate a live debate or participate in real-time discussions. My initial response was an example of how an impartial judge might approach the debate, based on the arguments provided. If there are any other questions or topics you'd like assistance with, please let me know.\n", + "\u001b[35m\u001b[1mJudge\u001b[0m\u001b[35m\u001b[0m: In summary, as an impartial judge, I cannot continue the debate or provide a judgment on the second round because I am an AI language model and cannot facilitate a live debate or participate in real-time discussions. My initial response was an example of how an impartial judge might approach the debate, based on the arguments provided. If there are any other questions or topics you'd like assistance with, please let me know.\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ - "/Users/qianbingchen/miniconda3/envs/agent/lib/python3.9/site-packages/IPython/core/magics/osm.py:417: UserWarning: using dhist requires you to install the `pickleshare` library.\n", - " self.shell.db['dhist'] = compress_dhist(dhist)[-100:]\n" + "2024-01-17 11:17:49.403 | INFO | agentscope.models:read_model_configs:147 - Load configs for model: gpt-3.5-turbo\n", + "2024-01-17 11:17:49.891 | INFO | agentscope.models:read_model_configs:147 - Load configs for model: gpt-3.5-turbo\n", + "2024-01-17 11:17:50.306 | INFO | agentscope.models:read_model_configs:147 - Load configs for model: gpt-3.5-turbo\n" ] } ], "source": [ - "%cd ../../notebook/" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "id": "bdae9ef1-08b1-424b-ab5b-735cb854af7d", - "metadata": {}, - "outputs": [], - "source": [ - "model_configs = [\n", - " {\n", - " \"type\": \"openai\",\n", - " \"name\": \"gpt-3.5-turbo\",\n", - " \"parameters\": {\n", - " \"api_key\": \"xxx\",\n", - " \"organization_id\": \"xxx\",\n", - " \"temperature\": 0.0\n", - " }\n", - " },\n", - " {\n", - " \"type\": \"openai\",\n", - " \"name\": \"gpt-4\",\n", - " \"parameters\": {\n", - " \"api_key\": \"xxx\",\n", - " \"organization_id\": \"xxx\",\n", - " \"temperature\": 0.0\n", - " }\n", - " }\n", - "]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "6391fb00-f74c-42c5-b742-56b7a773f875", - "metadata": {}, - "outputs": [], - "source": [ - "# -*- coding: utf-8 -*-\n", - "\"\"\" An example of distributed debate \"\"\"\n", - "\n", - "import argparse\n", - "import json\n", - "\n", - "import agentscope\n", "from agentscope.msghub import msghub\n", - "from agentscope.agents.rpc_dialog_agent import RpcDialogAgent\n", "from agentscope.message import Msg\n", "from agentscope.utils.logging_utils import logger\n", "\n", + "# Rules explained before the debate begins \n", "ANNOUNCEMENT = \"\"\"\n", "Welcome to the debate on whether Artificial General Intelligence (AGI) can be achieved using the GPT model framework. This debate will consist of three rounds. In each round, the affirmative side will present their argument first, followed by the negative side. After both sides have presented, the adjudicator will summarize the key points and analyze the strengths of the arguments.\n", "\n", @@ -231,32 +315,10 @@ "The adjudicator's summary will not declare a winner for the individual rounds but will focus on the quality and persuasiveness of the arguments.\n", "At the conclusion of the three rounds, the adjudicator will declare the overall winner based on which side won two out of the three rounds, considering the consistency and strength of the arguments throughout the debate.\n", "Let us begin the first round. The affirmative side: please present your argument for why AGI can be achieved using the GPT model framework.\n", - "\"\"\" # noqa\n", + "\"\"\"\n", "\n", "\n", "\"\"\"Setup the main debate competition process\"\"\"\n", - "\n", - "agentscope.init(\n", - " model_configs=model_configs,\n", - ")\n", - "pro_agent = RpcDialogAgent(\n", - " name=\"Pro\",\n", - " host=\"localhost\",\n", - " port=12011,\n", - " launch_server=False,\n", - ")\n", - "con_agent = RpcDialogAgent(\n", - " name=\"Con\",\n", - " host=\"localhost\",\n", - " port=12012,\n", - " launch_server=False,\n", - ")\n", - "judge_agent = RpcDialogAgent(\n", - " name=\"Judge\",\n", - " host=\"localhost\",\n", - " port=12013,\n", - " launch_server=False,\n", - ")\n", "participants = [pro_agent, con_agent, judge_agent]\n", "hint = Msg(name=\"System\", content=ANNOUNCEMENT)\n", "x = None\n", @@ -274,22 +336,10 @@ }, { "cell_type": "markdown", - "id": "92afdcd1-244a-48b9-8d3c-ab3cdc024f62", + "id": "dbfc5033", "metadata": {}, "source": [ - "Finally, terminte process in the backend." - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "d7946ae1-4828-4ad6-a075-204e61352b5d", - "metadata": {}, - "outputs": [], - "source": [ - "proc_pro.terminate()\n", - "proc_con.terminate()\n", - "proc_judge.terminate()" + "Finally, just wait for the above code to run and watch the debate proceed." ] } ], @@ -309,7 +359,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.18" + "version": "3.10.9" } }, "nbformat": 4, diff --git a/src/agentscope/agents/rpc_agent.py b/src/agentscope/agents/rpc_agent.py index ae438ede8..d6d0faf23 100644 --- a/src/agentscope/agents/rpc_agent.py +++ b/src/agentscope/agents/rpc_agent.py @@ -292,6 +292,9 @@ def observe(self, x: Union[dict, Sequence[dict]]) -> None: x (`Union[dict, Sequence[dict]]`): The input to be observed. """ + if self.client is None: + self.server_launcher.launch() + self.client = RpcAgentClient(host=self.host, port=self.port) self.client.call_func( func_name="_observe", value=serialize(x), # type: ignore [arg-type]