mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +00:00
feat: 首句aplogy时不加入到聊天记录
This commit is contained in:
parent
a110fb2080
commit
8555d8eb14
1 changed files with 15 additions and 7 deletions
|
|
@ -6,7 +6,7 @@ import fetch, {
|
|||
import crypto from 'crypto'
|
||||
|
||||
import HttpsProxyAgent from 'https-proxy-agent'
|
||||
import {Config, pureSydneyInstruction} from './config.js'
|
||||
import { Config, pureSydneyInstruction } from './config.js'
|
||||
import { isCN } from './common.js'
|
||||
|
||||
if (!globalThis.fetch) {
|
||||
|
|
@ -322,7 +322,6 @@ export default class SydneyAIClient {
|
|||
role: 'User',
|
||||
message
|
||||
}
|
||||
conversation.messages.push(userMessage)
|
||||
|
||||
const ws = await this.createWebSocketConnection()
|
||||
if (Config.debug) {
|
||||
|
|
@ -400,7 +399,7 @@ export default class SydneyAIClient {
|
|||
target: 'chat',
|
||||
type: 4
|
||||
}
|
||||
|
||||
let apology = false
|
||||
const messagePromise = new Promise((resolve, reject) => {
|
||||
let replySoFar = ''
|
||||
let adaptiveCardsSoFar = null
|
||||
|
|
@ -477,6 +476,9 @@ export default class SydneyAIClient {
|
|||
}
|
||||
if (messages[0].contentOrigin === 'Apology') {
|
||||
console.log('Apology found')
|
||||
if (!replySoFar) {
|
||||
apology = true
|
||||
}
|
||||
stopTokenFound = true
|
||||
clearTimeout(messageTimeout)
|
||||
clearTimeout(firstTimeout)
|
||||
|
|
@ -541,6 +543,9 @@ export default class SydneyAIClient {
|
|||
return
|
||||
}
|
||||
if (message.contentOrigin === 'Apology') {
|
||||
if (!replySoFar) {
|
||||
apology = true
|
||||
}
|
||||
console.log('Apology found')
|
||||
stopTokenFound = true
|
||||
clearTimeout(messageTimeout)
|
||||
|
|
@ -610,10 +615,12 @@ export default class SydneyAIClient {
|
|||
message: reply.text,
|
||||
details: reply
|
||||
}
|
||||
conversation.messages.push(replyMessage)
|
||||
|
||||
await this.conversationsCache.set(conversationKey, conversation)
|
||||
if (!apology) {
|
||||
conversation.messages.push(userMessage)
|
||||
conversation.messages.push(replyMessage)
|
||||
|
||||
await this.conversationsCache.set(conversationKey, conversation)
|
||||
}
|
||||
return {
|
||||
conversationSignature,
|
||||
conversationId,
|
||||
|
|
@ -622,7 +629,8 @@ export default class SydneyAIClient {
|
|||
messageId: replyMessage.id,
|
||||
conversationExpiryTime,
|
||||
response: reply.text,
|
||||
details: reply
|
||||
details: reply,
|
||||
apology
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue