Merge branch 'dev' of https://github.com/geekan/MetaGPT into geekan/dev

This commit is contained in:
莘权 马 2024-01-22 13:33:59 +08:00
commit 2eb5e2f913
2 changed files with 13 additions and 8 deletions

View file

@ -37,11 +37,7 @@ class FaissStore(LocalStore):
return FAISS.load_local(self.raw_data_path.parent, self.embedding, self.fname)
def _write(self, docs, metadatas):
try:
store = FAISS.from_texts(docs, self.embedding, metadatas=metadatas)
except Exception as e:
logger.error(f"Failed to write. error: {e}")
raise e
store = FAISS.from_texts(docs, self.embedding, metadatas=metadatas)
return store
def persist(self):

View file

@ -523,20 +523,29 @@ class Role(SerializationMixin, ContextMixin, BaseModel):
return not self.rc.news and not self.rc.todo and self.rc.msg_buffer.empty()
async def think(self) -> Action:
"""The exported `think` function"""
await self._observe()
"""
Export SDK API, used by AgentStore RPC.
The exported `think` function
"""
await self._observe() # For compatibility with the old version of the Agent.
await self._think()
return self.rc.todo
async def act(self) -> ActionOutput:
"""The exported `act` function"""
"""
Export SDK API, used by AgentStore RPC.
The exported `act` function
"""
msg = await self._act()
return ActionOutput(content=msg.content, instruct_content=msg.instruct_content)
@property
def action_description(self) -> str:
"""
Export SDK API, used by AgentStore RPC and Agent.
AgentStore uses this attribute to display to the user what actions the current role should take.
`Role` provides the default property, and this property should be overridden by children classes if necessary,
as demonstrated by the `Engineer` class.
"""
if self.rc.todo:
if self.rc.todo.desc: