mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 21:37:11 +00:00
fix: 修复aplogy打乱顺序丢失对话的问题
This commit is contained in:
parent
8555d8eb14
commit
c560a440e9
2 changed files with 4 additions and 5 deletions
|
|
@ -1012,7 +1012,7 @@ export class chatgpt extends plugin {
|
||||||
clientId: response.clientId,
|
clientId: response.clientId,
|
||||||
invocationId: response.invocationId,
|
invocationId: response.invocationId,
|
||||||
conversationSignature: response.conversationSignature,
|
conversationSignature: response.conversationSignature,
|
||||||
parentMessageId: response.messageId
|
parentMessageId: response.apology ? conversation.parentMessageId : response.messageId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -444,7 +444,7 @@ export default class SydneyAIClient {
|
||||||
reject('Request aborted')
|
reject('Request aborted')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let apology = false
|
// let apology = false
|
||||||
ws.on('message', (data) => {
|
ws.on('message', (data) => {
|
||||||
const objects = data.toString().split('')
|
const objects = data.toString().split('')
|
||||||
const events = objects.map((object) => {
|
const events = objects.map((object) => {
|
||||||
|
|
@ -507,7 +507,7 @@ export default class SydneyAIClient {
|
||||||
const difference = updatedText.substring(replySoFar.length)
|
const difference = updatedText.substring(replySoFar.length)
|
||||||
onProgress(difference)
|
onProgress(difference)
|
||||||
if (updatedText.trim().endsWith(stopToken)) {
|
if (updatedText.trim().endsWith(stopToken)) {
|
||||||
apology = true
|
// apology = true
|
||||||
// remove stop token from updated text
|
// remove stop token from updated text
|
||||||
replySoFar = updatedText.replace(stopToken, '').trim()
|
replySoFar = updatedText.replace(stopToken, '').trim()
|
||||||
return
|
return
|
||||||
|
|
@ -618,9 +618,8 @@ export default class SydneyAIClient {
|
||||||
if (!apology) {
|
if (!apology) {
|
||||||
conversation.messages.push(userMessage)
|
conversation.messages.push(userMessage)
|
||||||
conversation.messages.push(replyMessage)
|
conversation.messages.push(replyMessage)
|
||||||
|
|
||||||
await this.conversationsCache.set(conversationKey, conversation)
|
|
||||||
}
|
}
|
||||||
|
await this.conversationsCache.set(conversationKey, conversation)
|
||||||
return {
|
return {
|
||||||
conversationSignature,
|
conversationSignature,
|
||||||
conversationId,
|
conversationId,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue