From d92506d84fb4350b329d0bec8aa926f616948607 Mon Sep 17 00:00:00 2001 From: Cyberes Date: Sun, 19 Mar 2023 19:41:03 -0600 Subject: [PATCH] catch all exceptions when trying to rteply --- matrix_gpt/bot/chat_functions.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/matrix_gpt/bot/chat_functions.py b/matrix_gpt/bot/chat_functions.py index a9458ae..965b9fa 100644 --- a/matrix_gpt/bot/chat_functions.py +++ b/matrix_gpt/bot/chat_functions.py @@ -191,8 +191,8 @@ async def process_chat( response = await task if response is not None: break - except stopit.utils.TimeoutException: - logger.warning(f'Timed out replying to event {event.event_id}, retrying...') + except Exception as e: # (stopit.utils.TimeoutException, openai.error.APIConnectionError) + logger.warning(f'Got exception when trying to reply to event {event.event_id}, retrying: {e}') await client.room_typing(room.room_id, typing_state=True, timeout=15000) time.sleep(2) continue @@ -225,6 +225,7 @@ async def process_chat( store.add_event_id(event.event_id) if not isinstance(resp, RoomSendResponse): logger.critical(f'Failed to respond to event {event.event_id} in room {room.room_id}:\n{vars(resp)}') + await react_to_event(client, room.room_id, event.event_id, '❌') else: store.add_event_id(resp.event_id)