mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +00:00
fix: bym optimizing
This commit is contained in:
parent
1c34ecbb83
commit
314c60d0ae
6 changed files with 46 additions and 23 deletions
59
apps/bym.js
59
apps/bym.js
|
|
@ -17,6 +17,7 @@ import { JinyanTool } from '../utils/tools/JinyanTool.js'
|
|||
import { KickOutTool } from '../utils/tools/KickOutTool.js'
|
||||
import { SetTitleTool } from '../utils/tools/SetTitleTool.js'
|
||||
import {SerpTool} from '../utils/tools/SerpTool.js'
|
||||
import { SendMessageToSpecificGroupOrUserTool } from '../utils/tools/SendMessageToSpecificGroupOrUserTool.js'
|
||||
|
||||
export class bym extends plugin {
|
||||
constructor () {
|
||||
|
|
@ -72,9 +73,10 @@ export class bym extends plugin {
|
|||
if (Config.assistantLabel && e.msg?.includes(Config.assistantLabel)) {
|
||||
prop = -1
|
||||
}
|
||||
if (e.msg?.endsWith('?')) {
|
||||
prop = prop / 10
|
||||
}
|
||||
// 去掉吧 频率有点逆天
|
||||
// if (e.msg?.endsWith('?')) {
|
||||
// prop = prop / 10
|
||||
// }
|
||||
|
||||
let fuck = false
|
||||
let candidate = Config.bymPreset
|
||||
|
|
@ -85,7 +87,7 @@ export class bym extends plugin {
|
|||
if (prop < Config.bymRate) {
|
||||
logger.info('random chat hit')
|
||||
let chats = await getChatHistoryGroup(e, 20)
|
||||
opt.system = `你的名字是“${Config.assistantLabel}”,你在一个qq群里,群号是${group},当前和你说话的人群名片是${card}, qq号是${sender}, 请你结合用户的发言和聊天记录作出回应,要求表现得随性一点,最好参与讨论,混入其中。不要过分插科打诨,不知道说什么可以复读群友的话。要求你做搜索、发图、发视频和音乐等操作时要使用工具。不可以直接发[图片]这样蒙混过关。要求优先使用中文进行对话。` +
|
||||
opt.system = `你的名字是“${Config.assistantLabel}”,你在一个qq群里,群号是${group},当前和你说话的人群名片是${card}, qq号是${sender}, 请你结合用户的发言和聊天记录作出回应,要求表现得随性一点,最好参与讨论,混入其中。不要过分插科打诨,不知道说什么可以复读群友的话。要求你做搜索、发图、发视频和音乐等操作时要使用工具。不可以直接发[图片]这样蒙混过关。要求优先使用中文进行对话。如果此时不需要自己说话,可以只回复<EMPTY>` +
|
||||
candidate +
|
||||
'以下是聊天记录:' + chats
|
||||
.map(chat => {
|
||||
|
|
@ -116,7 +118,8 @@ export class bym extends plugin {
|
|||
new SendMusicTool(),
|
||||
new SendPictureTool(),
|
||||
new WebsiteTool(),
|
||||
new WeatherTool()
|
||||
new WeatherTool(),
|
||||
new SendMessageToSpecificGroupOrUserTool()
|
||||
]
|
||||
if (Config.azSerpKey) {
|
||||
tools.push(new SerpTool())
|
||||
|
|
@ -133,7 +136,7 @@ export class bym extends plugin {
|
|||
// console.log(JSON.stringify(opt))
|
||||
let rsp = await client.sendMessage(e.msg, opt)
|
||||
let text = rsp.text
|
||||
let texts = text.split(/(?<!\?)[。?\n](?!\?)/)
|
||||
let texts = text.split(/(?<!\?)[。?\n](?!\?)/, 3)
|
||||
for (let t of texts) {
|
||||
if (!t) {
|
||||
continue
|
||||
|
|
@ -144,22 +147,42 @@ export class bym extends plugin {
|
|||
}
|
||||
let finalMsg = await convertFaces(t, true, e)
|
||||
logger.info(JSON.stringify(finalMsg))
|
||||
if (Math.floor(Math.random() * 100) < 10) {
|
||||
await this.reply(finalMsg, true, {
|
||||
recallMsg: fuck ? 10 : 0
|
||||
})
|
||||
} else {
|
||||
await this.reply(finalMsg, false, {
|
||||
recallMsg: fuck ? 10 : 0
|
||||
finalMsg = filterResponseChunk(finalMsg)
|
||||
if (finalMsg) {
|
||||
if (Math.floor(Math.random() * 100) < 10) {
|
||||
await this.reply(finalMsg, true, {
|
||||
recallMsg: fuck ? 10 : 0
|
||||
})
|
||||
} else {
|
||||
await this.reply(finalMsg, false, {
|
||||
recallMsg: fuck ? 10 : 0
|
||||
})
|
||||
}
|
||||
await new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
resolve()
|
||||
}, Math.min(t.length * 200, 3000))
|
||||
})
|
||||
}
|
||||
await new Promise((resolve, reject) => {
|
||||
setTimeout(() => {
|
||||
resolve()
|
||||
}, Math.min(t.length * 200, 3000))
|
||||
})
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤
|
||||
* @param msg
|
||||
*/
|
||||
function filterResponseChunk (msg) {
|
||||
if (!msg) {
|
||||
return false
|
||||
}
|
||||
if (msg.trim() === '```') {
|
||||
return false
|
||||
}
|
||||
if (msg.trim() === '<EMPTY>') {
|
||||
return false
|
||||
}
|
||||
return msg
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue