Update bot/chatgpt/chat_gpt_bot.py
Browse files
bot/chatgpt/chat_gpt_bot.py
CHANGED
@@ -12,7 +12,7 @@ user_session = dict()
|
|
12 |
class ChatGPTBot(Bot):
|
13 |
def __init__(self):
|
14 |
openai.api_key = conf().get('open_ai_api_key')
|
15 |
-
openai.api_base="https://
|
16 |
|
17 |
def reply(self, query, context=None):
|
18 |
# acquire reply content
|
@@ -57,8 +57,8 @@ class ChatGPTBot(Bot):
|
|
57 |
except openai.error.RateLimitError as e:
|
58 |
# rate limit exception
|
59 |
logger.warn(e)
|
60 |
-
if retry_count <
|
61 |
-
time.sleep(
|
62 |
logger.warn("[OPEN_AI] RateLimit exceed, 第{}次重试".format(retry_count+1))
|
63 |
return self.reply_text(query, user_id, retry_count+1)
|
64 |
else:
|
@@ -82,8 +82,8 @@ class ChatGPTBot(Bot):
|
|
82 |
return image_url
|
83 |
except openai.error.RateLimitError as e:
|
84 |
logger.warn(e)
|
85 |
-
if retry_count <
|
86 |
-
time.sleep(
|
87 |
logger.warn("[OPEN_AI] ImgCreate RateLimit exceed, 第{}次重试".format(retry_count+1))
|
88 |
return self.reply_text(query, retry_count+1)
|
89 |
else:
|
|
|
12 |
class ChatGPTBot(Bot):
|
13 |
def __init__(self):
|
14 |
openai.api_key = conf().get('open_ai_api_key')
|
15 |
+
openai.api_base="https://apai.zyai.online/v1"
|
16 |
|
17 |
def reply(self, query, context=None):
|
18 |
# acquire reply content
|
|
|
57 |
except openai.error.RateLimitError as e:
|
58 |
# rate limit exception
|
59 |
logger.warn(e)
|
60 |
+
if retry_count < 1:
|
61 |
+
time.sleep(5)
|
62 |
logger.warn("[OPEN_AI] RateLimit exceed, 第{}次重试".format(retry_count+1))
|
63 |
return self.reply_text(query, user_id, retry_count+1)
|
64 |
else:
|
|
|
82 |
return image_url
|
83 |
except openai.error.RateLimitError as e:
|
84 |
logger.warn(e)
|
85 |
+
if retry_count < 1:
|
86 |
+
time.sleep(5)
|
87 |
logger.warn("[OPEN_AI] ImgCreate RateLimit exceed, 第{}次重试".format(retry_count+1))
|
88 |
return self.reply_text(query, retry_count+1)
|
89 |
else:
|