| 233 | return answer, previous_convo, convo_id |
| 234 | |
| 235 | def save_data(self): |
| 236 | if self.options.track: |
| 237 | try: |
| 238 | with open(self.options.chat_log, "a") as f: |
| 239 | f.write("\n".join(self.__chat_history) + "\n") |
| 240 | |
| 241 | with open(self.options.id_log, "w") as f: |
| 242 | f.write(str(self.previous_convo_id) + "\n") |
| 243 | f.write(str(self.conversation_id) + "\n") |
| 244 | |
| 245 | except Exception as ex: |
| 246 | self.log(f"{Fore.RED}>> Failed to save chat and ids to chat log and id_log." |
| 247 | f"{ex}") |
| 248 | finally: |
| 249 | self.__chat_history = [] |
| 250 | |
| 251 | def cli_chat(self, rep_queue: Queue or None = None): |
| 252 | """ |