diff --git a/metagpt/roles/di/engineer2.py b/metagpt/roles/di/engineer2.py index 5933e9eff..6313c5b33 100644 --- a/metagpt/roles/di/engineer2.py +++ b/metagpt/roles/di/engineer2.py @@ -71,6 +71,7 @@ class Engineer2(RoleZero): def _update_tool_execution(self): # validate = ValidateAndRewriteCode() cr = CodeReview() + image_getter = ImageGetter() self.exclusive_tool_commands.append("Engineer2.write_new_code") if self.run_eval is True: # Evalute tool map @@ -78,6 +79,7 @@ class Engineer2(RoleZero): { "git_create_pull": git_create_pull, "Engineer2.write_new_code": self.write_new_code, + "ImageGetter.get_image": image_getter.get_image, "CodeReview.review": cr.review, "CodeReview.fix": cr.fix, "Terminal.run_command": self._eval_terminal_run, @@ -87,7 +89,6 @@ class Engineer2(RoleZero): ) else: # Default tool map - image_getter = ImageGetter() self.tool_execution_map.update( { "git_create_pull": git_create_pull, diff --git a/tests/metagpt/roles/di/run_engineer2.py b/tests/metagpt/roles/di/run_engineer2.py index e5ae74485..a5ceec93e 100644 --- a/tests/metagpt/roles/di/run_engineer2.py +++ b/tests/metagpt/roles/di/run_engineer2.py @@ -1,5 +1,9 @@ import asyncio +import sys +import uuid +from pathlib import Path +from metagpt.logs import logger from metagpt.roles.di.engineer2 import Engineer2 DESIGN_DOC_2048 = '{"Implementation approach":"We will use the Pygame library to implement the 2048 game logic and user interface. Pygame is a set of Python modules designed for writing video games, which will help us create a responsive and visually appealing UI. For the mobile responsiveness, we will ensure that the game scales appropriately on different screen sizes. We will also use the Pygame GUI library to create buttons for restarting the game and choosing difficulty levels.","File list":["main.py","game.py","ui.py"],"Data structures and interfaces":"\\nclassDiagram\\n class Game {\\n -grid: list[list[int]]\\n -score: int\\n +__init__()\\n +move(direction: str) bool\\n +merge() bool\\n +spawn_tile() None\\n +is_game_over() bool\\n +reset() None\\n }\\n class UI {\\n -game: Game\\n +__init__(game: Game)\\n +draw_grid() None\\n +draw_score() None\\n +draw_buttons() None\\n +handle_input() None\\n }\\n class Main {\\n -ui: UI\\n +main() None\\n }\\n Main --> UI\\n UI --> Game\\n","Program call flow":"\\nsequenceDiagram\\n participant M as Main\\n participant U as UI\\n participant G as Game\\n M->>U: __init__(game)\\n U->>G: __init__()\\n M->>U: draw_grid()\\n U->>G: move(direction)\\n G-->>U: return bool\\n U->>G: merge()\\n G-->>U: return bool\\n U->>G: spawn_tile()\\n G-->>U: return None\\n U->>G: is_game_over()\\n G-->>U: return bool\\n U->>G: reset()\\n G-->>U: return None\\n M->>U: draw_score()\\n M->>U: draw_buttons()\\n M->>U: handle_input()\\n","Anything UNCLEAR":"Clarification needed on the specific design elements for the UI to ensure it meets the \'beautiful\' requirement. Additionally, we need to confirm the exact difficulty levels and how they should affect the game mechanics."}' @@ -99,6 +103,65 @@ Then correct any issues you find. You can review all code in one time, and solve CASUAL_CHAT = """what's your name?""" +# increment development +INC_DEVELOPMENT_CASE1 = [ + "Complete the Snake game with the root directory at '/home/mgx/mgx/MetaGPT/workspace/snake_game'", + "Use the up button to control the snake to move down, the left button to move right, and so on", + "Place the restart/start button at the top", + "Add a pause button", + "Display the score and leaderboard in real-time on the page", +] + +INC_DEVELOPMENT_CASE2 = [ + "Develop a Snake game using Python in the '/home/mgx/mgx/MetaGPT/workspace/snake_game_py' folder", + "Change the title to 'Special Snake'", + "Use the up button to control the snake to move down, the left button to move right, and so on", + "Add a pause button", + "Display the score and leaderboard in real-time on the page", + "Design a more attractive style for the leaderboard", +] + +INC_DEVELOPMENT_CASE3 = [ + "Complete the 2048 game with the root directory at '/home/mgx/mgx/MetaGPT/workspace/2048_game'", + "Place the start button at the top", + "Display the score and leaderboard in real-time on the page", + "Design a more attractive style for the leaderboard", + "Add a restart button", +] + +INC_DEVELOPMENT_CASE4 = [ + "Develop a 2048 game using Python in the '/home/mgx/mgx/MetaGPT/workspace/2048_game_py' folder", + "Display the score and leaderboard in real-time on the page", + "Add a restart button", +] +INC_DEVELOPMENT_CASE5 = [ + "Root path is '/home/mgx/mgx/MetaGPT/workspace/to_list' Create a website widget for TODO list management. Users should be able to add, mark as complete, and delete tasks. Include features like prioritization, due dates, and categories. Make it visually appealing, responsive, and user-friendly. Use HTML, CSS, and JavaScript. Consider additional features like notifications or task export. Keep it simple and enjoyable for users.dont use vue or react.dont use third party library, use localstorage to save data.", + "Add a `clean all` buttonn", +] +INC_DEVELOPMENT_CASE6 = [ + '使用原生HTML开发一个塔罗牌角色介绍网站\n1. 主题是塔罗牌占卜的网站\n2. 超前的网页布局\n3. 页面需要时响应式的\n4. 页面需要美观大气 root path "”/home/mgx/mgx/MetaGPT/workspace/taro"', + "扩充更多的角色,添加3个自己想出来的角色", + "让每一个角色的描述更加清楚", + "将中文内容全部替换为英文包括js里面的内容", +] + + +async def increment_development(): + engineer2 = Engineer2(run_eval=True) + example = INC_DEVELOPMENT_CASE6 + logger.remove() + logger.add(sys.stderr, level="INFO") + logger.add(Path("logs") / f"{str(uuid.uuid4())[-12:]}.log", level="DEBUG") + logger.info("user requirement:\n" + "\n".join(example)) + try: + for user_requirement in example: + logger.info(f"input:{user_requirement}") + await engineer2.run(user_requirement) + except Exception as e: + print(e) + + if __name__ == "__main__": - engineer2 = Engineer2() - asyncio.run(engineer2.run(GAME_REQ_2048_NO_DOC)) + asyncio.run(increment_development()) + # engineer2 = Engineer2() + # asyncio.run(engineer2.run(GAME_REQ_2048_NO_DOC))