🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
refine code
geekan00a212b52b69
diff --git a/metagpt/context.py b/metagpt/context.pyindex 0686aedc3..4badafcc4 100644--- a/metagpt/context.py+++ b/metagpt/context.py@@ -165,6 +165,7 @@ class ContextMixin(BaseModel):@propertydef llm(self) -> BaseLLM:"""Role llm: role llm > context llm"""+ # logger.info(f"class:{self.__class__.__name__}, llm: {self._llm}, llm_config: {self._llm_config}")if self._llm_config and not self._llm:self._llm = self.context.llm(self._llm_config.name, self._llm_config.provider)return self._llm or self.context.llm()diff --git a/metagpt/roles/engineer.py b/metagpt/roles/engineer.pyindex 364566b37..0d277813e 100644--- a/metagpt/roles/engineer.py+++ b/metagpt/roles/engineer.py@@ -109,7 +109,7 @@ class Engineer(Role):coding_context = await todo.run()# Code reviewif review:- action = WriteCodeReview(context=coding_context, _context=self.context, llm=self.llm)+ action = WriteCodeReview(i_context=coding_context, context=self.context, llm=self.llm)self._init_action_system_message(action)coding_context = await action.run()await src_file_repo.save(@@ -282,7 +282,7 @@ class Engineer(Role):)changed_files.docs[task_filename] = coding_docself.code_todos = [- WriteCode(context=i, g_context=self.context, llm=self.llm) for i in changed_files.docs.values()+ WriteCode(i_context=i, context=self.context, llm=self.llm) for i in changed_files.docs.values()]# Code directly modified by the user.dependency = await self.git_repo.get_dependency()@@ -297,7 +297,7 @@ class Engineer(Role):dependency=dependency,)changed_files.docs[filename] = coding_doc- self.code_todos.append(WriteCode(context=coding_doc, g_context=self.context, llm=self.llm))+ self.code_todos.append(WriteCode(i_context=coding_doc, context=self.context, llm=self.llm))if self.code_todos:self.set_todo(self.code_todos[0])@@ -313,7 +313,7 @@ class Engineer(Role):summarizations[ctx].append(filename)for ctx, filenames in summarizations.items():ctx.codes_filenames = filenames- self.summarize_todos.append(SummarizeCode(context=ctx, llm=self.llm))+ self.summarize_todos.append(SummarizeCode(i_context=ctx, llm=self.llm))if self.summarize_todos:self.set_todo(self.summarize_todos[0])diff --git a/metagpt/roles/qa_engineer.py b/metagpt/roles/qa_engineer.pyindex 80b0fd39a..9483ea260 100644--- a/metagpt/roles/qa_engineer.py+++ b/metagpt/roles/qa_engineer.py@@ -71,7 +71,7 @@ class QaEngineer(Role):)logger.info(f"Writing {test_doc.filename}..")context = TestingContext(filename=test_doc.filename, test_doc=test_doc, code_doc=code_doc)- context = await WriteTest(context=context, g_context=self.context, llm=self.llm).run()+ context = await WriteTest(i_context=context, context=self.context, llm=self.llm).run()await tests_file_repo.save(filename=context.test_doc.filename,content=context.test_doc.content,@@ -112,7 +112,7 @@ class QaEngineer(Role):returnrun_code_context.code = src_doc.contentrun_code_context.test_code = test_doc.content- result = await RunCode(context=run_code_context, g_context=self.context, llm=self.llm).run()+ result = await RunCode(i_context=run_code_context, 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,@@ -136,7 +136,7 @@ class QaEngineer(Role):async def _debug_error(self, msg):run_code_context = RunCodeContext.loads(msg.content)- code = await DebugError(context=run_code_context, g_context=self.context, llm=self.llm).run()+ code = await DebugError(i_context=run_code_context, context=self.context, llm=self.llm).run()await self.context.file_repo.save_file(filename=run_code_context.test_filename, content=code, relative_path=TEST_CODES_FILE_REPO)diff --git a/metagpt/roles/teacher.py b/metagpt/roles/teacher.pyindex b4ffd01d3..9206d5f80 100644--- a/metagpt/roles/teacher.py+++ b/metagpt/roles/teacher.py@@ -45,7 +45,7 @@ class Teacher(Role):actions = []print(TeachingPlanBlock.TOPICS)for topic in TeachingPlanBlock.TOPICS:- act = WriteTeachingPlanPart(context=self.rc.news[0].content, topic=topic, llm=self.llm)+ act = WriteTeachingPlanPart(i_context=self.rc.news[0].content, topic=topic, llm=self.llm)actions.append(act)self.add_actions(actions)