fixbug: rfc243

This commit is contained in:
莘权 马 2024-06-15 15:35:47 +08:00
commit e1b3bd3869
17 changed files with 378 additions and 46 deletions

View file

@ -19,11 +19,12 @@ from metagpt.config2 import Config
from metagpt.const import DEFAULT_WORKSPACE_ROOT
from metagpt.context import Context
from metagpt.environment import Environment
from metagpt.environment.mgx.mgx_env import MGXEnv
from metagpt.logs import logger
from metagpt.roles import Architect
from metagpt.roles.di.team_leader import TeamLeader
from metagpt.schema import AIMessage, UserMessage
from metagpt.utils.common import any_to_str, aread, to_markdown_code_block
from metagpt.utils.common import aread, to_markdown_code_block
app = typer.Typer(add_completion=False)
@ -37,19 +38,9 @@ class EnvBuilder(BaseModel):
output_dir: Path
def build(self) -> Environment:
env = Environment(context=self.context)
env = MGXEnv(context=self.context)
team_leader = TeamLeader()
architect = Architect()
architect.tools.extend(
[
"CompressExternalInterfaces",
"DetectInteraction",
"EvaluateTRD",
"WriteTRD",
"WriteFramework",
"EvaluateFramework",
]
)
# Prepare context
use_case_actors = "".join([f"- {v}: {k}\n" for k, v in self.actors.items()])
@ -111,7 +102,8 @@ async def develop(
{user_requirements}
"""
env.publish_message(
UserMessage(content=msg.format(user_requirements="\n".join(user_requirements)), send_to=any_to_str(TeamLeader))
UserMessage(content=msg.format(user_requirements="\n".join(user_requirements)), send_to="Bob"),
user_defined_recipient="Bob",
)
while not env.is_idle:

View file

@ -49,7 +49,7 @@ async def _write_trd(
evaluation_conclusion = ""
interaction_events = ""
trd = ""
while not is_pass:
while not is_pass and (context.cost_manager.total_cost < context.cost_manager.max_budget):
interaction_events = await detect_interaction.run(
user_requirements=r,
use_case_actors=use_case_actors,
@ -99,7 +99,7 @@ async def _write_framework(context: Context, use_case_actors: str, trd: str, ack
is_pass = False
framework = ""
evaluation_conclusion = ""
while not is_pass:
while not is_pass and (context.cost_manager.total_cost < context.cost_manager.max_budget):
try:
framework = await write_framework.run(
use_case_actors=use_case_actors,
@ -175,6 +175,7 @@ def startup(
llm_config: str = typer.Option(default="", help="Low-cost LLM config"),
constraint_filename: str = typer.Option(default="", help="What technical dependency constraints are."),
output_dir: str = typer.Option(default="", help="Output directory."),
investment: float = typer.Option(default=15.0, help="Dollar amount to invest in the AI company."),
):
if llm_config and Path(llm_config).exists():
config = Config.from_yaml_file(Path(llm_config))
@ -182,6 +183,7 @@ def startup(
logger.info("GPT 4 turbo is recommended")
config = Config.default()
ctx = Context(config=config)
ctx.cost_manager.max_budget = investment
asyncio.run(
develop(ctx, user_requirement_filename, actors_filename, acknowledge_filename, constraint_filename, output_dir)