🐛: 取消QQSDK的旧版标记
🐛: 修复switch指令的一些问题
This commit is contained in:
+2
-2
@@ -367,7 +367,7 @@ def initBot(cfg, prov):
|
||||
|
||||
# QQ频道
|
||||
if 'qqbot' in cfg and cfg['qqbot']['enable']:
|
||||
gu.log("- 启用QQ频道机器人(旧版) -", gu.LEVEL_INFO)
|
||||
gu.log("- 启用QQ频道机器人 -", gu.LEVEL_INFO)
|
||||
global qqchannel_bot, qqchan_loop
|
||||
qqchannel_bot = QQChan()
|
||||
qqchan_loop = asyncio.new_event_loop()
|
||||
@@ -399,7 +399,7 @@ def run_qqchan_bot(cfg, loop, qqchannel_bot: QQChan):
|
||||
gu.log("启动QQ频道机器人时出现错误, 原因如下: " + str(e), gu.LEVEL_CRITICAL, tag="QQ频道")
|
||||
gu.log(r"如果您是初次启动,请修改配置文件(QQChannelChatGPT/config.yaml)详情请看:https://github.com/Soulter/QQChannelChatGPT/wiki。" + str(e), gu.LEVEL_CRITICAL, tag="System")
|
||||
|
||||
i = input("输入y打开配置文件, 按回车退出程序。")
|
||||
i = input("如果本 Bot 运行在 Windows 下,可以输入 y 快捷打开配置文件。按回车退出程序。")
|
||||
if i == "y":
|
||||
abs_path = os.path.abspath("QQChannelChatGPT/configs/config.yaml")
|
||||
print("配置文件地址:" + abs_path)
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import json
|
||||
|
||||
from util import general_utils as gu
|
||||
has_git = True
|
||||
try:
|
||||
import git.exc
|
||||
from git.repo import Repo
|
||||
except BaseException as e:
|
||||
print("你正运行在无Git环境下,暂时将无法使用插件、热更新功能。")
|
||||
gu.log("你正运行在无Git环境下,暂时将无法使用插件、热更新功能。")
|
||||
has_git = False
|
||||
|
||||
import os
|
||||
import sys
|
||||
import requests
|
||||
@@ -16,7 +15,6 @@ import json
|
||||
import util.plugin_util as putil
|
||||
import shutil
|
||||
import importlib
|
||||
from util import general_utils as gu
|
||||
from util.cmd_config import CmdConfig as cc
|
||||
from model.platform.qq import QQ
|
||||
import stat
|
||||
|
||||
@@ -174,11 +174,13 @@ class CommandOpenAIOfficial(Command):
|
||||
if index > len(key_stat) or index < 1:
|
||||
return True, "账号序号不合法。", "switch"
|
||||
else:
|
||||
ret = self.provider.check_key(list(key_stat.keys())[index-1])
|
||||
if ret:
|
||||
return True, f"账号切换成功。", "switch"
|
||||
else:
|
||||
return True, f"账号切换失败,可能超额或超频。", "switch"
|
||||
try:
|
||||
new_key = list(key_stat.keys())[index-1]
|
||||
ret = self.provider.check_key(new_key)
|
||||
self.provider.set_key(new_key)
|
||||
except BaseException as e:
|
||||
return True, "账号切换失败,原因: " + str(e), "switch"
|
||||
return True, f"账号切换成功。", "switch"
|
||||
except BaseException as e:
|
||||
return True, "未知错误: "+str(e), "switch"
|
||||
else:
|
||||
|
||||
@@ -12,7 +12,6 @@ import traceback
|
||||
import tiktoken
|
||||
|
||||
abs_path = os.path.dirname(os.path.realpath(sys.argv[0])) + '/'
|
||||
key_record_path = abs_path + 'chatgpt_key_record'
|
||||
|
||||
class ProviderOpenAIOfficial(Provider):
|
||||
def __init__(self, cfg):
|
||||
@@ -110,7 +109,11 @@ class ProviderOpenAIOfficial(Provider):
|
||||
# 每隔10分钟转储一次
|
||||
time.sleep(10*self.history_dump_interval)
|
||||
|
||||
def text_chat(self, prompt, session_id = None, image_url = None, function_call=None):
|
||||
def text_chat(self, prompt,
|
||||
session_id = None,
|
||||
image_url = None,
|
||||
function_call=None,
|
||||
extra_conf: dict = None):
|
||||
if session_id is None:
|
||||
session_id = "unknown"
|
||||
if "unknown" in self.session_dict:
|
||||
@@ -161,7 +164,10 @@ class ProviderOpenAIOfficial(Provider):
|
||||
conf['model'] = 'gpt-4-vision-preview'
|
||||
else:
|
||||
conf = self.openai_model_configs
|
||||
print(req)
|
||||
|
||||
if extra_conf is not None:
|
||||
conf.update(extra_conf)
|
||||
|
||||
while retry < 10:
|
||||
try:
|
||||
if function_call is None:
|
||||
@@ -410,6 +416,9 @@ class ProviderOpenAIOfficial(Provider):
|
||||
def get_curr_key(self):
|
||||
return self.client.api_key
|
||||
|
||||
def set_key(self, key):
|
||||
self.client.api_key = key
|
||||
|
||||
# 添加key
|
||||
def append_key(self, key, sponsor):
|
||||
self.key_list.append(key)
|
||||
@@ -422,14 +431,8 @@ class ProviderOpenAIOfficial(Provider):
|
||||
base_url=self.api_base
|
||||
)
|
||||
messages = [{"role": "user", "content": "please just echo `test`"}]
|
||||
try:
|
||||
client_.chat.completions.create(
|
||||
messages=messages,
|
||||
**self.openai_model_configs
|
||||
)
|
||||
return True
|
||||
except Exception as e:
|
||||
pass
|
||||
return False
|
||||
|
||||
|
||||
client_.chat.completions.create(
|
||||
messages=messages,
|
||||
**self.openai_model_configs
|
||||
)
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user