[feat] better stringlizer
This commit is contained in:
@@ -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<boolean> {
|
||||
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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user