#2566 Cache expressions list for LLM API

d214c181560fdd2ae0cb1dfc9d10ec7cd22014f6

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +6 -3Ignore whitespace
public/scripts/extensions/expressions/index.js+6 -3
@@ -1387,7 +1387,8 @@ async function getExpressionsList() {
1387 }1387 }
13881388
1389 // If there was no specific list, or an error, just return the default expressions1389 // If there was no specific list, or an error, just return the default expressions
1390 return DEFAULT_EXPRESSIONS;1390 expressionsList = DEFAULT_EXPRESSIONS.filter(e => e !== 'talkinghead').slice();
1391 return expressionsList;
1391 }1392 }
13921393
1393 const result = await resolveExpressionsList();1394 const result = await resolveExpressionsList();
@@ -1618,11 +1619,13 @@ async function onClickExpressionRemoveCustom() {
1618 moduleWorker();1619 moduleWorker();
1619}1620}
16201621
1621function onExperesionApiChanged() {1622function onExpressionApiChanged() {
1622 const tempApi = this.value;1623 const tempApi = this.value;
1623 if (tempApi) {1624 if (tempApi) {
1624 extension_settings.expressions.api = Number(tempApi);1625 extension_settings.expressions.api = Number(tempApi);
1625 $('.expression_llm_prompt_block').toggle(extension_settings.expressions.api === EXPRESSION_API.llm);1626 $('.expression_llm_prompt_block').toggle(extension_settings.expressions.api === EXPRESSION_API.llm);
1627 expressionsList = null;
1628 spriteCache = {};
1626 moduleWorker();1629 moduleWorker();
1627 saveSettingsDebounced();1630 saveSettingsDebounced();
1628 }1631 }
@@ -1972,7 +1975,7 @@ function migrateSettings() {
1972 $('#expression_custom_add').on('click', onClickExpressionAddCustom);1975 $('#expression_custom_add').on('click', onClickExpressionAddCustom);
1973 $('#expression_custom_remove').on('click', onClickExpressionRemoveCustom);1976 $('#expression_custom_remove').on('click', onClickExpressionRemoveCustom);
1974 $('#expression_fallback').on('change', onExpressionFallbackChanged);1977 $('#expression_fallback').on('change', onExpressionFallbackChanged);
1975 $('#expression_api').on('change', onExperesionApiChanged);1978 $('#expression_api').on('change', onExpressionApiChanged);
1976 }1979 }
19771980
1978 // Pause Talkinghead to save resources when the ST tab is not visible or the window is minimized.1981 // Pause Talkinghead to save resources when the ST tab is not visible or the window is minimized.