mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-03-12 18:01:30 +08:00
fix: use openai_compat layer for error handling
The code was directly importing openai.error which fails with openai>=1.0. The project already has an openai_compat.py compatibility layer that handles both old (<1.0) and new (>=1.0) OpenAI SDK versions. This commit updates chat_gpt_bot.py to use the compatibility layer. Related: #2687
This commit is contained in:
@@ -4,7 +4,7 @@ import time
|
||||
import json
|
||||
|
||||
import openai
|
||||
import openai.error
|
||||
from models.openai.openai_compat import error as openai_error, RateLimitError, Timeout, APIError, APIConnectionError
|
||||
import requests
|
||||
from common import const
|
||||
from models.bot import Bot
|
||||
@@ -229,7 +229,7 @@ class ChatGPTBot(Bot, OpenAIImage, OpenAICompatibleBot):
|
||||
"""
|
||||
try:
|
||||
if conf().get("rate_limit_chatgpt") and not self.tb4chatgpt.get_token():
|
||||
raise openai.error.RateLimitError("RateLimitError: rate limit exceeded")
|
||||
raise RateLimitError("RateLimitError: rate limit exceeded")
|
||||
# if api_key == None, the default openai.api_key will be used
|
||||
if args is None:
|
||||
args = self.args
|
||||
|
||||
Reference in New Issue
Block a user