🎈 pref: 内容评估器优化

This commit is contained in:
zhiyu1998 2024-07-14 12:51:20 +08:00
parent dfb893b31d
commit 77940411ef
2 changed files with 20 additions and 18 deletions

View File

@ -1,3 +1,5 @@
import { contentEstimator } from "../utils/link-share-summary-util.js";
/**
* 用于百度翻译的常量控制
*
@ -85,12 +87,18 @@ export const TWITTER_BEARER_TOKEN = "";
*/
export const BILI_DEFAULT_INTRO_LEN_LIMIT = 50;
export const OCR_PROMPT = `
首先对将要用作替代文本的图像进行简短描述不要在描述中描述或提取文本
图片中提取的文本在适当的地方使用换行符如果文本被某物遮挡请使其不受阻隔以便阅读如果图像中没有文本只需回复描述不要包含任何其他信息
示例 文本编辑器中的代码行 const x = 5; const y = 10; const z = x + y; console.log(z);
`
export const SUMMARY_PROMPT = `请返回您仔细阅读正文后精心写成的详尽笔记如果是ArXiv论文就简要介绍下内容和创新点即可`
export const HELP_DOC = "\n文档https://gitee.com/kyrzy0416/rconsole-plugin"
/**
* 总结内容评估器的正则
* @type {{reg: RegExp, name: string}[]}
*/
export const SUMMARY_CONTENT_ESTIMATOR_PATTERNS = [
{ reg: /(?:https?:\/\/)?mp\.weixin\.qq\.com\/[A-Za-z\d._?%&+\-=\/#]*/, name: '微信文章' },
{ reg: /(?:https?:\/\/)?arxiv.org\/[a-zA-Z\d._?%&+\-=\/#]*/, name: 'ArXiv论文' },
{ reg: /(?:https?:\/\/)?sspai.com\/[a-zA-Z\d._?%&+\-=\/#]*/, name: '少数派' },
{ reg: /(?:https?:\/\/)?www\.bilibili\.com\/read\/[A-Za-z\d._?%&+\-=\/#]*/, name: '哔哩哔哩专栏' },
{ reg: /(?:https?:\/\/)?(www\.)chinadaily.com.cn\/a\/[a-zA-Z0-9\d._?%&+\-=\/#]*/, name: 'ChinaDaily' }
];

View File

@ -1,18 +1,12 @@
import { SUMMARY_CONTENT_ESTIMATOR_PATTERNS } from "../constants/constant.js";
/**
* 内容评估器
* @link {weixin}
* @link {linkShareSummary}
* @param link 链接
*/
export function contentEstimator(link) {
const patterns = [
{ reg: /(?:https?:\/\/)?mp\.weixin\.qq\.com\/[A-Za-z\d._?%&+\-=\/#]*/, name: '微信文章' },
{ reg: /(?:https?:\/\/)?arxiv.org\/[a-zA-Z\d._?%&+\-=\/#]*/, name: 'ArXiv论文' },
{ reg: /(?:https?:\/\/)?sspai.com\/[a-zA-Z\d._?%&+\-=\/#]*/, name: '少数派' },
{ reg: /(?:https?:\/\/)?www\.bilibili\.com\/read\/[A-Za-z\d._?%&+\-=\/#]*/, name: '哔哩哔哩专栏' },
{ reg: /(?:https?:\/\/)?(www\.)chinadaily.com.cn\/a\/[a-zA-Z0-9\d._?%&+\-=\/#]*/, name: 'ChinaDaily' }
];
for (const pattern of patterns) {
for (const pattern of SUMMARY_CONTENT_ESTIMATOR_PATTERNS) {
if (pattern.reg.test(link)) {
return {
name: pattern.name,