mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 21:37:11 +00:00
Chore: Optimize some code logic and add support for chat context in '锅巴面板' and 'chatgpt帮助' (#310)
* Optimized code logic and added support for chat context in '锅巴面板' and 'chatgpt帮助' In this commit, I have optimized certain code logic to improve the performance of the application. Additionally, I have added support for chat context in croutons and help, which will enhance the user experience and make the chatbot more user-friendly. This feature will allow users to maintain a better understanding of the conversation flow and context, and will ultimately lead to more successful interactions with the chatbot. * Update chat.js --------- Co-authored-by: ikechan8370 <geyinchibuaa@gmail.com>
This commit is contained in:
parent
84eabee14d
commit
68bb1f221e
5 changed files with 79 additions and 47 deletions
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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue