2023-06-28 19:44:34 +08:00
|
|
|
|
from revChatGPT.V3 import Chatbot
|
2023-05-19 18:12:02 +08:00
|
|
|
|
from utils import config_util as cfg
|
2023-05-27 17:03:43 +08:00
|
|
|
|
import time
|
2023-05-19 18:12:02 +08:00
|
|
|
|
|
2023-05-27 17:03:43 +08:00
|
|
|
|
count = 0
|
2023-05-19 18:12:02 +08:00
|
|
|
|
def question(cont):
|
2023-05-27 17:03:43 +08:00
|
|
|
|
global count
|
2023-05-19 18:12:02 +08:00
|
|
|
|
try:
|
2023-06-28 19:44:34 +08:00
|
|
|
|
chatbot = Chatbot(proxy = cfg.proxy_config, api_key = cfg.key_chatgpt_api_key)
|
|
|
|
|
response = chatbot.ask(cont)
|
2023-05-27 17:03:43 +08:00
|
|
|
|
count = 0
|
2023-05-19 18:12:02 +08:00
|
|
|
|
return response
|
2023-05-27 17:03:43 +08:00
|
|
|
|
except Exception as e:
|
|
|
|
|
count += 1
|
|
|
|
|
if count < 3:
|
|
|
|
|
time.sleep(15)
|
|
|
|
|
return question(cont)
|
|
|
|
|
return 'gpt当前繁忙,请稍后重试' + e
|