feat: 建议回复

This commit is contained in:
ikechan8370 2023-03-18 11:53:27 +08:00
parent dfd1ce469d
commit 3d466f0fee
4 changed files with 30 additions and 6 deletions

View file

@ -1,6 +1,6 @@
import plugin from '../../../lib/plugins/plugin.js'
import _ from 'lodash'
import {Config, defaultOpenAIAPI, defaultOpenAIReverseProxy} from '../utils/config.js'
import { Config, defaultOpenAIAPI, defaultOpenAIReverseProxy } from '../utils/config.js'
import { v4 as uuid } from 'uuid'
import delay from 'delay'
import { ChatGPTAPI } from 'chatgpt'
@ -613,7 +613,6 @@ export class chatgpt extends plugin {
return false
}
let quotemessage = []
if (chatMessage?.quote) {
chatMessage.quote.forEach(function (item, index) {
@ -631,6 +630,9 @@ export class chatgpt extends plugin {
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或者文字太长了哦我用文本回复你吧', e.isGroup)
@ -638,6 +640,9 @@ export class chatgpt extends plugin {
if (quotemessage.length > 0) {
this.reply(await makeForwardMsg(this.e, quotemessage))
}
if (Config.enableSuggestedResponses && chatMessage.suggestedResponses) {
this.reply(`建议的回复:\n${chatMessage.suggestedResponses}`)
}
}
} else if (userSetting.usePicture || (Config.autoUsePicture && response.length > Config.autoUsePictureThreshold)) {
// todo use next api of chatgpt to complete incomplete respoonse
@ -648,11 +653,17 @@ export class chatgpt extends plugin {
logger.error(err)
await this.renderImage(e, use !== 'bing' ? 'content/ChatGPT/index' : 'content/Bing/index', response, prompt)
}
if (Config.enableSuggestedResponses && chatMessage.suggestedResponses) {
this.reply(`建议的回复:\n${chatMessage.suggestedResponses}`)
}
} else {
await this.reply(`${response}`, e.isGroup)
if (quotemessage.length > 0) {
this.reply(await makeForwardMsg(this.e, quotemessage))
}
if (Config.enableSuggestedResponses && chatMessage.suggestedResponses) {
this.reply(`建议的回复:\n${chatMessage.suggestedResponses}`)
}
}
if (use !== 'bing') {
// 移除队列首位,释放锁
@ -793,6 +804,7 @@ export class chatgpt extends plugin {
})
response.quote = response.details.adaptiveCards?.[0]?.body?.[0]?.text?.replace(/\[\^[0-9]+\^\]/g, '').replace(response.response, '').split('\n')
}
response.suggestedResponses = response.details.suggestedResponses?.map(s => s.text).join('\n')
errorMessage = ''
break
} catch (error) {
@ -810,6 +822,7 @@ export class chatgpt extends plugin {
return {
text: response.response,
quote: response.quote,
suggestedResponses: response.suggestedResponses,
conversationId: response.conversationId,
clientId: response.clientId,
invocationId: response.invocationId,