mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 22:07:10 +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 crypto from 'crypto'
|
||||||
|
|
||||||
import HttpsProxyAgent from 'https-proxy-agent'
|
import HttpsProxyAgent from 'https-proxy-agent'
|
||||||
import {Config, pureSydneyInstruction} from './config.js'
|
import { Config, pureSydneyInstruction } from './config.js'
|
||||||
import { isCN } from './common.js'
|
import { isCN } from './common.js'
|
||||||
|
|
||||||
if (!globalThis.fetch) {
|
if (!globalThis.fetch) {
|
||||||
|
|
@ -322,7 +322,6 @@ export default class SydneyAIClient {
|
||||||
role: 'User',
|
role: 'User',
|
||||||
message
|
message
|
||||||
}
|
}
|
||||||
conversation.messages.push(userMessage)
|
|
||||||
|
|
||||||
const ws = await this.createWebSocketConnection()
|
const ws = await this.createWebSocketConnection()
|
||||||
if (Config.debug) {
|
if (Config.debug) {
|
||||||
|
|
@ -400,7 +399,7 @@ export default class SydneyAIClient {
|
||||||
target: 'chat',
|
target: 'chat',
|
||||||
type: 4
|
type: 4
|
||||||
}
|
}
|
||||||
|
let apology = false
|
||||||
const messagePromise = new Promise((resolve, reject) => {
|
const messagePromise = new Promise((resolve, reject) => {
|
||||||
let replySoFar = ''
|
let replySoFar = ''
|
||||||
let adaptiveCardsSoFar = null
|
let adaptiveCardsSoFar = null
|
||||||
|
|
@ -477,6 +476,9 @@ export default class SydneyAIClient {
|
||||||
}
|
}
|
||||||
if (messages[0].contentOrigin === 'Apology') {
|
if (messages[0].contentOrigin === 'Apology') {
|
||||||
console.log('Apology found')
|
console.log('Apology found')
|
||||||
|
if (!replySoFar) {
|
||||||
|
apology = true
|
||||||
|
}
|
||||||
stopTokenFound = true
|
stopTokenFound = true
|
||||||
clearTimeout(messageTimeout)
|
clearTimeout(messageTimeout)
|
||||||
clearTimeout(firstTimeout)
|
clearTimeout(firstTimeout)
|
||||||
|
|
@ -541,6 +543,9 @@ export default class SydneyAIClient {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (message.contentOrigin === 'Apology') {
|
if (message.contentOrigin === 'Apology') {
|
||||||
|
if (!replySoFar) {
|
||||||
|
apology = true
|
||||||
|
}
|
||||||
console.log('Apology found')
|
console.log('Apology found')
|
||||||
stopTokenFound = true
|
stopTokenFound = true
|
||||||
clearTimeout(messageTimeout)
|
clearTimeout(messageTimeout)
|
||||||
|
|
@ -610,10 +615,12 @@ export default class SydneyAIClient {
|
||||||
message: reply.text,
|
message: reply.text,
|
||||||
details: reply
|
details: reply
|
||||||
}
|
}
|
||||||
conversation.messages.push(replyMessage)
|
if (!apology) {
|
||||||
|
conversation.messages.push(userMessage)
|
||||||
await this.conversationsCache.set(conversationKey, conversation)
|
conversation.messages.push(replyMessage)
|
||||||
|
|
||||||
|
await this.conversationsCache.set(conversationKey, conversation)
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
conversationSignature,
|
conversationSignature,
|
||||||
conversationId,
|
conversationId,
|
||||||
|
|
@ -622,7 +629,8 @@ export default class SydneyAIClient {
|
||||||
messageId: replyMessage.id,
|
messageId: replyMessage.id,
|
||||||
conversationExpiryTime,
|
conversationExpiryTime,
|
||||||
response: reply.text,
|
response: reply.text,
|
||||||
details: reply
|
details: reply,
|
||||||
|
apology
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue