mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add model hash to TC API tokenizer cache key
This commit is contained in:
@ -433,6 +433,7 @@ export async function getTokenCountAsync(str, padding = undefined) {
|
||||
}
|
||||
|
||||
let tokenizerType = power_user.tokenizer;
|
||||
let modelHash = '';
|
||||
|
||||
if (main_api === 'openai') {
|
||||
if (padding === power_user.token_padding) {
|
||||
@ -448,13 +449,17 @@ export async function getTokenCountAsync(str, padding = undefined) {
|
||||
tokenizerType = getTokenizerBestMatch(main_api);
|
||||
}
|
||||
|
||||
if (tokenizerType === tokenizers.API_TEXTGENERATIONWEBUI) {
|
||||
modelHash = getStringHash(getTextGenModel() || online_status).toString();
|
||||
}
|
||||
|
||||
if (padding === undefined) {
|
||||
padding = 0;
|
||||
}
|
||||
|
||||
const cacheObject = getTokenCacheObject();
|
||||
const hash = getStringHash(str);
|
||||
const cacheKey = `${tokenizerType}-${hash}+${padding}`;
|
||||
const cacheKey = `${tokenizerType}-${hash}${modelHash}+${padding}`;
|
||||
|
||||
if (typeof cacheObject[cacheKey] === 'number') {
|
||||
return cacheObject[cacheKey];
|
||||
@ -484,6 +489,7 @@ export function getTokenCount(str, padding = undefined) {
|
||||
}
|
||||
|
||||
let tokenizerType = power_user.tokenizer;
|
||||
let modelHash = '';
|
||||
|
||||
if (main_api === 'openai') {
|
||||
if (padding === power_user.token_padding) {
|
||||
@ -499,13 +505,17 @@ export function getTokenCount(str, padding = undefined) {
|
||||
tokenizerType = getTokenizerBestMatch(main_api);
|
||||
}
|
||||
|
||||
if (tokenizerType === tokenizers.API_TEXTGENERATIONWEBUI) {
|
||||
modelHash = getStringHash(getTextGenModel() || online_status).toString();
|
||||
}
|
||||
|
||||
if (padding === undefined) {
|
||||
padding = 0;
|
||||
}
|
||||
|
||||
const cacheObject = getTokenCacheObject();
|
||||
const hash = getStringHash(str);
|
||||
const cacheKey = `${tokenizerType}-${hash}+${padding}`;
|
||||
const cacheKey = `${tokenizerType}-${hash}${modelHash}+${padding}`;
|
||||
|
||||
if (typeof cacheObject[cacheKey] === 'number') {
|
||||
return cacheObject[cacheKey];
|
||||
|
Reference in New Issue
Block a user