olivebot/ai_module/nlp_gpt.py
xszyou 5d4bac29b8 20230714
1、修复linux及mac运行出错问题;
2、修复因唇型出错无法继续执行问题;
3、提供rwkv对接方案。
2023-07-14 23:34:53 +08:00

19 lines
510 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from revChatGPT.V3 import Chatbot
from utils import config_util as cfg
import time
count = 0
def question(cont):
global count
try:
chatbot = Chatbot(model = "gpt-3.5", proxy = cfg.proxy_config, 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