🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
fix da not responded to new req; rm user_req attribute from rolezero
garylin209930286ce4b86f
diff --git a/metagpt/roles/di/data_analyst.py b/metagpt/roles/di/data_analyst.pyindex e489c9d98..1ccdd5e3c 100644--- a/metagpt/roles/di/data_analyst.py+++ b/metagpt/roles/di/data_analyst.py@@ -41,6 +41,7 @@ class DataAnalyst(DataInterpreter):# Command.PASS,]commands: list[dict] = [] # issued commands to be executed+ user_requirement: str = ""@model_validator(mode="after")def set_plan_and_tool(self) -> "DataInterpreter":@@ -68,9 +69,6 @@ class DataAnalyst(DataInterpreter):self.user_requirement = self.get_memories()[-1].contentself.planner.plan.goal = self.user_requirementexample = KeywordExpRetriever().retrieve(self.user_requirement)- else:- self.working_memory.add_batch(self.rc.news)- # TODO: implement experience retrieval in multi-round settingplan_status = self.planner.plan.model_dump(include=["goal", "tasks"])# for task in plan_status["tasks"]:@@ -82,10 +80,11 @@ class DataAnalyst(DataInterpreter):available_commands=prepare_command_prompt(self.available_commands),)context = self.llm.format_msg(self.working_memory.get() + [Message(content=prompt, role="user")])+ # print(*context, sep="\n" + "*" * 5 + "\n")async with ThoughtReporter():rsp = await self.llm.aask(context)self.commands = json.loads(CodeParser.parse_code(block=None, text=rsp))- self.rc.memory.add(Message(content=rsp, role="assistant"))+ self.rc.working_memory.add(Message(content=rsp, role="assistant"))await run_commands(self, self.commands, self.rc.working_memory)@@ -118,7 +117,11 @@ class DataAnalyst(DataInterpreter):rsp = Message(content="No actions taken yet", cause_by=Action) # will be overwritten after Role _actwhile actions_taken < self.rc.max_react_loop:# NOTE: Diff 2: Keep observing within _react, news will go into memory, allowing adapting to new info+ # add news from self._observe, the one called in self.run, consider removing when switching from working_memory to memory+ self.working_memory.add_batch(self.rc.news)await self._observe()+ # add news from this self._observe, we need twice because _observe rewrites rc.news+ self.working_memory.add_batch(self.rc.news)# thinkhas_todo = await self._think()diff --git a/metagpt/roles/di/role_zero.py b/metagpt/roles/di/role_zero.pyindex 44e658ed4..3f6e53eb6 100644--- a/metagpt/roles/di/role_zero.py+++ b/metagpt/roles/di/role_zero.py@@ -53,7 +53,6 @@ class RoleZero(Role):experience_retriever: ExpRetriever = DummyExpRetriever()# Others- user_requirement: str = ""command_rsp: str = "" # the raw string containing the commandscommands: list[dict] = [] # commands to be executedmemory_k: int = 20 # number of memories (messages) to use as historical context@@ -106,8 +105,7 @@ class RoleZero(Role):return Falseif not self.planner.plan.goal:- self.user_requirement = self.get_memories()[-1].content- self.planner.plan.goal = self.user_requirement+ self.planner.plan.goal = self.get_memories()[-1].content### 1. Experience ###example = self._retrieve_experience()