mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 21:37:11 +00:00
feat: 建议回复
This commit is contained in:
parent
dfd1ce469d
commit
3d466f0fee
4 changed files with 30 additions and 6 deletions
17
apps/chat.js
17
apps/chat.js
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue