From c7d4933baefe26a807be9189d49e8067995dae09 Mon Sep 17 00:00:00 2001 From: Cyberes Date: Sat, 18 Mar 2023 14:04:52 -0600 Subject: [PATCH] only send once --- matrix_gpt/bot/callbacks.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/matrix_gpt/bot/callbacks.py b/matrix_gpt/bot/callbacks.py index 154a9e8..b314266 100644 --- a/matrix_gpt/bot/callbacks.py +++ b/matrix_gpt/bot/callbacks.py @@ -77,16 +77,17 @@ class Callbacks: for event in thread_content: if isinstance(event, MegolmEvent): await send_text_to_room(self.client, room.room_id, 'Decryption Failure', reply_to_event_id=event.event_id, thread=True, thread_root_id=thread_content[0].event_id) + return else: api_data.append({ 'role': 'assistant' if event.sender == self.client.user_id else 'user', 'content': event.body if not event.body.startswith(self.command_prefix) else event.body[len(self.command_prefix):].strip() }) # if len(thread_content) >= 2 and thread_content[0].body.startswith(self.command_prefix): # if thread_content[len(thread_content) - 2].sender == self.client.user - # message = Message(self.client, self.store, msg, room, event, self.reply_in_thread) - # await message.process() - api_data.append({'role': 'user', 'content': event.body}) - await process_chat(self.client, room, event, api_data, self.store, self.openai, thread_root_id=thread_content[0].event_id, system_prompt=self.system_prompt) + # message = Message(self.client, self.store, msg, room, event, self.reply_in_thread) + # await message.process() + api_data.append({'role': 'user', 'content': event.body}) + await process_chat(self.client, room, event, api_data, self.store, self.openai, thread_root_id=thread_content[0].event_id, system_prompt=self.system_prompt) return elif msg.startswith(f'{self.command_prefix} ') or room.member_count == 2: # Otherwise if this is in a 1-1 with the bot or features a command prefix, treat it as a command.