diff --git a/metagpt/actions/write_code_guideline_an.py b/metagpt/actions/write_code_guideline_an.py index 0677f6edc..43645e80c 100644 --- a/metagpt/actions/write_code_guideline_an.py +++ b/metagpt/actions/write_code_guideline_an.py @@ -425,7 +425,7 @@ class WriteCodeGuideline(Action): async def main(): write_code_guideline = WriteCodeGuideline() node = await write_code_guideline.run(CODE_GUIDELINE_CONTEXT_EXAMPLE) - guideline = node.instruct_content.json(ensure_ascii=False) + guideline = node.instruct_content.model_dump_json() print(guideline) diff --git a/metagpt/actions/write_prd_an.py b/metagpt/actions/write_prd_an.py index e2fbb2599..91c1b2837 100644 --- a/metagpt/actions/write_prd_an.py +++ b/metagpt/actions/write_prd_an.py @@ -214,7 +214,7 @@ Based on New Requirements, output a New PRD that seamlessly integrates both the """ REFINE_PRD_TEMPLATE = """ -### New Project Name +### Project Name {project_name} ### New Requirements diff --git a/metagpt/roles/engineer.py b/metagpt/roles/engineer.py index d7a0312be..d4947a8f8 100644 --- a/metagpt/roles/engineer.py +++ b/metagpt/roles/engineer.py @@ -346,7 +346,7 @@ class Engineer(Role): context = CODE_GUIDELINE_CONTEXT.format(requirement=requirement, tasks=tasks, design=design, code=old_codes) node = await WriteCodeGuideline().run(context=context) - guideline = node.instruct_content.json(ensure_ascii=False) + guideline = node.instruct_content.model_dump_json() return guideline @staticmethod diff --git a/metagpt/utils/git_repository.py b/metagpt/utils/git_repository.py index b42111620..e9855df05 100644 --- a/metagpt/utils/git_repository.py +++ b/metagpt/utils/git_repository.py @@ -189,7 +189,7 @@ class GitRepository: return self._dependency def rename_root(self, new_dir_name): - """Rename/Copy the root directory of the Git repository. + """Rename the root directory of the Git repository. :param new_dir_name: The new name for the root directory. """ @@ -200,15 +200,10 @@ class GitRepository: logger.info(f"Delete directory {str(new_path)}") shutil.rmtree(new_path) try: - shutil.copytree(src=str(self.workdir), dst=str(new_path)) + shutil.move(src=str(self.workdir), dst=str(new_path)) except Exception as e: - logger.warning(f"Copy {str(self.workdir)} to {str(new_path)} error: {e}") - logger.info(f"Copy directory {str(self.workdir)} to {str(new_path)}") - # try: - # shutil.move(src=str(self.workdir), dst=str(new_path)) - # except Exception as e: - # logger.warning(f"Move {str(self.workdir)} to {str(new_path)} error: {e}") - # logger.info(f"Rename directory {str(self.workdir)} to {str(new_path)}") + logger.warning(f"Move {str(self.workdir)} to {str(new_path)} error: {e}") + logger.info(f"Rename directory {str(self.workdir)} to {str(new_path)}") self._repository = Repo(new_path) self._gitignore_rules = parse_gitignore(full_path=str(new_path / ".gitignore")) diff --git a/tests/metagpt/actions/test_design_api_an.py b/tests/metagpt/actions/test_design_api_an.py index 305c708c0..5b016ecce 100644 --- a/tests/metagpt/actions/test_design_api_an.py +++ b/tests/metagpt/actions/test_design_api_an.py @@ -8,7 +8,7 @@ import pytest from metagpt.actions.design_api_an import REFINED_DESIGN_NODES -from metagpt.provider import OpenAIGPTAPI +from metagpt.llm import LLM CONTEXT = """ ### Legacy Content @@ -94,11 +94,11 @@ CONTEXT = """ @pytest.fixture() def llm(): - return OpenAIGPTAPI() + return LLM() @pytest.mark.asyncio async def test_write_design_an(): node = await REFINED_DESIGN_NODES.fill(CONTEXT, llm) assert node.instruct_content - assert "Refined Data Structures and Interfaces" in node.instruct_content.json(ensure_ascii=False) + assert "Refined Data Structures and Interfaces" in node.instruct_content.model_dump_json() diff --git a/tests/metagpt/actions/test_project_management_an.py b/tests/metagpt/actions/test_project_management_an.py index 9ad4360cf..e0c1381ec 100644 --- a/tests/metagpt/actions/test_project_management_an.py +++ b/tests/metagpt/actions/test_project_management_an.py @@ -8,7 +8,7 @@ import pytest from metagpt.actions.project_management_an import REFINED_PM_NODES -from metagpt.provider import OpenAIGPTAPI +from metagpt.llm import LLM CONTEXT = """ ### Legacy Content @@ -134,11 +134,11 @@ CONTEXT = """ @pytest.fixture() def llm(): - return OpenAIGPTAPI() + return LLM() @pytest.mark.asyncio async def test_project_management_an(llm): node = await REFINED_PM_NODES.fill(CONTEXT, llm) assert node.instruct_content - assert "Refined Logic Analysis" in node.instruct_content.json(ensure_ascii=False) + assert "Refined Logic Analysis" in node.instruct_content.model_dump_json() diff --git a/tests/metagpt/actions/test_write_code_guideline_an.py b/tests/metagpt/actions/test_write_code_guideline_an.py index d740a6bd8..f8a1ae626 100644 --- a/tests/metagpt/actions/test_write_code_guideline_an.py +++ b/tests/metagpt/actions/test_write_code_guideline_an.py @@ -200,7 +200,7 @@ async def test_write_code_guideline_an(): ) node = await write_code_guideline.run(context=context) assert node.instruct_content - assert "Incremental Change" in node.instruct_content.json(ensure_ascii=False) + assert "Incremental Change" in node.instruct_content.model_dump_json() @pytest.mark.asyncio diff --git a/tests/metagpt/actions/test_write_prd_an.py b/tests/metagpt/actions/test_write_prd_an.py index d520eb863..79cd913cd 100644 --- a/tests/metagpt/actions/test_write_prd_an.py +++ b/tests/metagpt/actions/test_write_prd_an.py @@ -8,7 +8,7 @@ import pytest from metagpt.actions.write_prd_an import REFINE_PRD_NODE -from metagpt.provider import OpenAIGPTAPI +from metagpt.llm import LLM CONTEXT = """ ### New Project Name @@ -78,11 +78,11 @@ Please change the game's score target from 2048 to 4096, and change the interfac @pytest.fixture() def llm(): - return OpenAIGPTAPI() + return LLM() @pytest.mark.asyncio async def test_write_prd_an(llm): node = await REFINE_PRD_NODE.fill(CONTEXT, llm) assert node.instruct_content - assert "Refined Requirement Pool" in node.instruct_content.json(ensure_ascii=False) + assert "Refined Requirement Pool" in node.instruct_content.model_dump_json() diff --git a/tests/metagpt/test_increment.py b/tests/metagpt/test_increment.py index a6d5e0821..25769ff6a 100644 --- a/tests/metagpt/test_increment.py +++ b/tests/metagpt/test_increment.py @@ -14,140 +14,120 @@ from metagpt.startup import app runner = CliRunner() -def test_refine_simple_calculator(): +def test_refined_simple_calculator(): args = [ "Add subtraction, multiplication and division operations to the calculator. The current calculator can only perform basic addition operations, and it is necessary to introduce subtraction, multiplication, division operation into the calculator", "--inc", "--project-path", "data/simple_add_calculator", - "--project-name", - "simple_calculator", ] result = runner.invoke(app, args) logger.info(result) logger.info(result.output) -def test_refine_number_guessing_game(): +def test_refined_number_guessing_game(): args = [ - "Adding graphical interface functionality to enhance the user experience in the number-guessing game. The existing number-guessing game currently relies on command-line input for numbers. The goal is to introduce a graphical interface to improve the game's usability and visual appeal" + "Adding graphical interface functionality to enhance the user experience in the number-guessing game. The existing number-guessing game currently relies on command-line input for numbers. The goal is to introduce a graphical interface to improve the game's usability and visual appeal", "--inc", "--project-path", "data/number_guessing_game", - "--project-name", - "number_guessing_game", ] result = runner.invoke(app, args) logger.info(result) logger.info(result.output) -def test_refine_dice_simulator_1(): +def test_refined_dice_simulator_1(): args = [ - "Add functionality to view the history of scores. The original dice rolling game could only display the current game result, but the new requirement allows players to view the history of scores" + "Add functionality to view the history of scores. The original dice rolling game could only display the current game result, but the new requirement allows players to view the history of scores", "--inc", "--project-path", "data/dice_simulator_new", - "--project-name", - "dice_simulator_1", ] result = runner.invoke(app, args) logger.info(result) logger.info(result.output) -def test_refine_dice_simulator_2(): +def test_refined_dice_simulator_2(): args = [ "Add functionality to view the history of scores and perform statistical analysis on them. The original dice rolling game could only display the current game result, but the new requirement allows players to view the history of scores and display the statistical analysis results of the current score", "--inc", "--project-path", "data/dice_simulator_new", - "--project-name", - "dice_simulator_2", ] result = runner.invoke(app, args) logger.info(result) logger.info(result.output) -def test_refine_dice_simulator_3(): +def test_refined_dice_simulator_3(): args = [ - "Add functionality to set the number of sides on a die; Add functionality to view the history of scores; Add functionality to perform statistical analysis on all scores. The original dice rolling game could roll the dice multiple times and only display the current game result. But the new requirement add function that players to customize the number of sides of the dice and to view the history of scores and display the statistical analysis" + "Add functionality to set the number of sides on a die; Add functionality to view the history of scores; Add functionality to perform statistical analysis on all scores. The original dice rolling game could roll the dice multiple times and only display the current game result. But the new requirement add function that players to customize the number of sides of the dice and to view the history of scores and display the statistical analysis", "--inc", "--project-path", "data/dice_simulator_new", - "--project-name", - "dice_simulator_3", ] result = runner.invoke(app, args) logger.info(result) logger.info(result.output) -def test_refine_pygame_2048_1(): +def test_refined_pygame_2048_1(): args = [ - "Changed score target for 2048 game from 2048 to 4096. Please change the game's score target from 2048 to 4096, and change the interface size from 4*4 to 8*8" + "Changed score target for 2048 game from 2048 to 4096. Please change the game's score target from 2048 to 4096, and change the interface size from 4*4 to 8*8", "--inc", "--project-path", "data/pygame_2048", - "--project-name", - "pygame_2048_1", ] result = runner.invoke(app, args) logger.info(result) logger.info(result.output) -def test_refine_pygame_2048_2(): +def test_refined_pygame_2048_2(): args = [ - "Display the history score of the player in the 2048 game. Add a record board that can display players' historical score records so that players can trace their scores" + "Display the history score of the player in the 2048 game. Add a record board that can display players' historical score records so that players can trace their scores", "--inc", "--project-path", "data/pygame_2048", - "--project-name", - "pygame_2048_2", ] result = runner.invoke(app, args) logger.info(result) logger.info(result.output) -def test_refine_pygame_2048_3(): +def test_refined_pygame_2048_3(): args = [ - "Add limited time mode. The original game only had a default classic mode. The improved game should be able to support limited-time mode, allowing users to choose classic mode or limited-time mode from the available options before starting the game." + "Add limited time mode. The original game only had a default classic mode. The improved game should be able to support limited-time mode, allowing users to choose classic mode or limited-time mode from the available options before starting the game.", "--inc", "--project-path", "data/pygame_2048", - "--project-name", - "pygame_2048_3", ] result = runner.invoke(app, args) logger.info(result) logger.info(result.output) -def test_refine_word_cloud_1(): +def test_refined_word_cloud_1(): args = [ - "Add a feature to remove deprecated words from the word cloud. The current word cloud generator does not support removing deprecated words. Now, The word cloud generator should support removing deprecated words. Customize deactivated words to exclude them from word cloud. Let users see all the words in the text file, and allow users to select the words they want to remove." + "Add a feature to remove deprecated words from the word cloud. The current word cloud generator does not support removing deprecated words. Now, The word cloud generator should support removing deprecated words. Customize deactivated words to exclude them from word cloud. Let users see all the words in the text file, and allow users to select the words they want to remove.", "--inc", "--project-path", "data/word_cloud", - "--project-name", - "word_cloud_1", ] result = runner.invoke(app, args) logger.info(result) logger.info(result.output) -def test_refine_word_cloud_2(): +def test_refined_word_cloud_2(): args = [ - "Add a feature to customize the resolution of the word cloud.The new version allows users to customize the size and resolution of the generated word cloud after uploading a text file, and then generate the word cloud." + "Add a feature to customize the resolution of the word cloud.The new version allows users to customize the size and resolution of the generated word cloud after uploading a text file, and then generate the word cloud.", "--inc", "--project-path", "data/word_cloud", - "--project-name", - "word_cloud_2", ] result = runner.invoke(app, args) logger.info(result)