diff --git a/README.md b/README.md index c820ef7..67c3000 100644 --- a/README.md +++ b/README.md @@ -60,10 +60,14 @@ sudo apt-get install ffmpeg 其他玩法见官方文档 -## ✍️ 官方文档 & 其他玩法 +## ✍️ 官方文档 & 其他玩法 & AI 文档问答 > [👉 点击进入](https://zhiyu1998.github.io/rconsole-plugin/) +相关问题可以问我创建的 GLM 智能体: + + + ## 🤺 R插件交流群 @@ -119,4 +123,4 @@ sudo apt-get install ffmpeg ## 📃 日志 ![Alt](https://repobeats.axiom.co/api/embed/42b5a7769074be124bd9ab02456897e37d1581f1.svg "Repobeats analytics image") -[![zhiyu/rconsole-plugin](https://gitee.com/kyrzy0416/rconsole-plugin/widgets/widget_card.svg?colors=4183c4,ffffff,ffffff,e3e9ed,666666,9b9b9b)](https://gitee.com/kyrzy0416/rconsole-plugin) \ No newline at end of file +[![zhiyu/rconsole-plugin](https://gitee.com/kyrzy0416/rconsole-plugin/widgets/widget_card.svg?colors=4183c4,ffffff,ffffff,e3e9ed,666666,9b9b9b)](https://gitee.com/kyrzy0416/rconsole-plugin) diff --git a/apps/query.js b/apps/query.js index e8459b5..67db42b 100644 --- a/apps/query.js +++ b/apps/query.js @@ -3,24 +3,11 @@ import _ from "lodash"; import fetch from "node-fetch"; // 常量 import { CAT_LIMIT, COMMON_USER_AGENT } from "../constants/constant.js"; -import { - LINUX_AI_PROMPT, - LINUX_QUERY, - RDOC_AI_PROMPT, - RDOC_LINK, - REDIS_YUNZAI_LINUX, - REDIS_YUNZAI_RDOC -} from "../constants/query.js"; +import { LINUX_AI_PROMPT, LINUX_QUERY, REDIS_YUNZAI_LINUX } from "../constants/query.js"; // 配置文件 import config from "../model/config.js"; -import { deepSeekChat, llmRead } from "../utils/llm-util.js"; import { OpenaiBuilder } from "../utils/openai-builder.js"; -import { - redisExistAndGetKey, - redisExistAndInsertObject, - redisExistAndUpdateObject, - redisSetKey -} from "../utils/redis-util.js"; +import { redisExistAndGetKey, redisExistAndInsertObject, redisExistAndUpdateObject } from "../utils/redis-util.js"; import { textArrayToMakeForward } from "../utils/yunzai-util.js"; export class query extends plugin { @@ -59,10 +46,6 @@ export class query extends plugin { { reg: "^#(linux|Linux)(.*)", fnc: "linuxQuery" - }, - { - reg: "^#R文档(.*)", - fnc: "intelligentDoc", } ], }); @@ -355,45 +338,6 @@ export class query extends plugin { return parsedData; } - async intelligentDoc(e) { - const question = e.msg.replace("#R文档", "").trim(); - const rPluginDocument = await redisExistAndGetKey(REDIS_YUNZAI_RDOC); - if (question === "") { - e.reply("请输入要查询的文档内容!\n例如:#R文档 如何玩转BBDown"); - return; - } else if (question === "更新" || rPluginDocument?.content === undefined) { - // 权限判定 - if (!e.isMaster) { - e.reply("请让管理员发送以进行初始化,或者让管理员进行更新!"); - return; - } - e.reply("更新文档中..."); - const content = await llmRead(RDOC_LINK); - await redisSetKey(REDIS_YUNZAI_RDOC, { - content - }) - e.reply("文档更新完成!"); - } - let kimiAns, model = "DeepSeek"; - if (this.aiBaseURL && this.aiApiKey) { - const builder = await new OpenaiBuilder() - .setBaseURL(this.aiBaseURL) - .setApiKey(this.aiApiKey) - .setModel(this.aiModel) - .setPrompt(rPluginDocument) - .build(); - const kimiResp = await builder.kimi(RDOC_AI_PROMPT.replace("{}", question)); - kimiAns = kimiResp.ans; - model = kimiResp.model; - } else { - logger.info(RDOC_AI_PROMPT.replace("{}", question)); - kimiAns = await deepSeekChat(RDOC_AI_PROMPT.replace("{}", question), rPluginDocument.content); - } - const Msg = await Bot.makeForwardMsg(textArrayToMakeForward(e, [`「R插件 x ${ model }」联合为您总结内容:`, kimiAns])); - await e.reply(Msg); - return; - } - // 删除标签 removeTag(title) { const titleRex = /<[^>]+>/g; diff --git a/constants/query.js b/constants/query.js index 2257dd8..d9cbc8c 100644 --- a/constants/query.js +++ b/constants/query.js @@ -4,8 +4,6 @@ */ export const LINUX_QUERY = "https://api.pearktrue.cn/api/linux/?keyword={}"; -export const RDOC_LINK = "https://gitee.com/kyrzy0416/rconsole-plugin/raw/docs/posts/QA%E5%AE%98%E6%96%B9%E8%A7%A3%E7%AD%94.md"; - export const LINUX_AI_PROMPT = "- Role: Linux命令专家\n" + "- Background: 用户需要从特定的Linux命令网站获取常见命令的用法,希望得到简洁明了的回复。\n" + "- Profile: 你是一位对Linux命令有深入理解的专家,能够快速从网站中提取关键信息,并以简洁的方式呈现给用户。\n" + @@ -24,22 +22,8 @@ export const LINUX_AI_PROMPT = "- Role: Linux命令专家\n" + " - 例子3: 命令 'cp' — 复制文件或目录。\n" + "- Initialization: 在第一次对话中,请直接输出以下:您好!我是Linux命令专家,我将为您提供简洁明了的Linux命令用法。"; -export const RDOC_AI_PROMPT = "我有一些有关R插件的问题需要询问你,问题是:“{}”,回答的时候尽量大部分内容都来自文档,比如:询问你关于“Apple Music 和 Spotify 使用说明”,你只需回答:“" + - "AM解析和Spotify解析需要使用两个依赖freyr、atomicparsley,现在只以Debian系统为例:\n" + - "npm install -g freyr\n" + - "# 或者你有yarn的话可以使用\n" + - "yarn global add freyr\n" + - "# 接着安装它的依赖\n" + - "apt-get install atomicparsley”"; - /** * Linux命令缓存 * @type {string} */ export const REDIS_YUNZAI_LINUX = "Yz:rconsole:query:linux"; - -/** - * 文档文档需要的数据 - * @type {string} - */ -export const REDIS_YUNZAI_RDOC = "Yz:rconsole:query:rdoc";