Add chat process indication mark

This commit is contained in:
kwaroran
2024-04-11 04:43:56 +09:00
parent 746d226723
commit 3752b4e550
2 changed files with 33 additions and 3 deletions

View File

@@ -52,11 +52,12 @@ export interface OpenAIChatFull extends OpenAIChat{
}
export const doingChat = writable(false)
export const chatProcessStage = writable(0)
export const abortChat = writable(false)
export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:number,signal?:AbortSignal,continue?:boolean} = {}):Promise<boolean> {
chatProcessStage.set(0)
const abortSignal = arg.signal ?? (new AbortController()).signal
let isAborted = false
@@ -185,6 +186,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
}
chatProcessStage.set(1)
let unformated = {
'main':([] as OpenAIChat[]),
'jailbreak':([] as OpenAIChat[]),
@@ -641,6 +643,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
}
if(nowChatroom.supaMemory && db.supaMemoryType !== 'none'){
chatProcessStage.set(2)
const sp = await supaMemory(chats, currentTokens, maxContextTokens, currentChat, nowChatroom, tokenizer, {
asHyper: db.supaMemoryType !== 'subModel' && db.hypaMemory
})
@@ -651,7 +654,11 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
chats = sp.chats
currentTokens = sp.currentTokens
currentChat.supaMemoryData = sp.memory ?? currentChat.supaMemoryData
db.characters[selectedChar].chats[selectedChat].supaMemoryData = currentChat.supaMemoryData
console.log(currentChat.supaMemoryData)
DataBase.set(db)
currentChat.lastMemory = sp.lastId ?? currentChat.lastMemory
chatProcessStage.set(1)
}
else{
while(currentTokens > maxContextTokens){
@@ -961,6 +968,7 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
outputTokens: outputTokens,
maxContext: maxContextTokens,
}
chatProcessStage.set(3)
const req = await requestChatData({
formated: formated,
biasString: biases,
@@ -1120,6 +1128,8 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
}
}
chatProcessStage.set(4)
sendPeerChar()
if(req.special){