only send once

This commit is contained in:
Cyberes 2023-03-18 14:04:52 -06:00
parent 7dc2bf12b6
commit c7d4933bae
1 changed files with 5 additions and 4 deletions

View File

@ -77,16 +77,17 @@ class Callbacks:
for event in thread_content: for event in thread_content:
if isinstance(event, MegolmEvent): 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) 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: else:
api_data.append({ api_data.append({
'role': 'assistant' if event.sender == self.client.user_id else 'user', '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() '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 }) # 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) # message = Message(self.client, self.store, msg, room, event, self.reply_in_thread)
# await message.process() # await message.process()
api_data.append({'role': 'user', 'content': event.body}) 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) 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 return
elif msg.startswith(f'{self.command_prefix} ') or room.member_count == 2: 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. # Otherwise if this is in a 1-1 with the bot or features a command prefix, treat it as a command.