mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-06 06:12:39 +02:00
change parameter names
This commit is contained in:
parent
cc500edb37
commit
0f65ff5cb0
2 changed files with 16 additions and 10 deletions
|
|
@ -218,17 +218,21 @@ class ReviewAndRewriteCode(Action):
|
|||
name: str = "ReviewAndRewriteCode"
|
||||
|
||||
async def run(
|
||||
self, code_path: str, design_doc_input: str = "", task_doc_input: str = "", code_review_k_times: int = 2
|
||||
self,
|
||||
code_path: str,
|
||||
system_design_input: str = "",
|
||||
project_schedule_input: str = "",
|
||||
code_review_k_times: int = 2,
|
||||
) -> str:
|
||||
"""Reviews the provided code based on the accompanying design and task documentation, return the complete and correct code.
|
||||
|
||||
Read the code from `code_path`, and write the final code to `code_path`.
|
||||
If both `design_doc_input` and `task_doc_input are absent`, it will return and do nothing.
|
||||
If both `system_design_input` and `project_schedule_input are absent`, it will return and do nothing.
|
||||
|
||||
Args:
|
||||
code_path (str): The file path of the code snippet to be reviewed. This should be a string containing the path to the source code file.
|
||||
design_doc_input (str): Content or file path of the design document associated with the code. This should describe the system architecture, used in the code. It helps provide context for the review process.
|
||||
task_doc_input (str): Content or file path of the task document describing what the code is intended to accomplish. This should outline the functional requirements or objectives of the code.
|
||||
system_design_input (str): Content or file path of the design document associated with the code. This should describe the system architecture, used in the code. It helps provide context for the review process.
|
||||
project_schedule_input (str): Content or file path of the task document describing what the code is intended to accomplish. This should outline the functional requirements or objectives of the code.
|
||||
code_review_k_times (int, optional): The number of iterations for reviewing and potentially rewriting the code. Defaults to 2.
|
||||
|
||||
Returns:
|
||||
|
|
@ -238,17 +242,19 @@ class ReviewAndRewriteCode(Action):
|
|||
# Example of how to call the run method with a code snippet and documentation
|
||||
await ReviewAndRewriteCode().run(
|
||||
code_path="/tmp/game.js",
|
||||
design_doc_input="/tmp/system_design.json",
|
||||
task_doc_input="/tmp/project_task_list.json"
|
||||
system_design_input="/tmp/system_design.json",
|
||||
project_schedule_input="/tmp/project_task_list.json"
|
||||
)
|
||||
"""
|
||||
|
||||
if not design_doc_input and not task_doc_input:
|
||||
logger.info("Both design_doc_input and task_doc_input are absent, ReviewAndRewriteCode will do nothing.")
|
||||
if not system_design_input and not project_schedule_input:
|
||||
logger.info(
|
||||
"Both `system_design_input` and `project_schedule_input` are absent, ReviewAndRewriteCode will do nothing."
|
||||
)
|
||||
return
|
||||
|
||||
code, design_doc, task_doc = await asyncio.gather(
|
||||
aread(code_path), self._try_aread(design_doc_input), self._try_aread(task_doc_input)
|
||||
aread(code_path), self._try_aread(system_design_input), self._try_aread(project_schedule_input)
|
||||
)
|
||||
code_doc = self._create_code_doc(code_path=code_path, code=code)
|
||||
review_action = WriteCodeReview(i_context=CodingContext(filename=code_doc.filename))
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ EXTRA_INSTRUCTION = """
|
|||
10. When provided system design, YOU MUST FOLLOW "Data structures and interfaces". DONT CHANGE ANY DESIGN. Do not use public member functions that do not exist in your design.
|
||||
11. Write out EVERY CODE DETAIL, DON'T LEAVE TODO.
|
||||
12. To modify code in a file, read the entire file, make changes, and update the file with the complete code.
|
||||
13. Only when a system design or a project schedule is provided, at the end of the plan, add a ReviewAndRewriteCode Task for each file; for example, if there are three files, add three ReviewAndRewriteCode Tasks.
|
||||
13. If a system design or project schedule is provided, at the end of the plan, add a ReviewAndRewriteCode Task for each file; for example, if there are three files, add three ReviewAndRewriteCode Tasks.
|
||||
"""
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue