#2085 Switch to async token counters

This commit is contained in:
Cohee
2024-04-13 21:33:19 +03:00
parent 1c4bad35b2
commit 306bff0a92
7 changed files with 75 additions and 78 deletions

View File

@@ -17,7 +17,7 @@ import {
user_avatar,
} from '../script.js';
import { persona_description_positions, power_user } from './power-user.js';
import { getTokenCount } from './tokenizers.js';
import { getTokenCountAsync } from './tokenizers.js';
import { debounce, delay, download, parseJsonFile } from './utils.js';
const GRID_STORAGE_KEY = 'Personas_GridView';
@@ -171,9 +171,9 @@ export async function convertCharacterToPersona(characterId = null) {
/**
* Counts the number of tokens in a persona description.
*/
const countPersonaDescriptionTokens = debounce(() => {
const countPersonaDescriptionTokens = debounce(async () => {
const description = String($('#persona_description').val());
const count = getTokenCount(description);
const count = await getTokenCountAsync(description);
$('#persona_description_token_count').text(String(count));
}, 1000);