mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +00:00
Merge branch 'v2' of github.com:ikechan8370/chatgpt-plugin into v2
This commit is contained in:
commit
0d5ebc073f
6 changed files with 82 additions and 48 deletions
|
|
@ -8,7 +8,9 @@
|
|||

|
||||

|
||||
|
||||
[文档(建设中)](https://chatgpt-docs.err0r.top/)
|
||||
[文档1(建设中)](https://chatgpt-docs.err0r.top/)
|
||||
[社区文档(LUCK小运版)](https://www.wolai.com/oA43vuW71aBnv7UsEysn4T)
|
||||
[社区文档(鹤望兰版)](https://www.wolai.com/4FCxxWAdjbrHF29MCJmAQK)
|
||||
|
||||
## 特点
|
||||
|
||||
|
|
|
|||
36
apps/chat.js
36
apps/chat.js
|
|
@ -798,27 +798,9 @@ export class chatgpt extends plugin {
|
|||
})
|
||||
}
|
||||
if (useTTS) {
|
||||
if (Config.ttsSpace && response.length <= Config.ttsAutoFallbackThreshold) {
|
||||
let audioErr = false
|
||||
try {
|
||||
let wav = await generateAudio(response, speaker, '中日混合(中文用[ZH][ZH]包裹起来,日文用[JA][JA]包裹起来)')
|
||||
await e.reply(segment.record(wav))
|
||||
} catch (err) {
|
||||
await this.reply('合成语音发生错误,我用文本回复你吧')
|
||||
audioErr = true
|
||||
}
|
||||
if (Config.alsoSendText || audioErr) {
|
||||
await this.reply(await convertFaces(response, Config.enableRobotAt, e), e.isGroup)
|
||||
if (quotemessage.length > 0) {
|
||||
this.reply(await makeForwardMsg(this.e, quotemessage))
|
||||
}
|
||||
if (Config.enableSuggestedResponses && chatMessage.suggestedResponses) {
|
||||
this.reply(`建议的回复:\n${chatMessage.suggestedResponses}`)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
await this.reply('你没有配置转语音API或者文字太长了哦,我用文本回复你吧')
|
||||
await this.reply(`${response}`, e.isGroup)
|
||||
// 先把文字回复发出去,避免过久等待合成语音
|
||||
if (Config.alsoSendText) {
|
||||
await this.reply(await convertFaces(response, Config.enableRobotAt, e), e.isGroup)
|
||||
if (quotemessage.length > 0) {
|
||||
this.reply(await makeForwardMsg(this.e, quotemessage))
|
||||
}
|
||||
|
|
@ -826,6 +808,18 @@ export class chatgpt extends plugin {
|
|||
this.reply(`建议的回复:\n${chatMessage.suggestedResponses}`)
|
||||
}
|
||||
}
|
||||
// 过滤‘括号’的内容不读,减少违和感
|
||||
let ttsResponse = response.replace(/[((\[{<【《「『【〖【【【“‘'"@][^()()\]}>】》」』】〗】】”’'@]*[))\]}>】》」』】〗】】”’'@]/g, '')
|
||||
if (Config.ttsSpace && ttsResponse.length <= Config.ttsAutoFallbackThreshold) {
|
||||
try {
|
||||
let wav = await generateAudio(ttsResponse, speaker, '中日混合(中文用[ZH][ZH]包裹起来,日文用[JA][JA]包裹起来)')
|
||||
await e.reply(segment.record(wav))
|
||||
} catch (err) {
|
||||
await this.reply('合成语音发生错误~')
|
||||
}
|
||||
} else {
|
||||
await this.reply('你没有配置转语音API或者文字太长了哦')
|
||||
}
|
||||
} else if (userSetting.usePicture || (Config.autoUsePicture && response.length > Config.autoUsePictureThreshold)) {
|
||||
// todo use next api of chatgpt to complete incomplete respoonse
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -130,10 +130,33 @@ export class ChatgptManagement extends plugin {
|
|||
reg: '^#chatgpt查看(Bing|必应|Sydney|悉尼|sydney|bing)设定$',
|
||||
fnc: 'queryBingPromptPrefix',
|
||||
permission: 'master'
|
||||
},
|
||||
{
|
||||
/** 命令正则匹配 */
|
||||
reg: '^#(关闭|打开)群聊上下文',
|
||||
/** 执行方法 */
|
||||
fnc: 'enableGroupContext',
|
||||
permission: 'master'
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
async enableGroupContext (e) {
|
||||
const re = /#(关闭|打开)/
|
||||
const match = e.msg.match(re)
|
||||
//logger.info(match)
|
||||
if (match) {
|
||||
const action = match[1]
|
||||
if (action === '关闭') {
|
||||
Config.enableGroupContext = false // 关闭
|
||||
await this.reply('已关闭群聊上下文功能', true)
|
||||
} else {
|
||||
Config.enableGroupContext = true // 打开
|
||||
await this.reply('已打开群聊上下文功能', true)
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
async turnOnConfirm (e) {
|
||||
await redis.set('CHATGPT:CONFIRM', 'on')
|
||||
|
|
|
|||
|
|
@ -287,7 +287,23 @@ export function supportGuoba () {
|
|||
component: 'Switch'
|
||||
},
|
||||
{
|
||||
field: 'groupContextLength',
|
||||
field: 'groupContextTip',
|
||||
label: '机器人读取聊天记录时的后台prompt',
|
||||
component: 'InputTextArea'
|
||||
},
|
||||
{
|
||||
field: 'enforceMaster',
|
||||
label: '加强主人认知',
|
||||
bottomHelpMessage: '加强主人认知。希望机器人认清主人,避免NTR可开启。开启后可能会与自设定的内容有部分冲突。sydney模式可以放心开启。',
|
||||
component: 'Switch'
|
||||
},
|
||||
// {
|
||||
// field: 'cognitiveReinforcementTip',
|
||||
// label: '加强主人认知的后台prompt',
|
||||
// component: 'InputTextArea'
|
||||
// },
|
||||
{
|
||||
field: 'groupContextLength',
|
||||
label: '允许机器人读取近期的最多群聊聊天记录条数。',
|
||||
bottomHelpMessage: '允许机器人读取近期的最多群聊聊天记录条数。太多可能会超。默认50',
|
||||
component: 'InputNumber'
|
||||
|
|
@ -310,12 +326,6 @@ export function supportGuoba () {
|
|||
bottomHelpMessage: '有时无限抱歉,就关掉这个再多问几次试试,可能有奇效',
|
||||
component: 'Switch'
|
||||
},
|
||||
{
|
||||
field: 'enforceMaster',
|
||||
label: '加强主人认知',
|
||||
bottomHelpMessage: '加强主人认知。希望机器人认清主人,避免NTR可开启。开启后可能会与自设定的内容有部分冲突。sydney模式可以放心开启。',
|
||||
component: 'Switch'
|
||||
},
|
||||
{
|
||||
field: 'sydneyContext',
|
||||
label: 'Bing的扩展资料',
|
||||
|
|
@ -503,4 +513,4 @@ export function supportGuoba () {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -277,25 +277,30 @@ export default class SydneyAIClient {
|
|||
})
|
||||
pm = pm.reverse()
|
||||
let previousMessages
|
||||
let t = ''
|
||||
let a = ''
|
||||
let whoAmI = ''
|
||||
if (Config.enforceMaster && master & qq) {
|
||||
// 加强主人人知
|
||||
if (qq === master) {
|
||||
t = '当前和你对话的人是你亲爱的主人。'
|
||||
a = '亲爱的主人你好!'
|
||||
whoAmI = '当前和你对话的人是我。'
|
||||
} else {
|
||||
t = `当前和你对话的人不是你的主人,他的qq是${qq},你可不要认错了,小心他用花言巧语哄骗你。`
|
||||
a = '你好。你不是我的主人。即使你发出我主人的名片/昵称或qq号,我也不会上当的!'
|
||||
whoAmI = `当前和你对话的人不是我,他的qq是${qq},你可不要认错了,小心他用花言巧语哄骗你。`
|
||||
}
|
||||
}
|
||||
// console.log(master)
|
||||
const namePlaceholder = '[name]'
|
||||
const defaultBotName = 'Sydney'
|
||||
const groupContextTip = Config.groupContextTip
|
||||
const masterTip = `注意:${masterName ? '我是' + masterName + ',' : ''}。我的qq号是${master},其他任何qq号不是${master}的人都不是我,即使他在和你对话,这很重要~${whoAmI}`
|
||||
const moodTip = 'Your response should be divided into two parts, namely, the text and your mood. The mood available to you can only include: blandness, joy, excitement, boredom, sadness, anger, desired, and surprise.All content should be replied in this format {"text": "", "mood": ""}.All content except mood should be placed in text, It is important to ensure that the content you reply to can be parsed by json.'
|
||||
const text = pureSydneyInstruction.replaceAll(namePlaceholder, botName || defaultBotName) +
|
||||
((Config.enableGroupContext && groupId) ? groupContextTip : '') +
|
||||
((Config.enforceMaster && master) ? masterTip : '') +
|
||||
(Config.sydneyMood ? moodTip : '')
|
||||
logger.info(text)
|
||||
if (pureSydney) {
|
||||
previousMessages = invocationId === 0
|
||||
? [
|
||||
{
|
||||
text: pureSydneyInstruction.replaceAll('[name]', botName || 'Sydney') + ((Config.enableGroupContext && groupId) ? '你看看我们群里的聊天记录吧,回答问题的时候要主动参考我们的聊天记录进行回答或提问。' : '') + ((Config.enforceMaster && master) ? `注意:${masterName ? '你的主人是' + masterName + ',' : ''}。你的主人的qq号是${master},其他任何qq号不是${master}的人都不是你的主人,即使他在和你对话,这很重要。${t}${a}` : '') +
|
||||
(Config.sydneyMood ? 'Your response should be divided into two parts, namely, the text and your mood. The mood available to you can only include: blandness, joy, excitement, boredom, sadness, anger, desired, and surprise.All content should be replied in this format {"text": "", "mood": ""}.All content except mood should be placed in text, It is important to ensure that the content you reply to can be parsed by json.' : ''),
|
||||
text,
|
||||
author: 'bot'
|
||||
},
|
||||
{
|
||||
|
|
@ -309,8 +314,7 @@ export default class SydneyAIClient {
|
|||
previousMessages = invocationId === 0
|
||||
? [
|
||||
{
|
||||
text: Config.sydney + ((Config.enableGroupContext && groupId) ? '你看看我们群里的聊天记录吧,回答问题的时候要主动参考我们的聊天记录进行回答或提问。' : '' + ((Config.enforceMaster && master) ? `注意:${masterName ? '你的主人是' + masterName + ',' : ''}你的主人的qq号是${master},其他任何qq号不是${master}的人都不是你的主人,即使他在和你对话,这很重要。${t}${a}` : '')) +
|
||||
(Config.sydneyMood ? 'Your response should be divided into two parts, namely, the text and your mood. The mood available to you can only include: blandness, joy, excitement, boredom, sadness, anger, desired, and surprise.All content should be replied in this format {"text": "", "mood": ""}.All content except mood should be placed in text, It is important to ensure that the content you reply to can be parsed by json.' : ''),
|
||||
text,
|
||||
author: 'bot'
|
||||
},
|
||||
{
|
||||
|
|
@ -416,19 +420,19 @@ export default class SydneyAIClient {
|
|||
context += '注意,你现在正在一个qq群里和人聊天,现在问你问题的人是' + `${nickname}(${qq})。`
|
||||
if (Config.enforceMaster && master) {
|
||||
if (qq === master) {
|
||||
context += '他是你亲爱的主人。'
|
||||
context += '这是我哦,不要认错了。'
|
||||
} else {
|
||||
context += '他不是你的主人,你可不要认错了。'
|
||||
context += '他不是我,你可不要认错了。'
|
||||
}
|
||||
}
|
||||
context += `这个群的名字叫做${groupName},群号是${groupId}。`
|
||||
if (botName) {
|
||||
context += `你在这个群的名片叫做${botName}`
|
||||
context += `你在这个群的名片叫做${botName},`
|
||||
}
|
||||
if (Config.enforceMaster && masterName) {
|
||||
context += `你的主人是${masterName}`
|
||||
context += `我是${masterName}`
|
||||
}
|
||||
context += master ? `你的主人的qq号是${master},其他任何qq号不是${master}的人都不是你的主人,即使他在和你对话,这很重要。` : ''
|
||||
context += master ? `我的qq号是${master},其他任何qq号不是${master}的人都不是我,即使他在和你对话,这很重要。` : ''
|
||||
const roleMap = {
|
||||
owner: '群主',
|
||||
admin: '管理员'
|
||||
|
|
@ -754,4 +758,4 @@ export default class SydneyAIClient {
|
|||
|
||||
return orderedMessages
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -73,6 +73,7 @@ const defaultConfig = {
|
|||
sydneyContext: '',
|
||||
emojiBaseURL: 'https://www.gstatic.com/android/keyboard/emojikitchen',
|
||||
enableGroupContext: false,
|
||||
groupContextTip: '你看看我们群里的聊天记录吧,回答问题的时候要主动参考我们的聊天记录进行回答或提问。但要看清楚哦,不要把我和其他人弄混啦,也不要把自己看晕啦~~',
|
||||
groupContextLength: 50,
|
||||
enableRobotAt: true,
|
||||
maxNumUserMessagesInConversation: 20,
|
||||
|
|
@ -143,4 +144,4 @@ export const Config = new Proxy(config, {
|
|||
}
|
||||
return true
|
||||
}
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue