Delayed tokenizers initialization

This commit is contained in:
Cohee 2023-10-25 00:32:49 +03:00
parent 3edc456fe7
commit c2ba3a773a
2 changed files with 4 additions and 3 deletions

View File

@ -180,7 +180,7 @@ import {
formatInstructModeSystemPrompt,
} from "./scripts/instruct-mode.js";
import { applyLocale } from "./scripts/i18n.js";
import { getTokenCount, getTokenizerModel, saveTokenCache } from "./scripts/tokenizers.js";
import { getTokenCount, getTokenizerModel, initTokenizers, saveTokenCache } from "./scripts/tokenizers.js";
import { initPersonas, selectCurrentPersona, setPersonaDescription } from "./scripts/personas.js";
import { getBackgrounds, initBackgrounds } from "./scripts/backgrounds.js";
@ -719,6 +719,7 @@ async function firstLoadInit() {
await getUserAvatars();
await getCharacters();
await getBackgrounds();
await initTokenizers();
initBackgrounds();
initAuthorsNote();
initPersonas();

View File

@ -439,7 +439,7 @@ export function decodeTextTokens(tokenizerType, ids) {
}
}
jQuery(async () => {
export async function initTokenizers() {
await loadTokenCache();
registerDebugFunction('resetTokenCache', 'Reset token cache', 'Purges the calculated token counts. Use this if you want to force a full re-tokenization of all chats or suspect the token counts are wrong.', resetTokenCache);
});
}