fix bugs and make it perform better

This commit is contained in:
geekan 2023-12-22 17:15:36 +08:00
parent 49377c9db0
commit 058252c636
11 changed files with 59 additions and 32 deletions

View file

@ -67,7 +67,7 @@ class AgentCreator(Role):
self.agent_template = agent_template
async def _act(self) -> Message:
logger.info(f"{self._setting}: ready to {self._rc.todo}")
logger.info(f"{self._setting}: to do {self._rc.todo}")
todo = self._rc.todo
msg = self._rc.memory.get()[-1]

View file

@ -65,7 +65,7 @@ class SimpleCoder(Role):
self._init_actions([SimpleWriteCode])
async def _act(self) -> Message:
logger.info(f"{self._setting}: ready to {self._rc.todo}")
logger.info(f"{self._setting}: to do {self._rc.todo}")
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}: ready to {self._rc.todo}")
logger.info(f"{self._setting}: to do {self._rc.todo}")
# By choosing the Action by order under the hood
# todo will be first SimpleWriteCode() then SimpleRunCode()
todo = self._rc.todo

View file

@ -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}: ready to {self._rc.todo}")
logger.info(f"{self._setting}: to do {self._rc.todo}")
todo = self._rc.todo
# context = self.get_memories(k=1)[0].content # use the most recent memory as context

View file

@ -63,7 +63,7 @@ class Debator(Role):
return len(self._rc.news)
async def _act(self) -> Message:
logger.info(f"{self._setting}: ready to {self._rc.todo}")
logger.info(f"{self._setting}: to do {self._rc.todo}")
todo = self._rc.todo # An instance of SpeakAloud
memories = self.get_memories()

View file

@ -8,13 +8,15 @@
import asyncio
from metagpt.actions import Action, UserRequirement
from metagpt.environment import Environment
from metagpt.roles import Role
from metagpt.team import Team
action1 = Action(name="BidenSay", instruction="Use diverse words to attack your opponent, strong and emotional.")
action2 = Action(name="TrumpSay", instruction="Use diverse words to attack your opponent, strong and emotional.")
biden = Role(name="Biden", profile="democrat", goal="win election", actions=[action1], watch=[action2, UserRequirement])
trump = Role(name="Trump", profile="republican", goal="win election", actions=[action2], watch=[action1])
team = Team(investment=10.0, env_desc="US election live broadcast", roles=[biden, trump])
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])
asyncio.run(team.run(idea="Topic: climate change", n_round=5))
asyncio.run(team.run(idea="主题:气候变化,用中文辩论", n_round=5))