diff --git a/apps/tools.js b/apps/tools.js index 25387e1..9f7d1c5 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -191,7 +191,7 @@ export class tools extends plugin { fnc: "freyr" }, { - reg: "(mp.weixin|arxiv.org|sspai.com|chinadaily.com.cn|zhihu.com)", + reg: "(^#总结一下(http|https):\/\/.*|mp.weixin|arxiv.org|sspai.com|chinadaily.com.cn|zhihu.com)", fnc: "linkShareSummary" }, { @@ -1728,7 +1728,15 @@ export class tools extends plugin { // 链接总结 async linkShareSummary(e) { - const { name, summaryLink } = contentEstimator(e.msg); + let name, summaryLink; + + if (e.msg.startsWith("#总结一下")) { + name = "网页总结"; + summaryLink = e.msg.replace("#总结一下", ""); // 如果需要进一步处理 summaryLink,可以在这里添加相关逻辑 + } else { + ({ name: name, summaryLink: summaryLink } = contentEstimator(e.msg)); + } + // 判断是否有总结的条件 if (_.isEmpty(this.aiApiKey) || _.isEmpty(this.aiApiKey)) { // e.reply(`没有配置 Kimi,无法为您总结!${ HELP_DOC }`) @@ -1745,7 +1753,8 @@ export class tools extends plugin { const { ans: kimiAns, model } = await builder.kimi(summaryLink); // 计算阅读时间 const stats = estimateReadingTime(kimiAns); - e.reply(`当前 ${ name } 预计阅读时间: ${ stats.minutes } 分钟,总字数: ${ stats.words }`) + const titleMatch = kimiAns.match(/(Title|标题)([::])\s*(.*?)\n/)?.[3]; + e.reply(`《${ titleMatch }》 预计阅读时间: ${ stats.minutes } 分钟,总字数: ${ stats.words }`) const Msg = await Bot.makeForwardMsg(textArrayToMakeForward(e, [`「R插件 x ${ model }」联合为您总结内容:`, kimiAns])); await e.reply(Msg); return true; @@ -1760,7 +1769,7 @@ export class tools extends plugin { */ async tempSummary(name, summaryLink, e) { const llmCrawler = await fetch(PearAPI_CRAWLER.replace("{}", summaryLink)); - const content = (await llmCrawler.json())?.data; + const content = await (await llmCrawler.json())?.data; const titleMatch = content.match(/Title:\s*(.*?)\n/)?.[1]; e.reply(`${ this.identifyPrefix } 识别:${ name } - ${titleMatch},正在为您总结,请稍等...`, true); const deepseekFreeSummary = await fetch(PearAPI_DEEPSEEK, { diff --git a/constants/constant.js b/constants/constant.js index 7fbd98e..d4d75fb 100644 --- a/constants/constant.js +++ b/constants/constant.js @@ -104,7 +104,36 @@ export const BILI_DEFAULT_INTRO_LEN_LIMIT = 50; * 总结的prompt * @type {string} */ -export const SUMMARY_PROMPT = `请返回您仔细阅读正文后精心写成的详尽笔记,如果是ArXiv论文就简要介绍下内容和创新点即可` +export const SUMMARY_PROMPT = `# Role: Web Content Summarization Assistant + +## Profile +- author: R-plugin +- version: 1.0 +- language: 中文 +- description: An AI assistant specialized in summarizing web content, capable of extracting key points, summarizing articles, and providing concise overviews of complex topics. + +## Skills +1. Proficient in natural language understanding and summarization techniques. +2. Ability to extract key information from a variety of web content formats (articles, blogs, reports). +3. Capable of summarizing both short and long-form content. +4. Adaptive to different writing styles and tones. + +## Rules +1. Ensure the summary captures the main ideas and key points of the webpage. +2. The summary should be concise, clear, and accurate, avoiding unnecessary details. +3. Adapt the summary length and detail based on the complexity and length of the original content. +4. Preserve the context and intent of the original content without adding personal interpretation. + +## Workflows +1. Analyze the structure and main sections of the webpage. +2. Identify and extract key points, arguments, or information from the content. +3. Firstly, generate a title with the format constraint: "title: {title}". +4. Then, Generate a concise summary that includes the most important details. +5. Next, create a "Key Paragraph" that includes what you consider to be some of the critical information points from the article, each key point preceded by an emoji. +6. Finally, Review the summary for accuracy and completeness. Don't include the URL of the current webpage in the summary review. + +## Init +在第一次对话中,请直接输出以下:您好!我将联合R插件为您提供简洁明了的网页内容。` /** * 图片翻译 prompt @@ -163,4 +192,4 @@ export const DOWNLOAD_WAIT_DETECT_FILE_TIME = 3000; * 短链接接口 * @type {string} */ -export const SHORT_LINKS = "https://smolurl.com/api/links"; \ No newline at end of file +export const SHORT_LINKS = "https://smolurl.com/api/links";