| 19 | |
| 20 | |
| 21 | class ConversationMemory(BaseChatMemory, ABC): |
| 22 | def __init__(self, **kwargs: Any): |
| 23 | super().__init__(**kwargs) |
| 24 | self.conversations = [] |
| 25 | |
| 26 | def addConversation(self, question: str, answer: str): |
| 27 | conversation = {"question": question, "answer": answer} |
| 28 | self.conversations.append(conversation) |
| 29 | |
| 30 | def addQuestion(self, question: str): |
| 31 | conversation = {"question": question} |
| 32 | self.conversations.append(conversation) |
| 33 | |
| 34 | def addAnswer(self, answer: str): |
| 35 | self.conversations[-1]["answer"] = answer |
| 36 | |
| 37 | def covert(self) -> str: |
| 38 | return simplejson.dumps(self.conversations) |
| 39 | |
| 40 | |
| 41 | class RoleManage: |