fix: 修复aplogy打乱顺序丢失对话的问题

This commit is contained in:
ikechan8370 2023-03-21 13:24:40 +08:00
parent 8555d8eb14
commit c560a440e9
2 changed files with 4 additions and 5 deletions

View file

@ -1012,7 +1012,7 @@ export class chatgpt extends plugin {
clientId: response.clientId,
invocationId: response.invocationId,
conversationSignature: response.conversationSignature,
parentMessageId: response.messageId
parentMessageId: response.apology ? conversation.parentMessageId : response.messageId
}
}
}

View file

@ -444,7 +444,7 @@ export default class SydneyAIClient {
reject('Request aborted')
}
})
let apology = false
// let apology = false
ws.on('message', (data) => {
const objects = data.toString().split('')
const events = objects.map((object) => {
@ -507,7 +507,7 @@ export default class SydneyAIClient {
const difference = updatedText.substring(replySoFar.length)
onProgress(difference)
if (updatedText.trim().endsWith(stopToken)) {
apology = true
// apology = true
// remove stop token from updated text
replySoFar = updatedText.replace(stopToken, '').trim()
return
@ -618,9 +618,8 @@ export default class SydneyAIClient {
if (!apology) {
conversation.messages.push(userMessage)
conversation.messages.push(replyMessage)
await this.conversationsCache.set(conversationKey, conversation)
}
await this.conversationsCache.set(conversationKey, conversation)
return {
conversationSignature,
conversationId,