diff --git a/README.md b/README.md index 9904b4d..26b8085 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,12 @@ Then invite your bot and start a chat by prefixing your message with `!c`. The b I included a sample Systemd service. +## Use + +Invite the bot to your room and query it with the command `!c` (this can be changed in the config.) + +Don't try to use two bots in the same thread. + ## Encryption This bot supports encryption. I recommend using [Pantalaimon](https://github.com/matrix-org/pantalaimon/) to manage encryption keys as the diff --git a/matrix_gpt/bot/chat_functions.py b/matrix_gpt/bot/chat_functions.py index e8ea2ae..a718ffd 100644 --- a/matrix_gpt/bot/chat_functions.py +++ b/matrix_gpt/bot/chat_functions.py @@ -1,4 +1,5 @@ import logging +import time from types import ModuleType from typing import List, Optional, Union @@ -167,9 +168,10 @@ async def process_chat(client, room, event, command, store, openai_obj: ModuleTy for i in range(openai_retries): try: text_response, response = generate(timeout=5) - if text_response is not None: + if text_response is not None and response is not None: break except stopit.utils.TimeoutException: + time.sleep(2) continue if text_response is None: logger.critical(f'OpenAI API timeout for event {event.event_id} in room {room.room_id}.')