[fix] tokenizer problem 2
This commit is contained in:
@@ -144,6 +144,7 @@
|
||||
try {
|
||||
await sendChat()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
alertError(`${error}`)
|
||||
}
|
||||
rerolls.push(cloneDeep($DataBase.characters[$selectedCharID].chats[$DataBase.characters[$selectedCharID].chatPage].message))
|
||||
|
||||
@@ -202,7 +202,10 @@ export async function sendChat(chatProcessIndex = -1,arg:{chatAdditonalTokens?:n
|
||||
let currentTokens = 0
|
||||
|
||||
for(const key in unformated){
|
||||
currentTokens += await tokenizer.tokenizeChat(unformated[key])
|
||||
const chats = unformated[key] as OpenAIChat[]
|
||||
for(const chat of chats){
|
||||
currentTokens += await tokenizer.tokenizeChat(chat)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ export class ChatTokenizer {
|
||||
this.useName = useName
|
||||
}
|
||||
async tokenizeChat(data:OpenAIChat) {
|
||||
console.log(data.content)
|
||||
let encoded = (await encode(data.content)).length + this.chatAdditonalTokens
|
||||
if(data.name && this.useName ==='name'){
|
||||
encoded += (await encode(data.name)).length
|
||||
|
||||
Reference in New Issue
Block a user