Skip to content

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

use context instead of FileRepo... done main process.

geekan57581bbb36d8
diff --git a/metagpt/actions/write_code.py b/metagpt/actions/write_code.py
index 4089a8cfd..0c34bd670 100644
--- a/metagpt/actions/write_code.py
+++ b/metagpt/actions/write_code.py
@@ -137,11 +137,13 @@ class WriteCode(Action):
coding_context.code_doc.content = code
return coding_context
- async def get_codes(self, task_doc, exclude, git_repo, src_workspace) -> str:
+ @staticmethod
+ async def get_codes(task_doc, exclude, git_repo, src_workspace) -> str:
if not task_doc:
return ""
if not task_doc.content:
- task_doc.content = self.file_repo.get_file(filename=task_doc.filename, relative_path=TASK_FILE_REPO)
+ file_repo = git_repo.new_file_repository()
+ task_doc.content = file_repo.get_file(filename=task_doc.filename, relative_path=TASK_FILE_REPO)
m = json.loads(task_doc.content)
code_filenames = m.get("Task list", [])
codes = []
diff --git a/metagpt/roles/engineer.py b/metagpt/roles/engineer.py
index 51c831b91..98744383c 100644
--- a/metagpt/roles/engineer.py
+++ b/metagpt/roles/engineer.py
@@ -109,7 +109,7 @@ class Engineer(Role):
coding_context = await todo.run()
# Code review
if review:
- action = WriteCodeReview(context=coding_context, llm=self.llm)
+ action = WriteCodeReview(context=coding_context, g_context=self.context, llm=self.llm)
self._init_action_system_message(action)
coding_context = await action.run()
await src_file_repo.save(
diff --git a/metagpt/roles/qa_engineer.py b/metagpt/roles/qa_engineer.py
index 564b89bdc..7da0af072 100644
--- a/metagpt/roles/qa_engineer.py
+++ b/metagpt/roles/qa_engineer.py
@@ -112,7 +112,7 @@ class QaEngineer(Role):
return
run_code_context.code = src_doc.content
run_code_context.test_code = test_doc.content
- result = await RunCode(context=run_code_context, llm=self.llm).run()
+ result = await RunCode(context=run_code_context, g_context=self.context, llm=self.llm).run()
run_code_context.output_filename = run_code_context.test_filename + ".json"
await self.context.git_repo.new_file_repository(TEST_OUTPUTS_FILE_REPO).save(
filename=run_code_context.output_filename,