🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
6.i initial pr
leonzh0ud651ed288255
diff --git a/metagpt/roles/role.py b/metagpt/roles/role.pyindex 36269aed2..66be77dcd 100644--- a/metagpt/roles/role.py+++ b/metagpt/roles/role.py@@ -219,6 +219,7 @@ class Role:if message:if isinstance(message, str):message = Message(message)+ self.recv(message)if isinstance(message, Message):self.recv(message)elif not await self._observe():diff --git a/metagpt/roles/seacher.py b/metagpt/roles/seacher.pyindex 8e9f5c417..bc7bd7470 100644--- a/metagpt/roles/seacher.py+++ b/metagpt/roles/seacher.py@@ -5,10 +5,12 @@@Author : alexanderwu@File : seacher.py"""+from metagpt.logs import logger+from metagpt.roles import Role-from metagpt.actions import SearchAndSummarize+from metagpt.actions import SearchAndSummarize, ActionOutputfrom metagpt.tools import SearchEngineType-+from metagpt.schema import Messageclass Searcher(Role):def __init__(self, name='Alice', profile='Smart Assistant', goal='Provide search services for users',@@ -19,3 +21,18 @@ class Searcher(Role):def set_search_func(self, search_func):action = SearchAndSummarize("", engine=SearchEngineType.CUSTOM_ENGINE, search_func=search_func)self._init_actions([action])++ async def _act_sp(self) -> Message:+ logger.info(f"{self._setting}: ready to {self._rc.todo}")+ logger.info(self._rc.memory.get(k=0))+ response = await self._rc.todo.run(self._rc.memory.get(k=0))+ # logger.info(response)+ if isinstance(response, ActionOutput):+ msg = Message(content=response.content, instruct_content=response.instruct_content,+ role=self.profile, cause_by=type(self._rc.todo))+ else:+ msg = Message(content=response, role=self.profile, cause_by=type(self._rc.todo))+ self._rc.memory.add(msg)++ async def _act(self) -> Message:+ return await self._act_sp()\ No newline at end of file