#2566 Cache expressions list for LLM API

This commit is contained in:
Cohee 2024-07-27 13:57:39 +03:00
parent 443ef36653
commit d214c18156
1 changed files with 6 additions and 3 deletions

View File

@ -1387,7 +1387,8 @@ async function getExpressionsList() {
} }
// If there was no specific list, or an error, just return the default expressions // If there was no specific list, or an error, just return the default expressions
return DEFAULT_EXPRESSIONS; expressionsList = DEFAULT_EXPRESSIONS.filter(e => e !== 'talkinghead').slice();
return expressionsList;
} }
const result = await resolveExpressionsList(); const result = await resolveExpressionsList();
@ -1618,11 +1619,13 @@ async function onClickExpressionRemoveCustom() {
moduleWorker(); moduleWorker();
} }
function onExperesionApiChanged() { function onExpressionApiChanged() {
const tempApi = this.value; const tempApi = this.value;
if (tempApi) { if (tempApi) {
extension_settings.expressions.api = Number(tempApi); extension_settings.expressions.api = Number(tempApi);
$('.expression_llm_prompt_block').toggle(extension_settings.expressions.api === EXPRESSION_API.llm); $('.expression_llm_prompt_block').toggle(extension_settings.expressions.api === EXPRESSION_API.llm);
expressionsList = null;
spriteCache = {};
moduleWorker(); moduleWorker();
saveSettingsDebounced(); saveSettingsDebounced();
} }
@ -1972,7 +1975,7 @@ function migrateSettings() {
$('#expression_custom_add').on('click', onClickExpressionAddCustom); $('#expression_custom_add').on('click', onClickExpressionAddCustom);
$('#expression_custom_remove').on('click', onClickExpressionRemoveCustom); $('#expression_custom_remove').on('click', onClickExpressionRemoveCustom);
$('#expression_fallback').on('change', onExpressionFallbackChanged); $('#expression_fallback').on('change', onExpressionFallbackChanged);
$('#expression_api').on('change', onExperesionApiChanged); $('#expression_api').on('change', onExpressionApiChanged);
} }
// Pause Talkinghead to save resources when the ST tab is not visible or the window is minimized. // Pause Talkinghead to save resources when the ST tab is not visible or the window is minimized.