From 6cd083a2b71037d88372d5645bce174514a392ae Mon Sep 17 00:00:00 2001 From: geekan Date: Fri, 22 Dec 2023 17:48:54 +0800 Subject: [PATCH] tuning performance --- examples/agent_creator.py | 2 +- examples/build_customized_agent.py | 4 ++-- examples/build_customized_multi_agents.py | 2 +- examples/debate.py | 2 +- examples/debate_simple.py | 8 ++++---- metagpt/actions/write_code_review.py | 2 +- metagpt/roles/role.py | 2 +- metagpt/roles/searcher.py | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/agent_creator.py b/examples/agent_creator.py index 961d12968..dbb6f735a 100644 --- a/examples/agent_creator.py +++ b/examples/agent_creator.py @@ -67,7 +67,7 @@ class AgentCreator(Role): self.agent_template = agent_template async def _act(self) -> Message: - logger.info(f"{self._setting}: to do {self._rc.todo}") + logger.info(f"{self._setting}: to do {self._rc.todo}({self._rc.todo.name})") todo = self._rc.todo msg = self._rc.memory.get()[-1] diff --git a/examples/build_customized_agent.py b/examples/build_customized_agent.py index eb92d9a9c..ccdf7748a 100644 --- a/examples/build_customized_agent.py +++ b/examples/build_customized_agent.py @@ -65,7 +65,7 @@ class SimpleCoder(Role): self._init_actions([SimpleWriteCode]) async def _act(self) -> Message: - logger.info(f"{self._setting}: to do {self._rc.todo}") + logger.info(f"{self._setting}: to do {self._rc.todo}({self._rc.todo.name})") todo = self._rc.todo # todo will be SimpleWriteCode() msg = self.get_memories(k=1)[0] # find the most recent messages @@ -87,7 +87,7 @@ class RunnableCoder(Role): self._set_react_mode(react_mode="by_order") async def _act(self) -> Message: - logger.info(f"{self._setting}: to do {self._rc.todo}") + logger.info(f"{self._setting}: to do {self._rc.todo}({self._rc.todo.name})") # By choosing the Action by order under the hood # todo will be first SimpleWriteCode() then SimpleRunCode() todo = self._rc.todo diff --git a/examples/build_customized_multi_agents.py b/examples/build_customized_multi_agents.py index 865c09c37..16c36e08d 100644 --- a/examples/build_customized_multi_agents.py +++ b/examples/build_customized_multi_agents.py @@ -88,7 +88,7 @@ class SimpleTester(Role): self._watch([SimpleWriteCode, SimpleWriteReview]) # feel free to try this too async def _act(self) -> Message: - logger.info(f"{self._setting}: to do {self._rc.todo}") + logger.info(f"{self._setting}: to do {self._rc.todo}({self._rc.todo.name})") todo = self._rc.todo # context = self.get_memories(k=1)[0].content # use the most recent memory as context diff --git a/examples/debate.py b/examples/debate.py index ba15abda8..b3d287079 100644 --- a/examples/debate.py +++ b/examples/debate.py @@ -63,7 +63,7 @@ class Debator(Role): return len(self._rc.news) async def _act(self) -> Message: - logger.info(f"{self._setting}: to do {self._rc.todo}") + logger.info(f"{self._setting}: to do {self._rc.todo}({self._rc.todo.name})") todo = self._rc.todo # An instance of SpeakAloud memories = self.get_memories() diff --git a/examples/debate_simple.py b/examples/debate_simple.py index b90af4f82..524449771 100644 --- a/examples/debate_simple.py +++ b/examples/debate_simple.py @@ -12,10 +12,10 @@ from metagpt.environment import Environment from metagpt.roles import Role from metagpt.team import Team -action1 = Action(name="BidenSay", instruction="发表政见,充满激情的与对手辩论") -action2 = Action(name="TrumpSay", instruction="发表政见,充满激情的与对手辩论,MAGA!") -biden = Role(name="拜登", profile="民主党", goal="大选获胜", actions=[action1], watch=[action2, UserRequirement]) -trump = Role(name="特朗普", profile="共和党", goal="大选获胜", actions=[action2], watch=[action1]) +action1 = Action(name="BidenSay", instruction="发表政见,充满激情的反驳特朗普最新消息,尽最大努力获得选票") +action2 = Action(name="TrumpSay", instruction="发表政见,充满激情的反驳拜登最新消息,尽最大努力获得选票,MAGA!") +biden = Role(name="拜登", profile="民主党候选人", goal="大选获胜", actions=[action1], watch=[action2, UserRequirement]) +trump = Role(name="特朗普", profile="共和党候选人", goal="大选获胜", actions=[action2], watch=[action1]) env = Environment(desc="US election live broadcast") team = Team(investment=10.0, env=env, roles=[biden, trump]) diff --git a/metagpt/actions/write_code_review.py b/metagpt/actions/write_code_review.py index 1eba672a5..b0e7904e3 100644 --- a/metagpt/actions/write_code_review.py +++ b/metagpt/actions/write_code_review.py @@ -40,7 +40,7 @@ EXAMPLE_AND_INSTRUCTION = """ {format_example} -# Instruction: Based on the actual code situation, follow one of the "Format example". +# Instruction: Based on the actual code situation, follow one of the "Format example". Return only 1 file under review. ## Code Review: Ordered List. Based on the "Code to be Reviewed", provide key, clear, concise, and specific answer. If any answer is no, explain how to fix it step by step. 1. Is the code implemented as per the requirements? If not, how to achieve it? Analyse it step by step. diff --git a/metagpt/roles/role.py b/metagpt/roles/role.py index 91e56bade..d868e820f 100644 --- a/metagpt/roles/role.py +++ b/metagpt/roles/role.py @@ -395,7 +395,7 @@ class Role(BaseModel): self._set_state(next_state) async def _act(self) -> Message: - logger.info(f"{self._setting}: to do {self._rc.todo}") + logger.info(f"{self._setting}: to do {self._rc.todo}({self._rc.todo.name})") response = await self._rc.todo.run(self._rc.important_memory) if isinstance(response, (ActionOutput, ActionNode)): msg = Message( diff --git a/metagpt/roles/searcher.py b/metagpt/roles/searcher.py index da844b4dc..6e2bd8bc9 100644 --- a/metagpt/roles/searcher.py +++ b/metagpt/roles/searcher.py @@ -57,7 +57,7 @@ class Searcher(Role): async def _act_sp(self) -> Message: """Performs the search action in a single process.""" - logger.info(f"{self._setting}: to do {self._rc.todo}") + logger.info(f"{self._setting}: to do {self._rc.todo}({self._rc.todo.name})") response = await self._rc.todo.run(self._rc.memory.get(k=0)) if isinstance(response, (ActionOutput, ActionNode)):