mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +00:00
fix: 优化一些错误提示和一些代码格式化
This commit is contained in:
parent
c5d11efb74
commit
4bd6c8c7d8
3 changed files with 22 additions and 22 deletions
14
apps/chat.js
14
apps/chat.js
|
|
@ -524,8 +524,10 @@ export class chatgpt extends plugin {
|
|||
prompt = e.raw_message.trim()
|
||||
if (e.isGroup) {
|
||||
let me = e.group.pickMember(Bot.uin)
|
||||
let card = me.card || me.nickname
|
||||
let card = me.card
|
||||
let nickname = me.nickname
|
||||
prompt = prompt.replace(`@${card}`, '').trim()
|
||||
prompt = prompt.replace(`@${nickname}`, '').trim()
|
||||
}
|
||||
} else {
|
||||
let ats = e.message.filter(m => m.type === 'at')
|
||||
|
|
@ -747,7 +749,7 @@ export class chatgpt extends plugin {
|
|||
} else {
|
||||
previousConversation.bingToken = ''
|
||||
}
|
||||
} else {
|
||||
} else if (chatMessage.id) {
|
||||
previousConversation.parentMessageId = chatMessage.id
|
||||
}
|
||||
if (Config.debug) {
|
||||
|
|
@ -767,9 +769,9 @@ export class chatgpt extends plugin {
|
|||
}
|
||||
// 分离内容和情绪
|
||||
if (Config.sydneyMood) {
|
||||
let temp_response = completeJSON(response)
|
||||
if (temp_response.text) response = temp_response.text
|
||||
if (temp_response.mood) mood = temp_response.mood
|
||||
let tempResponse = completeJSON(response)
|
||||
if (tempResponse.text) response = tempResponse.text
|
||||
if (tempResponse.mood) mood = tempResponse.mood
|
||||
} else {
|
||||
mood = ''
|
||||
}
|
||||
|
|
@ -819,7 +821,7 @@ export class chatgpt extends plugin {
|
|||
}
|
||||
} 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 {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
"type": "module",
|
||||
"author": "ikechan8370",
|
||||
"dependencies": {
|
||||
"@waylaidwanderer/chatgpt-api": "^1.32.0",
|
||||
"@waylaidwanderer/chatgpt-api": "^1.33.2",
|
||||
"chatgpt": "^5.1.1",
|
||||
"delay": "^5.0.0",
|
||||
"https-proxy-agent": "5.0.1",
|
||||
|
|
@ -17,11 +17,11 @@
|
|||
"ws": "^8.13.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"eventsource-parser": "^1.0.0",
|
||||
"jimp": "^0.22.7",
|
||||
"puppeteer-extra": "^3.3.6",
|
||||
"puppeteer-extra-plugin-recaptcha": "^3.6.8",
|
||||
"puppeteer-extra-plugin-stealth": "^2.11.2",
|
||||
"sharp": "^0.31.3",
|
||||
"eventsource-parser": "^1.0.0"
|
||||
"sharp": "^0.31.3"
|
||||
}
|
||||
}
|
||||
|
|
@ -120,6 +120,11 @@ export default class SydneyAIClient {
|
|||
text = await response.text()
|
||||
retry--
|
||||
}
|
||||
if (response.status !== 200) {
|
||||
logger.error('创建sydney对话失败: status code: ' + response.status + response.statusText)
|
||||
logger.error(text)
|
||||
throw new Error(text)
|
||||
}
|
||||
try {
|
||||
return JSON.parse(text)
|
||||
} catch (err) {
|
||||
|
|
@ -144,6 +149,7 @@ export default class SydneyAIClient {
|
|||
logger.mark(`use sydney websocket host: ${sydneyHost}`)
|
||||
let ws = new WebSocket(sydneyHost + '/sydney/ChatHub', { agent })
|
||||
ws.on('error', (err) => {
|
||||
console.error(err)
|
||||
reject(err)
|
||||
})
|
||||
|
||||
|
|
@ -332,7 +338,6 @@ export default class SydneyAIClient {
|
|||
role: 'User',
|
||||
message
|
||||
}
|
||||
|
||||
const ws = await this.createWebSocketConnection()
|
||||
if (Config.debug) {
|
||||
logger.mark('sydney websocket constructed successful')
|
||||
|
|
@ -405,15 +410,6 @@ export default class SydneyAIClient {
|
|||
target: 'chat',
|
||||
type: 4
|
||||
}
|
||||
// if (previousMessagesFormatted) {
|
||||
// obj.arguments[0].previousMessages.push({
|
||||
// author: 'user',
|
||||
// description: previousMessagesFormatted,
|
||||
// contextType: 'WebPage',
|
||||
// messageType: 'Context',
|
||||
// messageId: 'discover-web--page-ping-mriduna-----'
|
||||
// });
|
||||
// }
|
||||
// simulates document summary function on Edge's Bing sidebar
|
||||
// unknown character limit, at least up to 7k
|
||||
if (groupId) {
|
||||
|
|
@ -694,6 +690,9 @@ export default class SydneyAIClient {
|
|||
default:
|
||||
}
|
||||
})
|
||||
ws.on('error', err => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
|
||||
const messageJson = JSON.stringify(obj)
|
||||
|
|
@ -701,9 +700,8 @@ export default class SydneyAIClient {
|
|||
console.debug(messageJson)
|
||||
console.debug('\n\n\n\n')
|
||||
}
|
||||
ws.send(`${messageJson}`)
|
||||
|
||||
try {
|
||||
ws.send(`${messageJson}`)
|
||||
const {
|
||||
message: reply,
|
||||
conversationExpiryTime
|
||||
|
|
@ -729,7 +727,7 @@ export default class SydneyAIClient {
|
|||
conversationExpiryTime,
|
||||
response: reply.text,
|
||||
details: reply,
|
||||
apology: Config.sydneyApologyIgnored && apology,
|
||||
apology: Config.sydneyApologyIgnored && apology
|
||||
}
|
||||
} catch (err) {
|
||||
await this.conversationsCache.set(conversationKey, conversation)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue