Skip to content

🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming

minor update

yzline0381680adcb
diff --git a/examples/build_customized_agent.py b/examples/build_customized_agent.py
index 312ffa4d5..746c8c9fa 100644
--- a/examples/build_customized_agent.py
+++ b/examples/build_customized_agent.py
@@ -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())
\ No newline at end of file
+if __name__ == '__main__':
+ fire.Fire(main)
\ No newline at end of file
diff --git a/examples/debate.py b/examples/debate.py
index 4e90edd20..3a9abf9bc 100644
--- a/examples/debate.py
+++ b/examples/debate.py
@@ -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