2023-11-20 11:24:46 +08:00
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import asyncio
2023-12-04 23:04:07 +08:00
from pathlib import Path
2023-11-28 18:16:50 +08:00
2023-11-20 11:24:46 +08:00
import typer
2023-11-29 16:22:05 +08:00
from metagpt . config import CONFIG
2023-11-20 11:24:46 +08:00
app = typer . Typer ( )
@app.command ( )
def startup (
idea : str = typer . Argument ( . . . , help = " Your innovative idea, such as ' Create a 2048 game. ' " ) ,
2023-11-29 20:12:03 +08:00
investment : float = typer . Option ( default = 3.0 , help = " Dollar amount to invest in the AI company. " ) ,
n_round : int = typer . Option ( default = 5 , help = " Number of rounds for the simulation. " ) ,
code_review : bool = typer . Option ( default = True , help = " Whether to use code review. " ) ,
run_tests : bool = typer . Option ( default = False , help = " Whether to enable QA for adding & running tests. " ) ,
implement : bool = typer . Option ( default = True , help = " Enable or disable code implementation. " ) ,
project_name : str = typer . Option ( default = " " , help = " Unique project name, such as ' game_2048 ' . " ) ,
inc : bool = typer . Option ( default = False , help = " Incremental mode. Use it to coop with existing repo. " ) ,
2023-11-29 16:22:05 +08:00
project_path : str = typer . Option (
2023-11-29 20:12:03 +08:00
default = " " ,
help = " Specify the directory path of the old version project to fulfill the " " incremental requirements. " ,
2023-11-29 16:22:05 +08:00
) ,
2023-11-29 20:12:03 +08:00
reqa_file : str = typer . Option ( default = " " , help = " Specify the source file name for rewriting the quality test code. " ) ,
2023-12-04 23:04:07 +08:00
max_auto_summarize_code : int = typer . Option (
default = - 1 ,
help = " The maximum number of times the ' SummarizeCode ' action is automatically invoked, with -1 indicating unlimited. This parameter is used for debugging the workflow. " ,
) ,
2023-11-20 11:24:46 +08:00
) :
""" Run a startup. Be a boss. """
2023-11-28 18:16:50 +08:00
from metagpt . roles import (
Architect ,
Engineer ,
ProductManager ,
ProjectManager ,
QaEngineer ,
)
2023-11-20 11:24:46 +08:00
from metagpt . team import Team
2023-11-29 16:22:05 +08:00
# Use in the PrepareDocuments action according to Section 2.2.3.5.1 of RFC 135.
2023-12-04 23:04:07 +08:00
CONFIG . project_path = project_path
if project_path :
inc = True
project_name = project_name or Path ( project_path ) . name
2023-11-29 16:22:05 +08:00
CONFIG . project_name = project_name
CONFIG . inc = inc
CONFIG . reqa_file = reqa_file
2023-12-04 23:04:07 +08:00
CONFIG . max_auto_summarize_code = max_auto_summarize_code
2023-11-29 16:22:05 +08:00
2023-11-20 11:24:46 +08:00
company = Team ( )
company . hire (
[
ProductManager ( ) ,
Architect ( ) ,
ProjectManager ( ) ,
]
)
if implement or code_review :
company . hire ( [ Engineer ( n_borg = 5 , use_code_review = code_review ) ] )
if run_tests :
company . hire ( [ QaEngineer ( ) ] )
company . invest ( investment )
2023-11-29 16:22:05 +08:00
company . run_project ( idea )
2023-11-20 11:24:46 +08:00
asyncio . run ( company . run ( n_round = n_round ) )
if __name__ == " __main__ " :
2023-11-29 16:22:05 +08:00
app ( )