diff --git a/src/.vuepress/navbar.ts b/src/.vuepress/navbar.ts index 016aed8bf..bbb8fb362 100644 --- a/src/.vuepress/navbar.ts +++ b/src/.vuepress/navbar.ts @@ -17,7 +17,7 @@ export default navbar([ { text: "配置方法", icon: "context", - link: "/posts/config-intro", + link: "/posts/config/", }, { text: "代码仓库", diff --git a/src/.vuepress/sidebar.ts b/src/.vuepress/sidebar.ts index b2edbfcfd..2f5c1976c 100644 --- a/src/.vuepress/sidebar.ts +++ b/src/.vuepress/sidebar.ts @@ -75,7 +75,40 @@ export default sidebar({ { text: "配置详解", icon: "context", - link: "posts/config-intro", + prefix: "posts/config/", + link: "posts/config/", + children: [ + { + text: "platform.json", + icon: "config", + link: "platform" + }, + { + text: "pipeline.json", + icon: "config", + link: "pipeline" + }, + { + text: "provider.json", + icon: "config", + link: "provider" + }, + { + text: "command.json", + icon: "config", + link: "command" + }, + { + text: "sensitive-words.json", + icon: "config", + link: "sensitive-words" + }, + { + text: "system.json", + icon: "config", + link: "system" + }, + ] }, { text: "常见问题", diff --git a/src/posts/config-intro.md b/src/posts/config-intro.md index cef57d98a..6695d8792 100644 --- a/src/posts/config-intro.md +++ b/src/posts/config-intro.md @@ -39,387 +39,6 @@ tag: 以下是对各个配置文件的详细解读 -## command.json - -设置每个命令的权限配置 - -普通用户权限级别为 1,管理员(`system.json`中设置的)权限级别为 2。 - -在这里设置每个命令的最低权限级别,若设置为1,则用户和管理员均可用,若为2,则仅管理员可用 - - 需要设置子命令,以点号间隔,如`"plugin.on"` 示例: - -```json -{ "plugin": 1, - "plugin.on": 2 -} -``` - - 意思是 plugin 命令的最低权限级别为 1,plugin.on 命令的最低权限级别为 2。 每个命令都有默认的权限级别 - -若不设置,则使用默认的级别在`pkg/command/operators`里每个命令类有默认的权限级别 - -## pipeline.json - -QChatGPT 3.0新引入的概念,平台适配器获取到消息事件之后,发送给pipeline排队进行处理 - -可以设置黑白名单、群响应规则、是否检查传入消息、传入消息忽略规则、是否检查敏感词、百度云内容审核配置、传入消息长度设置、限速配置 - -以下是各项的详细解释 - -### 黑白名单 - -```json -"access-control":{ - "mode": "blacklist", - "blacklist": [], - "whitelist": [] -}, -``` - -`access-control`:黑白名单控制 - -`mode`:设置模式白名单 `whitelist` 和黑名单 `blacklist` 两种模式 - -`blacklist`:格式`{type}_{id}`,示例:`"blacklist": [group_12345678,person_12341234],` - -`whitelist`:格式`{type}_{id}`,示例:`"whitelist": [group_12345678,person_12341234]` - - - -### 群响应规则 - -```json -"respond-rules": { - "default": { - "at": true, - "prefix": [ - "/ai", "!ai", "!ai", "ai" - ], - "regexp": [], - "random": 0.0 - } -}, -``` - -`respond-rules`:设置群内响应规则,仅对access-control通过的群生效其中可含有多个key,若要对特定群设置响应规则,则以群号作为键未特指的群,将使用 default 中的响应规则 - -`at`:`true`或`false`,设置@响应 - -`prefix`:设置响应前缀 - -`regexp`:正则匹配 - -`random`:随机匹配,为1时所有消息都响应 - -你可以为单个群聊设置特定的响应规则,例如 - -```json -"respond-rules": { - "default": { - "at": true, - "prefix": [ - "/ai", "!ai", "!ai", "ai" - ], - "regexp": [], - "random": 0.0 - }, - "123456":{ - "at": true, - "prefix": [ - "/ai", "!ai", "!ai", "ai" - ], - "regexp": [], - "random": 0.0 - }, - "789012":{ - "at": true, - "prefix": [ - "/ai", "!ai", "!ai", "ai" - ], - "regexp": [], - "random": 0.0 - } -}, -``` - -```json -"income-msg-check": true, -``` - - - -### 是否检查传入消息 - -```json -"income-msg-check": true, -``` - -`income-msg-check`:是否检查传入的消息 - -### 传入消息忽略规则 - -```json -"ignore-rules": { - "prefix": ["/"], - "regexp": [] -}, -``` - -符合规则的传入消息将被忽略,仅`income-msg-check`为`true`时生效 - -`prefix`:前缀为`/`的忽略 - -`regexp`:正则匹配的忽略 - -### 是否检查敏感词 - -```json -"check-sensitive-words": true, -``` - -`check-sensitive-words`:是否检查敏感词,敏感词词库为`sensitive-words.json`里面的 - -### 百度云内容审核配置 - -```json -"baidu-cloud-examine": { - "enable": false, - "api-key": "", - "api-secret": "" -}, -``` - -`baidu-cloud-examine`:控制是否使用是否进行百度云内容审核 - -`enable`:enable=true时启用,一定会检查响应结果,仅`income-msg-check`为true时检查传入消息 - -`api-key`:百度AI开放平台的`API_KEY` - -`api-secret`:百度AI开放平台的`SECRET_KEY` - -*`API_KEY`与`SECRET_KEY`是在创建完毕应用后,系统分配给用户的,均为字符串,用于标识用户,为访问做签名验证,可在AI服务控制台中的**应用列表**中查看* - -### 传入消息长度设置 - -```json -"submit-messages-tokens": 3072, -``` - -`submit-messages-tokens`:传给模型的消息长度限制,不同模型有不同的token数限制,QChatGPT 内部会保存各个模型的(约)最大token数限制 - - 与此值取最小值,在传给模型API之前进行截断 - -### 限速配置 - -```json -"rate-limit": { - "strategy": "drop", - "algo": "fixwin", - "fixwin": { - "default": 60 - } -} -``` - -`rate-limit`限速配置, 支持 drop 和 wait 两种策略 - -`strategy`:`drop`为丢弃,`wait`为等待 - -`algo`: 使用的算法,目前仅支持 `fixwin` (固定窗口),即一分钟内最多处理多少个请求 - -`fixwin`:具体速率设置,一分钟内最多处理多少个请求, 支持对特定session指定限速,格式为 {type}_{id},示例:group_12345678,person_12341234 - -## platform.json - -可以配置:要启用的消息适配器列表,是否跟踪内容函数调用过程,群内回复时是否引用原消息,群内回复时是否at原用户,强制消息延迟范围,长消息处理策略,是否向用户隐藏AI的异常信息 - -### 消息适配器列表 - -```json -"platform-adapters": [ - { - "adapter": "yiri-mirai", - "enable": false, - "host": "127.0.0.1", - "port": 8080, - "verifyKey": "yirimirai", - "qq": 123456789 - }, - { - "adapter": "nakuru", - "enable": false, - "host": "127.0.0.1", - "ws_port": 8080, - "http_port": 5700, - "token": "" - }, - { - "adapter": "aiocqhttp", - "enable": false, - "host": "127.0.0.1", - "port": 8080 - }, - { - "adapter": "qq-botpy", - "enable": false, - "appid": "", - "secret": "", - "intents": [ - "public_guild_messages", - "direct_message" - ] - } -], -``` - -截至2024年2月13日,目前支持`mirai`、`go-cqhttp`、`aiocqhttp`、`QQ官方机器人`,支持同时开启多个消息适配器,甚至四个全开 - -```json -{ - "adapter": "yiri-mirai", - "enable": false, - "host": "127.0.0.1", - "port": 8080, - "verifyKey": "yirimirai", - "qq": 123456789 -}, -``` - -`"adapter": "yiri-mirai"`,无需动,表明是接入`mirai`的配置 - -`enable`:是否启用,`true`开启 - -`host`:主机地址,一般不动 - -`port`:设置端口,默认8080,与`mirai-api-http`里面设置的保持一致 - -`verifyKey`:密钥,默认yirimirai,与`mirai-api-http`里面设置的保持一致 - -`qq`:设置机器人QQ号,与当前mirai登录的机器人的QQ号保持一致 - -```json -{ - "adapter": "nakuru", - "enable": false, - "host": "127.0.0.1", - "ws_port": 8080, - "http_port": 5700, - "token": "" -}, -``` - -`"adapter": "nakuru",`,无需动,表明是接入`go-cqhttp`的配置 - -`enable`:是否启用,`true`开启 - -`host`:主机地址,一般不动 - - `ws_port`:正向WS服务器监听地址,与`go-cqhttp`的`config.yml`里面的保持一致 - - `http_port`:http服务器监听地址,与`go-cqhttp`的`config.yml`里面的保持一致 - - `token`:验证密钥,,与`go-cqhttp`的`config.yml`里面的保持一致 - -```json -{ - "adapter": "aiocqhttp", - "enable": false, - "host": "127.0.0.1", - "port": 8080 -}, -``` - -`"adapter": "aiocqhttp",`,无需动,表示是接入`shamrock等onebot协议实现的机器人框架`的配置 - -`enable`:是否启用,`true`开启 - -`host`:主机地址,一般不动 - -`port`:设置端口,默认8080,与对应框架里面设置的保持一致 - -```json -{ - "adapter": "qq-botpy", - "enable": false, - "appid": "", - "secret": "", - "intents": [ - "public_guild_messages", - "direct_message" - ] -} -``` - -`"adapter": "qq-botpy",`,无需动,表明是接入`QQ官方机器人`的配置 - -`enable`:是否启用,`true`开启 - -`appid`:申请到的QQ官方机器人的appid - -`secret`:申请到的QQ官方机器人的secret - -`intents`:控制监听的事件类型,`public_guild_messages` 频道消息`direct_message` 频道私聊消息 `public_messages` Q群消息(需要权限) - -### 是否跟踪内容函数调用过程 - -```json -"track-function-calls": true, -``` - -是否跟踪内容函数调用过程,如果开启了,在对话中调用的函数记录也会发给用户 - -关闭后仅会发给用户最终结果 - - - -### 群内回复时是否引用原消息 - -```json -"quote-origin": false, -``` - - - -### 群内回复时是否at原用户 - -```json -"at-sender": false, -``` - - - -### 强制消息延迟范围 - -```json -"force-delay": [0, 0], -``` - -强制消息延迟范围,以防风控,单位是秒。 - -### 长消息处理策略 - -```json -"long-text-process": { - "threshold": 256, - "strategy": "forward", - "font-path": "" -}, -``` - -`threshold`:阈值,文字长度大于此值的消息会使用长消息处理策略 - -`strategy`:长消息处理策略,目前支持forward和image - -`font-path`: image的渲染字体。未设置时,如果在windows下,会尝试寻找系统的微软雅黑字体,若找不到,则转为forward策略。未设置时,若不是windows系统,则直接转为forward策略。 - -### 是否向用户隐藏AI的异常信息 - -``` -"hide-exception-info": true -``` - - 是否向用户隐藏AI的异常信息,如果为true,当请求AI出现异常时,会返回一个错误的提示给用户。而把报错详情输出在控制台。 ## plugin-settings.json @@ -456,156 +75,3 @@ QChatGPT 3.0新引入的概念,平台适配器获取到消息事件之后, `priority`: 插件运行优先级,在初始化、事件调用时,高优先级的插件将优先被处理 `enabled`:设置为false时,不会初始化,也不会被调用 - -## provider.json - -配置提供AI聊天接口的信息 - -```json -"enable-chat": true, -``` - -`enable-chat`:是否开启AI聊天功能 - -```json -"openai-config": { - "api-keys": [ - "sk-1234567890" - ], - "base_url": "https://api.openai.com/v1", - "chat-completions-params": { - "model": "gpt-3.5-turbo" - }, - "request-timeout": 120 -}, -``` - -`api-keys`:以列表的形式设置若干个api key - -`base_url`:设置接口地址,后面一定要加`/v1` - -`model`:选择模型 - -`request-timeout`:设置请求超时时间,以秒为单位,对于耗时较长的模型,建议设置较大值 - -```json -"prompt-mode": "normal", -"prompt": { - "default": "如果用户之后想获取帮助,请你说”输入!help获取帮助“。" -} -``` - -`prompt-mode`:设置人格预设模式,值为`normal`和`full-scenario` - -`normal`时,使用下面的`prompt`,可设置多个 - -```json -"prompt": { - "default": "如果用户之后想获取帮助,请你说”输入!help获取帮助“。", - "help": "如果用户之后想获取帮助,请你说”输入!help获取帮助“。" -} -``` - -在使用中通过 - -`!reset <预设名>`指令加载,或使用`!default <预设名>`指令将其设为默认 - -## scenario-template.json - -data/scenario 目录下情景预设的模版 - -```json -{ - "prompt": [ - { - "role": "system", - "content": "You are a helpful assistant. 如果我需要帮助,你要说“输入!help获得帮助”" - }, - { - "role": "assistant", - "content": "好的,我是一个能干的AI助手。 如果你需要帮助,我会说“输入!help获得帮助”" - } - ] -} -``` - -如果你要创建新的人格预设,那么在`data/scenario` 新建一个文件,文件名后边要用,一个情景在一个文件 - -使用中通过 - -`!reset <文件名>`指令加载,或使用`!default <文件名>`指令将其设为默认 - -## sensitive-words.json - -没什么好说的,就是敏感词词库 - -## system.json - -设置一下系统信息,如管理员、网络代理、是否上报遥测数据供开发者分析、日志等级、会话消息处理并发数、流水线消息处理并发数、帮助消息 - -```json -"admin-sessions": [], -``` - -`admin-sessions`:设置管理员会话,格式为 {type}_{id},type 为 "group" 或 "person",如: - -```json -"admin-sessions": ["group_123456789", "person_123456789"], -``` - -```json -"network-proxies": { - "http": null, - "https": null -}, -``` - -`network-proxies`:设置网络代理,为正向代理,http和https都要填,例如 - -```json -"network-proxies": { - "http": 127.0.0.1:7890, - "https": 127.0.0.1:7890 -}, -``` - -正向代理也可以用环境变量设置:http_proxy 和 https_proxy - -```json -"report-usage": true, -``` - -`report-usage`:是否上报遥测数据供开发者分析,不包含敏感信息 - -```json -"logging-level": "info", -``` - -`logging-level`:暂时没用,现在只能通过环境变量 DEBUG=true 来设置调试日志输出 - -```json -"session-concurrency": { - "default": 1 -}, -``` - -`session-concurrency`:会话消息处理并发数,粒度是每个会话,session格式为 {type}_{id},未指定的session使用 default 配置 - -```json -"pipeline-concurrency": 20, -``` - -`pipeline-concurrency`:流水线消息处理并发数,粒度是整个程序 - -```json -"help-message": "QChatGPT - 😎高稳定性、🧩支持插件、🌏实时联网的 ChatGPT QQ 机器人🤖\n链接:https://q.rkcn.top" -``` - -`help-message`:帮助消息,用户发送!help 命令时的输出 - -## 提出建议 - -:::tip -欢迎广大用户积极提出意见和建议,帮助我们进一步改善 -::: - diff --git a/src/posts/config/README.md b/src/posts/config/README.md new file mode 100644 index 000000000..e0659402c --- /dev/null +++ b/src/posts/config/README.md @@ -0,0 +1,13 @@ +--- +head: + - - meta + - name: keywords + content: ChatGPT QQ机器人教程,QChatGPT项目部署教程 +title: 配置文件详解 +icon: blog +author: Lazy +date: 2024-02-18 +index: false +--- + +配置文件均位于 `data/config/` 目录下,请点击左侧目录查看各个文件的详细配置项。 \ No newline at end of file diff --git a/src/posts/config/command.md b/src/posts/config/command.md new file mode 100644 index 000000000..61753c5f6 --- /dev/null +++ b/src/posts/config/command.md @@ -0,0 +1,40 @@ +--- +head: + - - meta + - name: keywords + content: command.json 配置文件 +title: command.json 配置项 +icon: blog +order: 4 +author: RockChinQ +date: 2024-02-18 +category: + - 配置文件 +--- + +:::info 目录 +[[toc]] +::: + +`data/config/command.json` 中配置命令相关的配置项。 + +## 命令权限 privilege + +设置每个命令的权限配置 + +普通用户权限级别为 1,管理员(`system.json`中设置的)权限级别为 2。 + +在这里设置每个命令的最低权限级别,若设置为1,则用户和管理员均可用,若为2,则仅管理员可用 + + 需要设置子命令,以点号间隔,如`"plugin.on"` 示例: + +```json +{ + "plugin": 1, + "plugin.on": 2 +} +``` + + 意思是 plugin 命令的最低权限级别为 1,plugin.on 命令的最低权限级别为 2。 每个命令都有默认的权限级别 + +若不设置,则使用默认的级别。在`pkg/command/operators`里每个命令类有默认的权限级别 diff --git a/src/posts/config/pipeline.md b/src/posts/config/pipeline.md new file mode 100644 index 000000000..0ed31805c --- /dev/null +++ b/src/posts/config/pipeline.md @@ -0,0 +1,172 @@ +--- +head: + - - meta + - name: keywords + content: pipeline.json 配置文件 +title: pipeline.json 配置项 +icon: blog +order: 2 +author: RockChinQ +date: 2024-02-18 +category: + - 配置文件 +--- + +:::info 目录 +[[toc]] +::: + +`data/config/pipeline.json` 配置程序处理一个请求的过程中的操作流程,平台适配器获取到消息事件之后,发送给pipeline排队进行处理。可以设置黑白名单、群响应规则、是否检查传入消息、传入消息忽略规则、是否检查敏感词、百度云内容审核配置、传入消息长度设置、限速配置等功能。 + + +## 访问控制 access-control + +```json +"access-control":{ + "mode": "blacklist", + "blacklist": [], + "whitelist": [] +}, +``` + +`mode`:设置模式白名单 `whitelist`(仅处理`whitelist`列表中的会话的消息)或黑名单 `blacklist`(忽略`blacklist`列表中的会话的消息) + +`blacklist`:格式`{type}_{id}`,示例:`"blacklist": [group_12345678,person_12341234],` + +`whitelist`:格式`{type}_{id}`,示例:`"whitelist": [group_12345678,person_12341234]` + + +## 群消息响应规则 respond-rules + +仅处理`access-control`通过的会话的消息,其中可含有多个key,若要对特定群设置响应规则,则以群号作为键。未特指的群,将使用 default 中的响应规则 + +```json +"respond-rules": { + "default": { + "at": true, + "prefix": [ + "/ai", "!ai", "!ai", "ai" + ], + "regexp": [], + "random": 0.0 + } +}, +``` + +`at`:`true`或`false`,设置@响应 + +`prefix`:设置响应前缀 + +`regexp`:正则匹配 + +`random`:随机匹配,为1时所有消息都响应 + +你可以为单个群聊设置特定的响应规则,例如 + +```json +"respond-rules": { + "default": { + "at": true, + "prefix": [ + "/ai", "!ai", "!ai", "ai" + ], + "regexp": [], + "random": 0.0 + }, + "123456":{ + "at": true, + "prefix": [ + "/ai", "!ai", "!ai", "ai" + ], + "regexp": [], + "random": 0.0 + }, + "789012":{ + "at": true, + "prefix": [ + "/ai", "!ai", "!ai", "ai" + ], + "regexp": [], + "random": 0.0 + } +}, +``` + +## 检查传入消息内容开关 income-msg-check + +```json +"income-msg-check": true, +``` + +`income-msg-check`:是否检查传入的消息 + +## 传入消息忽略规则 ignore-rules + +```json +"ignore-rules": { + "prefix": ["/"], + "regexp": [] +}, +``` + +符合规则的传入消息将被忽略,仅`income-msg-check`为`true`时生效 + +`prefix`:前缀为`/`的忽略 + +`regexp`:正则匹配的忽略 + +## 本地敏感词检查 check-sensitive-words + +```json +"check-sensitive-words": true, +``` + +`check-sensitive-words`:是否检查敏感词,敏感词词库为`data/config/sensitive-words.json`里面的 + +## 百度云内容审核配置 baidu-cloud-examine + +```json +"baidu-cloud-examine": { + "enable": false, + "api-key": "", + "api-secret": "" +}, +``` + +`baidu-cloud-examine`:控制是否使用是否进行百度云内容审核 + +`enable`:enable=true时启用,一定会检查AI响应结果,仅`income-msg-check`为true时检查传入消息 + +`api-key`:百度AI开放平台的`API_KEY` + +`api-secret`:百度AI开放平台的`SECRET_KEY` + +*`API_KEY`与`SECRET_KEY`是在创建完毕应用后,系统分配给用户的,均为字符串,用于标识用户,为访问做签名验证,可在AI服务控制台中的**应用列表**中查看* + +## 传入消息长度设置 submit-messages-tokens + +```json +"submit-messages-tokens": 3072, +``` + +`submit-messages-tokens`:传给模型的消息长度限制,不同模型有不同的token数限制,QChatGPT 内部会保存各个模型的(约)最大token数限制 + + 与此值取最小值,在传给模型API之前对当前会话的历史消息进行截断 + +## 请求限速规则 rate-limit + +```json +"rate-limit": { + "strategy": "drop", + "algo": "fixwin", + "fixwin": { + "default": 60 + } +} +``` + +`strategy`:会话中的请求速率超过限制时的处理策略,`drop`为丢弃新请求,`wait`为等待请求速率降到限制以下 + +`algo`: 使用的算法,目前仅支持 `fixwin` (固定窗口),即一分钟内最多处理多少个请求 + +`fixwin`:具体速率设置,一分钟内最多处理多少个请求, 支持对特定session指定限速,格式为 {type}_{id},示例:group_12345678,person_12341234 \ No newline at end of file diff --git a/src/posts/config/platform.md b/src/posts/config/platform.md new file mode 100644 index 000000000..02e13c741 --- /dev/null +++ b/src/posts/config/platform.md @@ -0,0 +1,147 @@ +--- +head: + - - meta + - name: keywords + content: platform.json 配置文件 +title: platform.json 配置项 +icon: blog +order: 1 +author: RockChinQ +date: 2024-02-18 +category: + - 配置文件 +--- + +:::info 目录 +[[toc]] +::: + +`data/config/platform.json` 配置程序连接的消息平台和相关消息处理配置项。启用的消息适配器列表,是否跟踪内容函数调用过程,群内回复时是否引用原消息,群内回复时是否at原用户,强制消息延迟范围,长消息处理策略,是否向用户隐藏AI的异常信息等。 + +## 消息平台适配器 platform-adapters + +```json +"platform-adapters": [ + { + "adapter": "yiri-mirai", + "enable": false, + "host": "127.0.0.1", + "port": 8080, + "verifyKey": "yirimirai", + "qq": 123456789 + }, + { + "adapter": "nakuru", + "enable": false, + "host": "127.0.0.1", + "ws_port": 8080, + "http_port": 5700, + "token": "" + }, + { + "adapter": "aiocqhttp", + "enable": false, + "host": "127.0.0.1", + "port": 8080 + }, + { + "adapter": "qq-botpy", + "enable": false, + "appid": "", + "secret": "", + "intents": [ + "public_guild_messages", + "direct_message" + ] + } +], +``` + +目前支持 `mirai`、`go-cqhttp`、`aiocqhttp`、`qq-botpy` 四种消息平台适配器,也可以同时启用多个同种类或不同种类的平台适配器。 +各个适配器的配置方式请查看[部署教程](../deploy/config)。 + +### 多开示例 + +```json +"platform-adapters": [ + { + "adapter": "yiri-mirai", + "enable": true, + "host": "127.0.0.1", + "port": 8080, + "verifyKey": "yirimirai", + "qq": 123456789 + }, + { + "adapter": "nakuru", + "enable": true, + "host": "127.0.0.1", + "ws_port": 8081, + "http_port": 5701, + "token": "token" + } +] +``` + +## 跟踪内容函数调用 track-function-calls + +```json +"track-function-calls": true, +``` + +是否跟踪内容函数调用过程,如果开启了,在对话中调用的内容函数记录也会发给用户 + +关闭后(false)仅会发给用户最终结果 + +> 内容函数功能请查看插件功能文档。 + + +## 引用原消息 quote-origin + +```json +"quote-origin": false, +``` + +在群内回复时是否引用原消息 + +## 是否at原用户 at-sender + +```json +"at-sender": false, +``` + +在群内回复时是否at原用户 + +## 强制消息延迟范围 force-delay + +```json +"force-delay": [0, 0], +``` + +在将响应内容发回给用户前的强制消息延迟时间范围,以防风控,单位是秒。 + +## 长消息处理策略 long-text-process + +```json +"long-text-process": { + "threshold": 256, + "strategy": "forward", + "font-path": "" +}, +``` + +`threshold`:阈值,文字长度大于此值的消息会使用长消息处理策略 + +`strategy`:长消息处理策略,目前支持forward(转发消息组件)和image(文字转图片) + +`font-path`: image的渲染字体。未设置时,如果在windows下,会尝试寻找系统的微软雅黑字体,若找不到,则转为forward策略。未设置时,若不是windows系统,则直接转为forward策略。 + +## 向用户隐藏AI接口的异常信息 hide-exception-info + +``` +"hide-exception-info": true +``` + + 是否向用户隐藏AI的异常信息,如果为true,当请求AI接口出现异常时,会返回一个错误的提示给用户。而把报错详情输出在控制台。 + + diff --git a/src/posts/config/provider.md b/src/posts/config/provider.md new file mode 100644 index 000000000..475df8b1d --- /dev/null +++ b/src/posts/config/provider.md @@ -0,0 +1,102 @@ +--- +head: + - - meta + - name: keywords + content: provider.json 配置文件 +title: provider.json 配置项 +icon: blog +order: 3 +author: RockChinQ +date: 2024-02-18 +category: + - 配置文件 +--- + + +:::info 目录 +[[toc]] +::: + +`data/config/provider.json` 中配置AI接口提供商相关的配置项。 + +## 启用聊天功能 enable-chat + +```json +"enable-chat": true, +``` + +`enable-chat`:是否开启AI聊天功能 + +## OpenAI 接口配置 openai-config + +```json +"openai-config": { + "api-keys": [ + "sk-1234567890" + ], + "base_url": "https://api.openai.com/v1", + "chat-completions-params": { + "model": "gpt-3.5-turbo" + }, + "request-timeout": 120 +}, +``` + +`api-keys`:以列表的形式设置若干个api key + +`base_url`:设置接口地址,后面一定要加`/v1` + +`model`:填写要使用的模型名称。通常来说直接填写模型名称即可,但如果要使用原生接口不是 ChatCompletion 但以 ChatCompletion 接口格式接入的模型,请在模型名称前方加一个 `OneAPI/` 前缀以进行区分。 +简单来说可以认为是:现阶段非 OpenAI 的模型接入都需要在模型名称前方加一个 `OneAPI/` 前缀。 + +例如: +1. 通过 OneAPI 等中转服务接入了 OpenAI 的 `gpt-4` 模型,由于 `gpt-4` 也是使用 ChatCompletion 接口格式进行请求,则可以直接填入 `gpt-4`; +2. 通过 OneAPI 等中转服务接入了 Google 的 `gemini-pro` 模型,由于 `gemini-pro` 原生接口格式并非 ChatCompletion,因此需要填入 `OneAPI/gemini-pro`。 + + +`request-timeout`:设置请求超时时间,以秒为单位,对于耗时较长的模型,建议设置较大值 + +## 情景预设(人格) prompt + +```json +"prompt-mode": "normal", +"prompt": { + "default": "如果用户之后想获取帮助,请你说”输入!help获取帮助“。" +} +``` + +`prompt-mode`:设置情景预设模式,值为`normal`(单预设模式)和`full-scenario`(完整历史对话模式) + +`normal`时,使用下面的`prompt`,可设置多个 + +```json +"prompt": { + "default": "如果用户之后想获取帮助,请你说”输入!help获取帮助“。", + "help": "如果用户之后想获取帮助,请你说”输入!help获取帮助“。" +} +``` + +在使用中通过`!default <预设名>`指令将其设为默认 + +### full-scenario模式配置方法 + +把完整的历史对话以文件形式添加到`data/scenario/`目录下,参考`data/scenario/default.json` + +```json +{ + "prompt": [ + { + "role": "system", + "content": "You are a helpful assistant. 如果我需要帮助,你要说“输入!help获得帮助”" + }, + { + "role": "assistant", + "content": "好的,我是一个能干的AI助手。 如果你需要帮助,我会说“输入!help获得帮助”" + } + ] +} +``` + +`role` 为消息的角色,可以是`user`(用户)、`assistant`(AI)、`system`(系统) +`content` 为字符串,表示消息内容。 +在使用中通过`!default <文件名>`指令将其设为默认 diff --git a/src/posts/config/sensitive-words.md b/src/posts/config/sensitive-words.md new file mode 100644 index 000000000..93d52fbce --- /dev/null +++ b/src/posts/config/sensitive-words.md @@ -0,0 +1,15 @@ +--- +head: + - - meta + - name: keywords + content: sensitive-words.json 配置文件 +title: sensitive-words.json 配置项 +icon: blog +order: 5 +author: RockChinQ +date: 2024-02-18 +category: + - 配置文件 +--- + +本地敏感词词库,参考 `data/config/sensitive-words.json` 内容进行修改即可。 \ No newline at end of file diff --git a/src/posts/config/system.md b/src/posts/config/system.md new file mode 100644 index 000000000..a484725e4 --- /dev/null +++ b/src/posts/config/system.md @@ -0,0 +1,95 @@ +--- +head: + - - meta + - name: keywords + content: system.json 配置文件 +title: system.json 配置项 +icon: blog +order: 6 +author: RockChinQ +date: 2024-02-18 +category: + - 配置文件 +--- + +:::info 目录 +[[toc]] +::: + + + +`data/config/system.json` 中配置系统设置,如管理员、网络代理、是否上报遥测数据供开发者分析、日志等级、会话消息处理并发数、流水线消息处理并发数、帮助消息等 + +## 管理员会话 admin-sessions + +```json +"admin-sessions": [], +``` + +`admin-sessions`:设置管理员会话,格式为 {type}_{id},type 为 "group" 或 "person",如: + +```json +"admin-sessions": ["group_123456789", "person_123456789"], +``` + +## 网络代理 network-proxies + +```json +"network-proxies": { + "http": null, + "https": null +}, +``` + +`network-proxies`:设置网络代理,为正向代理,http和https都要填,例如 + +```json +"network-proxies": { + "http": 127.0.0.1:7890, + "https": 127.0.0.1:7890 +}, +``` + +正向代理也可以用环境变量设置:http_proxy 和 https_proxy + +## 上报遥测数据 report-usage + +```json +"report-usage": true, +``` + +`report-usage`:是否上报遥测数据供开发者分析,不包含敏感信息 + +## 日志等级 logging-level + +```json +"logging-level": "info", +``` + +`logging-level`:暂时没用,现在只能通过环境变量 DEBUG=true 来设置调试日志输出 + +## 会话消息处理并发数 session-concurrency + +```json +"session-concurrency": { + "default": 1 +}, +``` + +`session-concurrency`:会话消息处理并发数,粒度是每个会话,session格式为 {type}_{id},未指定的session使用 default 配置 + +## 流水线消息处理并发数 pipeline-concurrency + +```json +"pipeline-concurrency": 20, +``` + +`pipeline-concurrency`:流水线消息处理并发数,粒度是整个程序,目前使用 FCFS 算法调度各个请求。 + +## 帮助消息 help-message + +```json +"help-message": "QChatGPT - 😎高稳定性、🧩支持插件、🌏实时联网的 ChatGPT QQ 机器人🤖\n链接:https://q.rkcn.top" +``` + +`help-message`:帮助消息,用户发送 !help 命令时的输出 diff --git a/src/posts/deploy/README.md b/src/posts/deploy/README.md index 1711509fc..a5da29d1e 100644 --- a/src/posts/deploy/README.md +++ b/src/posts/deploy/README.md @@ -9,9 +9,6 @@ author: Lazy date: 2024-02-18 index: false --- -:::info 目录 -[[toc]] -::: ## 部署教程: diff --git a/src/posts/deploy/config.md b/src/posts/deploy/config.md index 879a5e465..1f49a89aa 100644 --- a/src/posts/deploy/config.md +++ b/src/posts/deploy/config.md @@ -9,7 +9,7 @@ author: Lazy date: 2024-02-18 --- -修改以下配置文件即可启用 QChatGPT 的基本功能,更多的配置项详解请查看[配置详解](../config-intro.md)。 +修改以下配置文件即可启用 QChatGPT 的基本功能,更多的配置项详解请查看[配置详解](../config)。 - `data/config/platform.json` - `data/config/provider.json` @@ -123,7 +123,7 @@ date: 2024-02-18 ## provider.json -修改此配置文件以设置所连接的 AI 提供商的相关信息,仅讲解必要的配置项,更多的配置项详解请查看[配置详解](../config-intro.md)。 +修改此配置文件以设置所连接的 AI 提供商的相关信息,仅讲解必要的配置项,更多的配置项详解请查看[配置详解](../config)。 ```json "openai-config": { diff --git a/src/posts/plugin-develop.md b/src/posts/plugin-develop.md index 6f21c53cf..81627a702 100644 --- a/src/posts/plugin-develop.md +++ b/src/posts/plugin-develop.md @@ -428,43 +428,6 @@ NormalMessageResponded = "normal_message_responded" reply: list 替换回复消息组件列表 """ -SessionFirstMessageReceived = "session_first_message_received" -"""会话被第一次交互时触发 - kwargs: - session_name: str 会话名称(_) - session: pkg.openai.session.Session 会话对象 - default_prompt: str 预设值 -""" - -SessionExplicitReset = "session_reset" -"""会话被用户手动重置时触发,此事件不支持阻止默认行为 - kwargs: - session_name: str 会话名称(_) - session: pkg.openai.session.Session 会话对象 -""" - -SessionExpired = "session_expired" -"""会话过期时触发 - kwargs: - session_name: str 会话名称(_) - session: pkg.openai.session.Session 会话对象 - session_expire_time: int 已设置的会话过期时间(秒) -""" - -KeyExceeded = "key_exceeded" -"""api-key超额时触发 - kwargs: - key_name: str 超额的api-key名称 - usage: dict 超额的api-key使用情况 - exceeded_keys: list[str] 超额的api-key列表 -""" - -KeySwitched = "key_switched" -"""api-key超额切换成功时触发,此事件不支持阻止默认行为 - kwargs: - key_name: str 切换成功的api-key名称 - key_list: list[str] api-key列表 -""" PromptPreProcessing = "prompt_pre_processing" # 于v2.5.1加入 """每回合调用接口前对prompt进行预处理时触发,此事件不支持阻止默认行为 @@ -472,12 +435,10 @@ PromptPreProcessing = "prompt_pre_processing" # 于v2.5.1加入 session_name: str 会话名称(_) default_prompt: list 此session使用的情景预设内容 prompt: list 此session现有的prompt内容 - text_message: str 用户发送的消息文本 - + returns (optional): default_prompt: list 修改后的情景预设内容 prompt: list 修改后的prompt内容 - text_message: str 修改后的消息文本 """ ```