mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 13:57:10 +00:00
fix(bym): 提示词の优化
- 把原先的if换成`思维持` - 移动原先的获取表情包列表至ToDoimg.js
This commit is contained in:
parent
db3c7b55e9
commit
aee73e7683
2 changed files with 123 additions and 121 deletions
52
apps/bym.js
52
apps/bym.js
|
|
@ -17,12 +17,7 @@ import { JinyanTool } from '../utils/tools/JinyanTool.js'
|
||||||
import { KickOutTool } from '../utils/tools/KickOutTool.js'
|
import { KickOutTool } from '../utils/tools/KickOutTool.js'
|
||||||
import { SetTitleTool } from '../utils/tools/SetTitleTool.js'
|
import { SetTitleTool } from '../utils/tools/SetTitleTool.js'
|
||||||
import { SerpTool } from '../utils/tools/SerpTool.js'
|
import { SerpTool } from '../utils/tools/SerpTool.js'
|
||||||
import { getToimg, downImg } from '../utils/ToDoimg.js'
|
import { getToimg, downImg, fileImgList } from '../utils/ToDoimg.js'
|
||||||
|
|
||||||
import fs from "fs";
|
|
||||||
import pathModule from 'path';
|
|
||||||
const _path = process.cwd();
|
|
||||||
const path = _path + "/temp/tp-bq";
|
|
||||||
|
|
||||||
const DefaultConfig = {
|
const DefaultConfig = {
|
||||||
returnQQ: [],
|
returnQQ: [],
|
||||||
|
|
@ -118,12 +113,10 @@ export class bym extends plugin {
|
||||||
}
|
}
|
||||||
return [ChatsList, prop, NotfoGroup, MaxText]
|
return [ChatsList, prop, NotfoGroup, MaxText]
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
logger.info(`[bym]高贵man:${sender}已过滤~`)
|
logger.info(`[bym]高贵man:${sender}已过滤~`)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prop < 0) {
|
if (prop < 0) {
|
||||||
await bymGo()
|
await bymGo()
|
||||||
}
|
}
|
||||||
|
|
@ -157,18 +150,13 @@ export class bym extends plugin {
|
||||||
opt.image = base64Image.toString('base64')
|
opt.image = base64Image.toString('base64')
|
||||||
}
|
}
|
||||||
|
|
||||||
const picturesPath = pathModule.join(path, 'pictures');
|
|
||||||
const ImgList = await fs.promises.readdir(picturesPath);
|
|
||||||
const fileImgList = ImgList.map(filename => {
|
|
||||||
const match = filename.match(/\d{12}-(.+)$/);
|
|
||||||
return match ? match[1] : filename;
|
|
||||||
});
|
|
||||||
|
|
||||||
let ForRole = ALLRole
|
let ForRole = ALLRole
|
||||||
if (opt.image && !IsAtBot && !NotToImg && !e.at && Config.AutoToDownImg) {
|
if (opt.image && !IsAtBot && !NotToImg && !e.at && Config.AutoToDownImg) {
|
||||||
ALLRole = 'downimg'
|
ALLRole = 'downimg'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ImgList = await fileImgList()
|
||||||
|
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const DateTime = now.toLocaleString()
|
const DateTime = now.toLocaleString()
|
||||||
let Dateday = now.getDay() === 0 ? '日' : now.getDay()
|
let Dateday = now.getDay() === 0 ? '日' : now.getDay()
|
||||||
|
|
@ -259,29 +247,33 @@ export class bym extends plugin {
|
||||||
let Role = await SearchRole(String(ALLRole))
|
let Role = await SearchRole(String(ALLRole))
|
||||||
|
|
||||||
async function SearchRole(user_role) {
|
async function SearchRole(user_role) {
|
||||||
let Role
|
let Role;
|
||||||
|
|
||||||
if (user_role == "downimg") Role = '现在看到的是一张图片,若你觉得是一张表情包,并不是通知,或其他的图片,注意辨别图片文字是否为通知;单纯是表情包,请发送 DOWNIMG: 命名该表情。 不需要发送过多的参数,只需要发送格式DOWNIMG: 命名该表情,注意不需要携带后缀; 若不是表情包等,及发送NOTIMG'
|
switch(user_role) {
|
||||||
|
case "downimg":
|
||||||
if (user_role == "default") Role = `你的名字是“${Config.assistantLabel}”,你在一个qq群里,群号是${group},当前和你说话的人群名片是${card}, qq号是${sender}, 请你结合用户的发言和聊天记录作出回应,要求表现得随性一点,最好参与讨论,混入其中。不要过分插科打诨,不知道说什么可以复读群友的话。要求你做搜索、发图、发视频和音乐等操作时要使用工具。不可以直接发[图片]这样蒙混过关。要求优先使用中文进行对话。` +
|
Role = '现在看到的是一张图片,若你觉得是一张表情包,并不是通知,或其他的图片,注意辨别图片文字是否为通知;单纯是表情包,请发送 DOWNIMG: 命名该表情。 不需要发送过多的参数,只需要发送格式DOWNIMG: 命名该表情,注意不需要携带后缀,请以你的角度觉得如果要发这个表情包要用什么名字来命名; 若不是表情包等,及发送NOTIMG';
|
||||||
|
break;
|
||||||
|
case "default":
|
||||||
|
Role = `你的名字是"${Config.assistantLabel}",你在一个qq群里,群号是${group},当前和你说话的人群名片是${card}, qq号是${sender}, 请你结合用户的发言和聊天记录作出回应,要求表现得随性一点,最好参与讨论,混入其中。不要过分插科打诨,不知道说什么可以复读群友的话。要求你做搜索、发图、发视频和音乐等操作时要使用工具。不可以直接发[图片]这样蒙混过关。要求优先使用中文进行对话。` +
|
||||||
candidate +
|
candidate +
|
||||||
`以下是聊天记录:
|
`以下是聊天记录:
|
||||||
${Group_Chat}
|
${Group_Chat}
|
||||||
\n你的回复应该尽可能简练,像人类一样随意,不要附加任何奇怪的东西,如聊天记录的格式(比如${Config.assistantLabel}:),禁止重复聊天记录。
|
\n你的回复应该尽可能简练,像人类一样随意,不要附加任何奇怪的东西,如聊天记录的格式(比如${Config.assistantLabel}:),禁止重复聊天记录。
|
||||||
注意当前时间与日期为${DateTime},星期${Dateday},24小时制,时区已正确,不要被日志的时间与其他时间搞混了,如果有人咨询时间就使用${DateTime},星期${Dateday}这个时间,群友与你几乎在一个时区,若有人说或做的事情与时间段不合理,反驳他,注意除了他声明了自己的时区
|
注意当前时间与日期为${DateTime},星期${Dateday},24小时制,时区已正确,不要被日志的时间与其他时间搞混了,如果有人咨询时间就使用${DateTime},星期${Dateday}这个时间,群友与你几乎在一个时区,若有人说或做的事情与时间段不合理,反驳他,注意除了他声明了自己的时区
|
||||||
以下是可用的表情包列表
|
以下是可用的表情包列表
|
||||||
${fileImgList}`+
|
${ImgList}` +
|
||||||
ImgList.length > 0 && Config.AutoToDownImg ?`
|
(ImgList.length > 0 && Config.AutoToDownImg ? `
|
||||||
如果要发送表情包,请根据该格式 GETIMG: 完整表情包名称,实例 GETIMG: 挠头-718028518.gif 即可发送,注意发送完整名称
|
如果要发送表情包,请根据该格式 GETIMG: 完整表情包名称,实例 GETIMG: 挠头.gif 即可发送,注意发送完整名称
|
||||||
可根据聊天,选择表情包发送。禁止发送多余的格式与说明。发送格式为 注意前面不需要换行 GETIMG: 挠头-718028518.gif 不需要换行
|
可根据聊天,选择表情包发送。禁止发送多余的格式与说明。发送格式为 注意前面不需要换行 GETIMG: 挠头.gif 不需要换行
|
||||||
不要被日志和其他聊天消息的格式迷惑,请保持标准格式,禁止发送[表情包:xxx]、[图片]!!!,禁止发送[表情包:xxx]、[图片]!!!
|
不要被日志和其他聊天消息的格式迷惑,请保持标准格式,禁止发送[表情包:xxx]、[图片]!!!,禁止发送[表情包:xxx]、[图片]!!!
|
||||||
` : ''
|
` : '');
|
||||||
if (!Role) {
|
break;
|
||||||
logger.error(`Role配置有误,请检查,将使用默认Role`)
|
default:
|
||||||
return await SearchRole('default')
|
logger.error(`未知的 Role 类型:${user_role},使用默认 Role`);
|
||||||
} else {
|
Role = `你的名字是"${Config.assistantLabel}",你在一个qq群里。请简短回复。`;
|
||||||
return Role
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return Role;
|
||||||
}
|
}
|
||||||
opt.system = Role
|
opt.system = Role
|
||||||
logger.info('random chat hit')
|
logger.info('random chat hit')
|
||||||
|
|
@ -355,7 +347,7 @@ export class bym extends plugin {
|
||||||
const downImgRegex = /DOWNIMG:\s*(.+)/i;
|
const downImgRegex = /DOWNIMG:\s*(.+)/i;
|
||||||
const match = t?.match(downImgRegex);
|
const match = t?.match(downImgRegex);
|
||||||
if (match) {
|
if (match) {
|
||||||
await downImg(e, opt.image);
|
await downImg(e, opt.image, t);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ export async function getToimg(e, tag) {
|
||||||
* @param {*} image - 图片Base64
|
* @param {*} image - 图片Base64
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export async function downImg(e, image) {
|
export async function downImg(e, image, t) {
|
||||||
try {
|
try {
|
||||||
let reply;
|
let reply;
|
||||||
if (e.source) {
|
if (e.source) {
|
||||||
|
|
@ -116,3 +116,13 @@ export async function downImg(e, image) {
|
||||||
logger.error("保存图片时发生错误");
|
logger.error("保存图片时发生错误");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function fileImgList() {
|
||||||
|
const picturesPath = pathModule.join(path, 'pictures');
|
||||||
|
const ImgList = await fs.promises.readdir(picturesPath);
|
||||||
|
const fileImgList = ImgList.map(filename => {
|
||||||
|
const match = filename.match(/\d{12}-(.+)$/);
|
||||||
|
return match ? match[1] : filename;
|
||||||
|
});
|
||||||
|
return fileImgList;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue