f8ff5a2187
+ 增加运行时自动清理ui缓存; + 增加gpt代理设置可为空; + 提高灵聚对接的稳定性。
22 lines
610 B
Python
22 lines
610 B
Python
from revChatGPT.V3 import Chatbot
|
||
from utils import config_util as cfg
|
||
import time
|
||
|
||
count = 0
|
||
def question(cont):
|
||
global count
|
||
try:
|
||
if cfg.proxy_config != '' :
|
||
chatbot = Chatbot(proxy = cfg.proxy_config, api_key = cfg.key_chatgpt_api_key)
|
||
else:
|
||
chatbot = Chatbot(api_key = cfg.key_chatgpt_api_key)
|
||
response = chatbot.ask(cont)
|
||
count = 0
|
||
return response
|
||
except Exception as e:
|
||
count += 1
|
||
if count < 3:
|
||
time.sleep(15)
|
||
return question(cont)
|
||
return 'gpt当前繁忙,请稍后重试' + e
|