mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-04-27 09:46:24 +02:00
Modify prompt in write_code_guide_an.py and get_codes function in write_code.py
This commit is contained in:
parent
81934e2202
commit
850c3ec094
2 changed files with 12 additions and 14 deletions
|
|
@ -163,14 +163,13 @@ class WriteCode(Action):
|
|||
code_filenames = m.get("Task list", [])
|
||||
codes = []
|
||||
src_file_repo = CONFIG.git_repo.new_file_repository(relative_path=CONFIG.src_workspace)
|
||||
old_file_repo = CONFIG.git_repo.new_file_repository(relative_path=CONFIG.old_workspace)
|
||||
|
||||
src_files = src_file_repo.all_files
|
||||
old_files = old_file_repo.all_files
|
||||
union_files_list = list(set(src_files) | set(old_files))
|
||||
|
||||
if mode == "guide":
|
||||
# 从两个repo中取code,并结合在一起
|
||||
src_files = src_file_repo.all_files
|
||||
old_file_repo = CONFIG.git_repo.new_file_repository(relative_path=CONFIG.old_workspace)
|
||||
old_files = old_file_repo.all_files
|
||||
union_files_list = list(set(src_files) | set(old_files))
|
||||
for filename in union_files_list:
|
||||
if filename == exclude:
|
||||
if filename in old_files:
|
||||
|
|
@ -181,10 +180,11 @@ class WriteCode(Action):
|
|||
else:
|
||||
doc = await src_file_repo.get(filename=filename) # 使用先前生成的代码
|
||||
if not doc:
|
||||
if filename in old_files:
|
||||
doc = await old_file_repo.get(filename=filename) # 使用原始代码
|
||||
else:
|
||||
continue
|
||||
# if filename in old_files:
|
||||
# doc = await old_file_repo.get(filename=filename) # 使用原始代码
|
||||
# else:
|
||||
# continue
|
||||
continue # 跳过
|
||||
codes.append(f"----- {filename}\n```{doc.content}```")
|
||||
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -18,8 +18,7 @@ from metagpt.schema import Document
|
|||
GUIDELINE = ActionNode(
|
||||
key="Code Guideline",
|
||||
expected_type=list[str],
|
||||
instruction="You are a professional software engineer, and your main task is to "
|
||||
"proposing incremental development plans and code guidance",
|
||||
instruction="crafting comprehensive incremental development plans and providing detailed code guidance",
|
||||
example=[
|
||||
"`calculator.py` should be extended to include methods for subtraction, multiplication, and division. Error handling should be implemented for division to prevent division by zero.",
|
||||
"New endpoints for subtraction, multiplication, and division should be added to `main.py`.",
|
||||
|
|
@ -83,7 +82,7 @@ if __name__ == '__main__':
|
|||
|
||||
CODE_GUIDE_CONTEXT = """
|
||||
### NOTICE
|
||||
Role: You are a professional software engineer, and your main task is to write code Guideline and code craft with triple quote, based on the following attentions and context. Output format carefully referenced "Format example".
|
||||
Role: You are a professional software engineer, and your main task is to craft comprehensive incremental development plans and provide detailed code guidance with triple quote, based on the following attentions and context. Output format carefully referenced "Format example".
|
||||
1. Determine the scope of responsibilities of each file and what classes and methods need to be implemented.
|
||||
2. Import all referenced classes.
|
||||
3. Implement all methods.
|
||||
|
|
@ -159,8 +158,7 @@ ATTENTION: Use '##' to SPLIT SECTIONS, not '#'. Output format carefully referenc
|
|||
5. CAREFULLY CHECK THAT YOU DONT MISS ANY NECESSARY CLASS/FUNCTION IN THIS FILE.
|
||||
6. Before using a external variable/module, make sure you import it first.
|
||||
7. Write out EVERY CODE DETAIL, DON'T LEAVE TODO.
|
||||
8. When Task List code files do not include Legacy Code files, you need to seamlessly merge and adjust Legacy Code files that do not appear in the Task List into the code files of the task list being written based on the guideline.
|
||||
9. Attention: Make modifications and additions to the legacy code in accordance with the provided guidelines and API. Ensure that the complete code is implemented without any omissions.
|
||||
8. Attention: Make modifications and additions to the legacy code in accordance with the provided guidelines and API. Ensure that the complete code is implemented without any omissions.
|
||||
"""
|
||||
|
||||
CODE_GUIDE_CONTEXT_EXAMPLE = """
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue