Skip to content

🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming

update: 提示词 ex 优化

your-username8e984db9ff8b
diff --cc metagpt/prompts/di/swe_agent.py
index c4db3b785,78a8ce846..51fc1621e
--- a/metagpt/prompts/di/swe_agent.py
+++ b/metagpt/prompts/di/swe_agent.py
@@@ -89,53 -78,26 +89,53 @@@ Thought: We have located both the `open
->
### Fix the Bug(Require): Fix the bug in the code by editing the relevant function, class or code snippet.
- Thought: Let's edit the apow function to include the Pow case in the isinstance check.
-[{{
++Thought: Now that I've found the bug, let's fix it by edit.
+{{
"command_name": "Bash.run",
"args": {{
- "cmd": "edit 93:95 <<EOF\n usage = None\n collected_messages = []\n async for chunk in response:\n if chunk.usage is not None:\n usage = CompletionUsage(**chunk.usage)\n chunk_message = chunk.choices[0].delta.content or '' if chunk.choices else '' # extract the message\n finish_reason = (\n chunk.choices[0].finish_reason if chunk.choices and hasattr(chunk.choices[0], 'finish_reason') else None\n )\n log_llm_stream(chunk_message)\nEOF"
- "cmd": "edit 10:20 <<EOF\n regex = r'\A[\w.@+-]+\Z'\n message = _( \n 'Enter a valid username. This value may contain only English letters, ' \n 'numbers, and @/./+/-/_ characters.'\n )\n flags = re.ASCII\n\n@deconstructible\nclass UnicodeUsernameValidator(validators.RegexValidator):\n regex = r'\A[\w.@+-]+\Z'\nEOF"
++ "cmd": "edit 93:95 <<EOF\n usage = None\n collected_messages = []\n async for chunk in response:\n if chunk.usage is not None:\n usage = CompletionUsage(**chunk.usage)\n chunk_message = chunk.choices[0].delta.content or '' if chunk.choices else '' # extract the message\n finish_reason = (\n chunk.choices[0].finish_reason if chunk.choices and hasattr(chunk.choices[0], 'finish_reason') else None\n )\n log_llm_stream(chunk_message)\nEOF"
}}
-}}]
+}}
+->
+Thought: Due to a syntax error related to an undefined name 'Image', we need to address this issue even though it is not directly related to our work. Let's try importing the package to fix it.
+{{
+ "command_name": "Bash.run",
+ "args": {{
- "cmd": "edit 14:14 <<EOF\nfrom PIL.Image import Image\nEOF"
++ "cmd": "edit 14:14 <<EOF\nfrom PIL.Image import Image\nEOF"
+ }}
+}}
->
-### Push the Changes: Pushes changes from a local Git repository to its remote counterpart.
-[{{
+### Save the Changes (Required): After all changes have been made, save them to the repository.
+> You must choose one of the following two methods.
+
+#### Just save the changes locally, it only need one action.
+Thought: The bug has been fixed. Let's submit the changes.
+{{
+ "command_name": "Bash.run",
+ "args": {{
+ "cmd": "submit"
+ }}
+}}
+->
+
+#### 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.
+{{
"command_name": "git_push",
"args": {{
- "local_path": "/workspace/django__django_3.0/django/contrib/auth",
+ "local_path": "/workspace/MetaGPT",
"app_name": "github",
- "comments": "Fix: produced TypeError: openai.types.completion_usage.CompletionUsage() argument after ** must be a mapping, not NoneType",
+ "comments": "Fix Issue #1275: produced TypeError: openai.types.completion_usage.CompletionUsage() argument after ** must be a mapping, not NoneType"",
"new_branch": "test-fix"
}}
-}}]
+}}
+->
-### Create pull request
+##### 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.
[{{
"command_name": "git_create_pull",
"args": {{
@@@ -244,5 -199,6 +244,5 @@@ The current bash state is
(Open file: {{open_file}})
(Current directory: {{working_dir}})
- Avoid repeating the same command. Instead, please think about the current situation and provide the next bash command to execute in JSON format"
+ Avoid repeating the same command. Instead, please think about the current situation and provide the next bash command to execute in JSON format:"
-
"""
diff --cc metagpt/tools/libs/git.py
index 676e9125a,4606b5815..a2fd87a92
--- a/metagpt/tools/libs/git.py
+++ b/metagpt/tools/libs/git.py
@@@ -9,10 -9,9 +9,9 @@@ from github.Issue import Issu
from github.PullRequest import PullRequest
from metagpt.tools.tool_registry import register_tool
- from metagpt.utils.git_repository import GitBranch
-@register_tool(tags=["software development", "git", "Commit the changes and push to remote git repository."])
+@register_tool(tags=["software development", "git", "Push to remote git repository."])
async def git_push(
local_path: Union[str, Path],
app_name: str,
diff --cc metagpt/tools/libs/terminal.py
index c23cc1a7f,b54adf0d4..e93e4575f
--- a/metagpt/tools/libs/terminal.py
+++ b/metagpt/tools/libs/terminal.py
@@@ -28,7 -28,7 +28,7 @@@ class Terminal
async def _start_process(self):
# Start a persistent shell process
self.process = await asyncio.create_subprocess_exec(
- *self.shell_command, stdin=PIPE, stdout=PIPE, stderr=PIPE, executable="bash"
- *self.shell_command, stdin=PIPE, stdout=PIPE, stderr=STDOUT, executable="/bin/bash"
++ *self.shell_command, stdin=PIPE, stdout=PIPE, stderr=STDOUT, executable="bash"
)
await self._check_state()