mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-05 14:55:18 +02:00
minor update
This commit is contained in:
parent
fa8eb17451
commit
e0381680ad
2 changed files with 13 additions and 16 deletions
|
|
@ -6,6 +6,8 @@ Author: garylin2099
|
|||
import re
|
||||
import subprocess
|
||||
|
||||
import fire
|
||||
|
||||
from metagpt.actions import Action
|
||||
from metagpt.roles import Role
|
||||
from metagpt.schema import Message
|
||||
|
|
@ -127,15 +129,12 @@ class RunnableCoder(Role):
|
|||
await self._act()
|
||||
return Message(content="All job done", role=self.profile)
|
||||
|
||||
if __name__ == "__main__":
|
||||
import asyncio
|
||||
async def main(msg="write a function that calculates the sum of a list"):
|
||||
# role = SimpleCoder()
|
||||
role = RunnableCoder()
|
||||
logger.info(msg)
|
||||
result = await role.run(msg)
|
||||
logger.info(result)
|
||||
|
||||
async def main():
|
||||
msg = "write a function that calculates the sum of a list"
|
||||
# role = SimpleCoder()
|
||||
role = RunnableCoder()
|
||||
logger.info(msg)
|
||||
result = await role.run(msg)
|
||||
logger.info(result)
|
||||
|
||||
asyncio.run(main())
|
||||
if __name__ == '__main__':
|
||||
fire.Fire(main)
|
||||
|
|
@ -56,7 +56,7 @@ class Trump(Role):
|
|||
await super()._observe()
|
||||
self._rc.news = [
|
||||
msg for msg in self._rc.news if msg.send_to == self.name
|
||||
] # only relevant msgs count as observed news
|
||||
] # accept messages sent (from opponent) to self, disregard own messages from the last round
|
||||
return len(self._rc.news)
|
||||
|
||||
async def _act(self) -> Message:
|
||||
|
|
@ -77,7 +77,6 @@ class Trump(Role):
|
|||
sent_from=self.name,
|
||||
send_to=self.opponent_name,
|
||||
)
|
||||
self._publish_message(msg)
|
||||
|
||||
return msg
|
||||
|
||||
|
|
@ -97,8 +96,8 @@ class Biden(Role):
|
|||
async def _observe(self) -> int:
|
||||
await super()._observe()
|
||||
self._rc.news = [
|
||||
msg for msg in self._rc.news if msg.send_to == self.name or msg.cause_by == BossRequirement
|
||||
] # only relevant msgs count as observed news
|
||||
msg for msg in self._rc.news if msg.cause_by == BossRequirement or msg.send_to == self.name
|
||||
] # accept the very first human instruction (the debate topic) or messages sent (from opponent) to self, disregard own messages from the last round
|
||||
return len(self._rc.news)
|
||||
|
||||
async def _act(self) -> Message:
|
||||
|
|
@ -119,7 +118,6 @@ class Biden(Role):
|
|||
sent_from=self.name,
|
||||
send_to=self.opponent_name,
|
||||
)
|
||||
self._publish_message(msg)
|
||||
|
||||
return msg
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue