From f52a0eb43a41b65baa87ffbecce9cf0fa7641e26 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Sat, 27 Jul 2024 08:58:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E8=BF=81=E7=A7=BB=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/bootstrap.py | 5 +- configs/config.yaml | 137 ------------------------------------------- util/config_utils.py | 38 ++++++++++++ 3 files changed, 42 insertions(+), 138 deletions(-) delete mode 100644 configs/config.yaml diff --git a/astrbot/bootstrap.py b/astrbot/bootstrap.py index ef548dd39..08a29a258 100644 --- a/astrbot/bootstrap.py +++ b/astrbot/bootstrap.py @@ -107,4 +107,7 @@ class AstrBotBootstrap(): self.plugin_manager.plugin_reload() def load_platform(self): - return self.platfrom_manager.load_platforms() \ No newline at end of file + platforms = self.platfrom_manager.load_platforms() + if not platforms: + logger.warn("未启用任何消息平台。") + return platforms \ No newline at end of file diff --git a/configs/config.yaml b/configs/config.yaml deleted file mode 100644 index 44f04c029..000000000 --- a/configs/config.yaml +++ /dev/null @@ -1,137 +0,0 @@ -# 如果你不知道怎么部署,请查看https://soulter.top/posts/qpdg.html -# 不一定需要key了,如果你没有key但有openAI账号或者必应账号,可以考虑使用下面的逆向库 - - -###############平台设置################# - -# QQ频道机器人 -# QQ开放平台的appid和令牌 -# q.qq.com -# enable为true则启用,false则不启用 -qqbot: - enable: true - appid: - token: - -# QQ机器人 -# enable为true则启用,false则不启用 -# 需要安装GO-CQHTTP配合使用。 -# 文档:https://docs.go-cqhttp.org/ -# 请将go-cqhttp的配置文件的sever部分粘贴为以下内容,否则无法使用 -# 请先启动go-cqhttp再启动本程序 -# -# servers: -# - http: -# host: 127.0.0.1 -# version: 0 -# port: 5700 -# timeout: 5 -# - ws: -# address: 127.0.0.1:6700 -# middlewares: -# <<: *default -gocqbot: - enable: false - -# 设置是否一个人一个会话 -uniqueSessionMode: false -# QChannelBot 的版本,请勿修改此字段,否则可能产生一些bug -version: 3.0 -# [Beta] 转储历史记录时间间隔(分钟) -dump_history_interval: 10 -# 一个用户只能在time秒内发送count条消息 -limit: - time: 60 - count: 5 -# 公告 -notice: "此机器人由Github项目QQChannelChatGPT驱动。" -# 是否打开私信功能 -# 设置为true则频道成员可以私聊机器人。 -# 设置为false则频道成员不能私聊机器人。 -direct_message_mode: true - -# 系统代理 -# http_proxy: http://localhost:7890 -# https_proxy: http://localhost:7890 - -# 自定义回复前缀,如[Rev]或其他,务必加引号以防止不必要的bug。 -reply_prefix: - openai_official: "[GPT]" - rev_chatgpt: "[Rev]" - rev_edgegpt: "[RevBing]" - -# 百度内容审核服务 -# 新用户免费5万次调用。https://cloud.baidu.com/doc/ANTIPORN/index.html -baidu_aip: - enable: false - app_id: - api_key: - secret_key: - - - - -###############语言模型设置################# - - -# OpenAI官方API -# 注意:已支持多key自动切换,方法: -# key: -# - sk-xxxxxx -# - sk-xxxxxx -# 在下方非注释的地方使用以上格式 -# 关于api_base:可以使用一些云函数(如腾讯、阿里)来避免国内被墙的问题。 -# 详见: -# https://github.com/Ice-Hazymoon/openai-scf-proxy -# https://github.com/Soulter/QQChannelChatGPT/issues/42 -# 设置为none则表示使用官方默认api地址 -openai: - key: - - - api_base: none - # 这里是GPT配置,语言模型默认使用gpt-3.5-turbo - chatGPTConfigs: - model: gpt-3.5-turbo - max_tokens: 3000 - temperature: 0.9 - top_p: 1 - frequency_penalty: 0 - presence_penalty: 0 - - total_tokens_limit: 5000 - -# 逆向文心一言【暂时不可用,请勿使用】 -rev_ernie: - enable: false - -# 逆向New Bing -# 需要在项目根目录下创建cookies.json并粘贴cookies进去。 -# 详见:https://soulter.top/posts/qpdg.html -rev_edgegpt: - enable: false - -# 逆向ChatGPT库 -# https://github.com/acheong08/ChatGPT -# 优点:免费(无免费额度限制); -# 缺点:速度相对慢。OpenAI 速率限制:免费帐户每小时 50 个请求。您可以通过多帐户循环来绕过它 -# enable设置为true后,将会停止使用上面正常的官方API调用而使用本逆向项目 -# -# 多账户可以保证每个请求都能得到及时的回复。 -# 关于account的格式 -# account: -# - email: 第1个账户 -# password: 第1个账户密码 -# - email: 第2个账户 -# password: 第2个账户密码 -# - .... -# 支持使用access_token登录 -# 例: -# - session_token: xxxxx -# - access_token: xxxx -# 请严格按照上面这个格式填写。 -# 逆向ChatGPT库的email-password登录方式不工作,建议使用access_token登录 -# 获取access_token的方法,详见:https://soulter.top/posts/qpdg.html -rev_ChatGPT: - enable: false - account: - - access_token: \ No newline at end of file diff --git a/util/config_utils.py b/util/config_utils.py index 935793c98..cdf783e3e 100644 --- a/util/config_utils.py +++ b/util/config_utils.py @@ -9,6 +9,44 @@ def init_configs(): ''' cc = CmdConfig() + cc.init_attributes("qqbot", { + "enable": False, + "appid": "", + "token": "", + }) + cc.init_attributes("gocqbot", { + "enable": False, + }) + cc.init_attributes("uniqueSessionMode", False) + cc.init_attributes("dump_history_interval", 10) + cc.init_attributes("limit", { + "time": 60, + "count": 30, + }) + cc.init_attributes("notice", "") + cc.init_attributes("direct_message_mode", True) + cc.init_attributes("reply_prefix", "") + cc.init_attributes("baidu_aip", { + "enable": False, + "app_id": "", + "api_key": "", + "secret_key": "" + }) + cc.init_attributes("openai", { + "key": [], + "api_base": "", + "chatGPTConfigs": { + "model": "gpt-4o", + "max_tokens": 6000, + "temperature": 0.9, + "top_p": 1, + "frequency_penalty": 0, + "presence_penalty": 0, + }, + "total_tokens_limit": 10000, + }) + + cc.init_attributes("qq_forward_threshold", 200) cc.init_attributes("qq_welcome", "") cc.init_attributes("qq_pic_mode", True)