Skip to content

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

feat: merge geekan:main

莘权 马073a10ce024e
diff --cc metagpt/roles/role.py
index 9636a1f30,9d0898b71..528e7d72d
--- a/metagpt/roles/role.py
+++ b/metagpt/roles/role.py
@@@ -354,12 -346,19 +355,19 @@@ class Role(BaseModel)
"""Get the role prefix"""
if self.desc:
return self.desc
- return PREFIX_TEMPLATE.format(
- **{"profile": self.profile, "name": self.name, "goal": self.goal, "constraints": self.constraints}
- )
+
+ prefix = PREFIX_TEMPLATE.format(**{"profile": self.profile, "name": self.name, "goal": self.goal})
+
+ if self.constraints:
+ prefix += CONSTRAINT_TEMPLATE.format(**{"constraints": self.constraints})
+
+ if self._rc.env and self._rc.env.desc:
+ env_desc = f"You are in {self._rc.env.desc} with roles({self._rc.env.role_names()})."
+ prefix += env_desc
+ return prefix
- async def _think(self) -> None:
- """Think about what to do and decide on the next action"""
+ async def _think(self) -> bool:
+ """Consider what to do and decide on the next course of action. Return false if nothing can be done."""
if len(self._actions) == 1:
# If there is only one action, then only this one can be performed
self._set_state(0)
diff --cc metagpt/team.py
index ed370fd16,0b9f042df..625903e3e
--- a/metagpt/team.py
+++ b/metagpt/team.py
@@@ -117,8 -120,11 +124,11 @@@ class Team(BaseModel)
logger.info(self.json(ensure_ascii=False))
@serialize_decorator
- async def run(self, n_round=3, auto_archive=True):
- async def run(self, n_round=3, idea=""):
++ async def run(self, n_round=3, idea="", auto_archive=True):
"""Run company until target round or no money"""
+ if idea:
+ self.run_project(idea=idea)
+
while n_round > 0:
# self._save()
n_round -= 1