From 6fa3deef00ad06c68c77d68e60b349e0d0137ebb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=98=E6=9D=83=20=E9=A9=AC?= Date: Wed, 29 Nov 2023 20:58:41 +0800 Subject: [PATCH] feat: merge geekan:cli-etc --- metagpt/actions/write_code.py | 28 ++++++++++++---------------- metagpt/utils/git_repository.py | 1 + 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/metagpt/actions/write_code.py b/metagpt/actions/write_code.py index e373b1127..0cd41c52f 100644 --- a/metagpt/actions/write_code.py +++ b/metagpt/actions/write_code.py @@ -31,22 +31,6 @@ Role: You are a professional engineer; the main goal is to write PEP8 compliant, Language: Please use the same language as the user requirement, but the title and code should be still in English. For example, if the user speaks Chinese, the specific text of your answer should also be in Chinese. ATTENTION: Use '##' to SPLIT SECTIONS, not '#'. Output format carefully referenced "Format example". ------ -# Context -{context} ------ - -## Code: {filename} Write code with triple quoto, based on the following list and context. -1. Do your best to implement THIS ONLY ONE FILE. ONLY USE EXISTING API. IF NO API, IMPLEMENT IT. -2. Requirement: Based on the context, implement one following code file, note to return only in code form, your code will be part of the entire project, so please implement complete, reliable, reusable code snippets -3. Set default value: If there is any setting, ALWAYS SET A DEFAULT VALUE, ALWAYS USE STRONG TYPE AND EXPLICIT VARIABLE. -4. Follow design: YOU MUST FOLLOW "Data structures and interfaces". DONT CHANGE ANY DESIGN. -5. Think before writing: What should be implemented and provided in this document? -6. CAREFULLY CHECK THAT YOU DONT MISS ANY NECESSARY CLASS/FUNCTION IN THIS FILE. -7. Do not use public member functions that do not exist in your design. -8. Before using a variable, make sure you reference it first -9. Write out EVERY DETAIL, DON'T LEAVE TODO. - ----- # Design ```json @@ -68,6 +52,18 @@ ATTENTION: Use '##' to SPLIT SECTIONS, not '#'. Output format carefully referenc {logs} ``` ----- + +## Code: {filename} Write code with triple quoto, based on the following list and context. +1. Do your best to implement THIS ONLY ONE FILE. ONLY USE EXISTING API. IF NO API, IMPLEMENT IT. +2. Requirement: Based on the context, implement one following code file, note to return only in code form, your code will be part of the entire project, so please implement complete, reliable, reusable code snippets +3. Set default value: If there is any setting, ALWAYS SET A DEFAULT VALUE, ALWAYS USE STRONG TYPE AND EXPLICIT VARIABLE. +4. Follow design: YOU MUST FOLLOW "Data structures and interfaces". DONT CHANGE ANY DESIGN. +5. Think before writing: What should be implemented and provided in this document? +6. CAREFULLY CHECK THAT YOU DONT MISS ANY NECESSARY CLASS/FUNCTION IN THIS FILE. +7. Do not use public member functions that do not exist in your design. +8. Before using a variable, make sure you reference it first +9. Write out EVERY DETAIL, DON'T LEAVE TODO. + ## Format example ----- ## Code: {filename} diff --git a/metagpt/utils/git_repository.py b/metagpt/utils/git_repository.py index b1cfe1ed2..7c9ec645f 100644 --- a/metagpt/utils/git_repository.py +++ b/metagpt/utils/git_repository.py @@ -59,6 +59,7 @@ class GitRepository: :param local_path: The local path to the Git repository. :param auto_init: If True, automatically initializes a new Git repository if the provided path is not a Git repository. """ + local_path = Path(local_path) if self.is_git_dir(local_path): self._repository = Repo(local_path) return