feat: 识图增加固定prompt

This commit is contained in:
zhiyu1998 2024-05-16 16:51:09 +08:00
parent 6c2748f703
commit bb32dbf66b
3 changed files with 13 additions and 4 deletions

View File

@ -7,7 +7,7 @@ import axios from "axios";
// url库
import url from 'url';
// 常量
import { CAT_LIMIT } from "../constants/constant.js";
import { CAT_LIMIT, OCR_PROMPT } from "../constants/constant.js";
// 配置文件
import config from "../model/index.js";
// 书库
@ -387,12 +387,15 @@ export class query extends plugin {
.setBaseURL(this.aiBaseURL)
.setApiKey(this.aiApiKey)
.setModel(this.aiModel)
.setPrompt(OCR_PROMPT)
.setPath(imgPath)
.build();
this.e.reply(`「R插件 x ${ model }」联合识别:\n${ ans }`);
const ocrAns = ans.split("▲");
logger.info(ocrAns)
this.e.reply(`「R插件 x ${ model }」联合识别:\n描述:${ ocrAns[1] } \nOCR识别结果${ ocrAns[2] }`);
await checkAndRemoveFile(filenameWithExtension);
} catch (err) {
e.reply("「R插件 x 月之暗面 Kimi」联合识别提醒你无法找到图片路径")
this.e.reply("「R插件 x 月之暗面 Kimi」联合识别提醒你无法找到图片路径")
logger.error(err);
}
return true;

View File

@ -84,3 +84,9 @@ export const TWITTER_BEARER_TOKEN = "";
* @type {number}
*/
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);
`

Binary file not shown.

Before

Width:  |  Height:  |  Size: 551 KiB

After

Width:  |  Height:  |  Size: 504 KiB