timeout wait

This commit is contained in:
Cyberes 2023-03-19 16:01:36 -06:00
parent a80eb6d484
commit e74a3685be
2 changed files with 9 additions and 1 deletions

View File

@ -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. 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 ## Encryption
This bot supports encryption. I recommend using [Pantalaimon](https://github.com/matrix-org/pantalaimon/) to manage encryption keys as the This bot supports encryption. I recommend using [Pantalaimon](https://github.com/matrix-org/pantalaimon/) to manage encryption keys as the

View File

@ -1,4 +1,5 @@
import logging import logging
import time
from types import ModuleType from types import ModuleType
from typing import List, Optional, Union 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): for i in range(openai_retries):
try: try:
text_response, response = generate(timeout=5) text_response, response = generate(timeout=5)
if text_response is not None: if text_response is not None and response is not None:
break break
except stopit.utils.TimeoutException: except stopit.utils.TimeoutException:
time.sleep(2)
continue continue
if text_response is None: if text_response is None:
logger.critical(f'OpenAI API timeout for event {event.event_id} in room {room.room_id}.') logger.critical(f'OpenAI API timeout for event {event.event_id} in room {room.room_id}.')