From 5aab97554c960c9cd4165e48ae0922923d66cccd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E4=BC=9F=E9=9F=AC?= Date: Thu, 5 Sep 2024 19:42:16 +0800 Subject: [PATCH] update engineer prompt --- metagpt/prompts/di/engineer2.py | 9 ++++--- metagpt/strategy/experience_retriever.py | 31 +----------------------- metagpt/tools/libs/editor.py | 4 +-- 3 files changed, 9 insertions(+), 35 deletions(-) diff --git a/metagpt/prompts/di/engineer2.py b/metagpt/prompts/di/engineer2.py index 113551212..afe904c92 100644 --- a/metagpt/prompts/di/engineer2.py +++ b/metagpt/prompts/di/engineer2.py @@ -6,7 +6,7 @@ You are an autonomous programmer The special interface consists of a file editor that shows you 100 lines of a file at a time. You can use terminal commands (e.g., cat, ls, cd) by calling Terminal.run_command. -Do Not run the code. + You should carefully observe the behavior and results of the previous action, and avoid triggering repeated errors. @@ -75,10 +75,13 @@ Note: 18. Use Engineer2.write_new_code to create or modify a file. Write only one code file each time. If you only need to code one file, provide all the necessary information in one response. 19. When the requirement is simple, you don't need to create a plan, just do it right away. 20. If the code exists, use the Editor tool's open and edit commands to modify it. Since it is not a new code, do not use write_new_code. -21. Forbidden to run code in the terminal. + 22. When using the editor, pay attention to the editor's current directory. When you use editor tools, the paths must be either absolute or relative to the editor's current directory. """ - +""" +21. Forbidden to run code in the terminal. +Do Not run the code. +""" CURRENT_STATE = """ The current editor state is: (Editor current directory: {editor_current_directory}) diff --git a/metagpt/strategy/experience_retriever.py b/metagpt/strategy/experience_retriever.py index 4c649f0d2..416e16279 100644 --- a/metagpt/strategy/experience_retriever.py +++ b/metagpt/strategy/experience_retriever.py @@ -1007,24 +1007,8 @@ Since Editor.insert_content_at_line can only be used once per response, this tim In the next turn, I will try to add another code snippet ## example 11 -``` -#### Save the changes and commit them to the remote repository. -##### Push the changes from the local repository to the remote repository. -Thought: All changes have been saved, let's push the code to the remote repository. -```json -[ - { - "command_name": "Terminal.run_command", - "args": { - "cmd": "git push origin test-fix" - } - } -] -``` - - -##### Create a pull request (Optional): Merge the changes from the new branch into the master branch. +Create a pull request (Optional): Merge the changes from the new branch into the master branch. Thought: Now that the changes have been pushed to the remote repository, due to the user's requirement, let's create a pull request to merge the changes into the master branch. ```json [ @@ -1044,19 +1028,6 @@ Thought: Now that the changes have been pushed to the remote repository, due to ``` """ -""" -## example 11 -I have finished all the tasks, so I will use Plan.finish_current_task and then follow the command ‘end’ to stop. -```json -[ - { - "command_name": "end", - "args": { - } - } -] -``` -""" WEB_SCRAPING_EXAMPLE = """ ## action 1 User Requirement: Scrap and list the restaurant names of first page by searching for the keyword `beef` on the website https://www.yelp.com/. diff --git a/metagpt/tools/libs/editor.py b/metagpt/tools/libs/editor.py index 46c9d3315..d35e97d07 100644 --- a/metagpt/tools/libs/editor.py +++ b/metagpt/tools/libs/editor.py @@ -747,13 +747,13 @@ class Editor(BaseModel): self.current_line = max(1, len(lines)) # end of original file else: self.current_line = start or n_total_lines or 1 - cuccess_edit_info = SUCCESS_EDITE_INFO.format( + success_edit_info = SUCCESS_EDITE_INFO.format( file_name=file_name.resolve(), n_total_lines=n_total_lines, window_after_applied=self._print_window(file_name, self.current_line, self.window), line_number=self.current_line, ).strip() - return cuccess_edit_info + return success_edit_info def edit_file_by_replace(self, file_name: str, to_replace: str, new_content: str) -> str: """Edit a file. This will search for `to_replace` in the given file and replace it with `new_content`.