fix: 修复父类role代码改动而影响到子类role-教程助手功能的问题

This commit is contained in:
Stitch-z 2024-06-12 15:06:32 +08:00
parent eca66704d8
commit cf45fba821

View file

@ -56,7 +56,7 @@ class TutorialAssistant(Role):
self.main_title = titles.get("title")
directory = f"{self.main_title}\n"
self.total_content += f"# {self.main_title}"
actions = list()
actions = list(self.actions)
for first_dir in titles.get("directory"):
actions.append(WriteContent(language=self.language, directory=first_dir))
key = list(first_dir.keys())[0]
@ -64,6 +64,8 @@ class TutorialAssistant(Role):
for second_dir in first_dir[key]:
directory += f" - {second_dir}\n"
self.set_actions(actions)
self.rc.max_react_loop = len(self.actions)
return Message()
async def _act(self) -> Message:
"""Perform an action as determined by the role.
@ -77,8 +79,7 @@ class TutorialAssistant(Role):
self.topic = msg.content
resp = await todo.run(topic=self.topic)
logger.info(resp)
await self._handle_directory(resp)
return await super().react()
return await self._handle_directory(resp)
resp = await todo.run(topic=self.topic)
logger.info(resp)
if self.total_content != "":