[feat] nerdslash
This commit is contained in:
BIN
public/token/nai/nerdstash_v2.model
Normal file
BIN
public/token/nai/nerdstash_v2.model
Normal file
Binary file not shown.
@@ -14,10 +14,13 @@ async function encode(data:string):Promise<(number[]|Uint32Array|Int32Array)>{
|
||||
if(db.aiModel.startsWith('claude')){
|
||||
return await tokenizeWebTokenizers(data, 'claude')
|
||||
}
|
||||
if(db.aiModel.startsWith('novelai')){
|
||||
return await tokenizeWebTokenizers(data, 'novelai')
|
||||
}
|
||||
return await tikJS(data)
|
||||
}
|
||||
|
||||
type tokenizerType = 'novellist'|'claude'
|
||||
type tokenizerType = 'novellist'|'claude'|'novelai'
|
||||
|
||||
let tikParser:Tiktoken = null
|
||||
let tokenizersTokenizer:Tokenizer = null
|
||||
@@ -51,6 +54,11 @@ async function tokenizeWebTokenizers(text:string, type:tokenizerType) {
|
||||
await (await fetch("/token/claude/claude.json")
|
||||
).arrayBuffer())
|
||||
break
|
||||
case 'novelai':
|
||||
tokenizersTokenizer = await webTokenizer.Tokenizer.fromSentencePiece(
|
||||
await (await fetch("/token/nai/nerdstash_v2.model")
|
||||
).arrayBuffer())
|
||||
break
|
||||
}
|
||||
tokenizersType = type
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user