From 235a798c6470ae3f2e7c3c575739bd1f3c7dd814 Mon Sep 17 00:00:00 2001 From: Paillat Date: Mon, 4 Sep 2023 13:27:09 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20fix(ChatProcess.py):=20remove=20?= =?UTF-8?q?unused=20import=20statement=20for=20APIError=20from=20openai.er?= =?UTF-8?q?ror=20module=20=F0=9F=94=A7=20fix(ChatProcess.py):=20change=20e?= =?UTF-8?q?xception=20check=20from=20isinstance(e,=20APIError)=20to=20isin?= =?UTF-8?q?stance(e,=20TimeoutError)=20to=20handle=20timeout=20errors=20co?= =?UTF-8?q?rrectly=20=F0=9F=94=A7=20fix(ChatProcess.py):=20fix=20formattin?= =?UTF-8?q?g=20of=20error=20message=20to=20be=20sent=20in=20case=20of=20an?= =?UTF-8?q?=20error=20during=20message=20processing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ChatProcess.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/ChatProcess.py b/src/ChatProcess.py index c142b37..ce04ff3 100644 --- a/src/ChatProcess.py +++ b/src/ChatProcess.py @@ -5,7 +5,6 @@ import discord import datetime import json -from openai.error import APIError from src.utils.misc import moderate from src.utils.variousclasses import models, characters from src.guild import Guild @@ -14,7 +13,6 @@ from src.chatUtils.prompts import createPrompt from src.functionscalls import call_function, server_normal_channel_functions, functions from src.chatUtils.requesters.request import request - class Chat: def __init__(self, bot: discord.bot, message: discord.Message): self.bot = bot @@ -210,7 +208,7 @@ class Chat: self.message.remove_reaction("🤔", self.message.guild.me) except: pass - if isinstance(e, APIError): + if isinstance(e, TimeoutError): await self.message.channel.send( "Due to OpenAI not doing their work, I can unfortunately not answer right now. Do retry soon!", delete_after=5, @@ -218,9 +216,9 @@ class Chat: else: await self.message.channel.send( f"""An error occured while processing your message, we are sorry about that. Please check your settings and try again later. If the issue persists, please join uor discord server here: https://discord.gg/pB6hXtUeDv and send the following logs: - ``` - {e} - ```""", +``` +{e} +```""", delete_after=4, ) try: