diff --git a/src/ts/process/index.ts b/src/ts/process/index.ts index 564ecdaa..93d537e4 100644 --- a/src/ts/process/index.ts +++ b/src/ts/process/index.ts @@ -18,6 +18,7 @@ export interface OpenAIChat{ role: 'system'|'user'|'assistant' content: string memo?:string + name?:string } export const doingChat = writable(false) @@ -200,22 +201,26 @@ export async function sendChat(chatProcessIndex = -1):Promise { const ms = currentChat.message for(const msg of ms){ let formedChat = processScript(currentChar,replacePlaceholders(msg.data, currentChar.name), 'editprocess') - if(nowChatroom.type === 'group'){ - if(msg.saying && msg.role === 'char'){ - formedChat = `${findCharacterbyIdwithCache(msg.saying).name}: ${formedChat}` - + let name = '' + if(msg.role === 'char'){ + if(msg.saying){ + name = `${findCharacterbyIdwithCache(msg.saying).name}` } - else if(msg.role === 'user'){ - formedChat = `${db.username}: ${formedChat}` + else{ + name = `${currentChar.name}` } } + else if(msg.role === 'user'){ + name = `${db.username}` + } if(!msg.chatId){ msg.chatId = v4() } chats.push({ role: msg.role === 'user' ? 'user' : 'assistant', content: formedChat, - memo: msg.chatId + memo: msg.chatId, + name: name }) currentTokens += (await tokenize(formedChat) + 1) } diff --git a/src/ts/process/request.ts b/src/ts/process/request.ts index 34235e34..124aa07f 100644 --- a/src/ts/process/request.ts +++ b/src/ts/process/request.ts @@ -53,6 +53,11 @@ export async function requestChatDataMain(arg:requestDataArgument, model:'model' switch(aiModel){ case 'gpt35': case 'gpt4':{ + + for(let i=0;i