Add awaits to event emissions

d5959a4681481582640b78c4c73a0a3208a6421f

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

4 files changed, +10 -10Ignore whitespace
public/script.js+6 -6
@@ -3514,7 +3514,7 @@ export async function generateRaw(prompt, api, instructOverride, quietToLoud, sy
3514 break;3514 break;
3515 }3515 }
3516 case 'textgenerationwebui':3516 case 'textgenerationwebui':
3517 generateData = getTextGenGenerationData(prompt, amount_gen, false, false, null, 'quiet');3517 generateData = await getTextGenGenerationData(prompt, amount_gen, false, false, null, 'quiet');
3518 TempResponseLength.restore(api);3518 TempResponseLength.restore(api);
3519 break;3519 break;
3520 case 'openai': {3520 case 'openai': {
@@ -4651,7 +4651,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
4651 break;4651 break;
4652 case 'textgenerationwebui': {4652 case 'textgenerationwebui': {
4653 const cfgValues = useCfgPrompt ? { guidanceScale: cfgGuidanceScale, negativePrompt: await getCombinedPrompt(true) } : null;4653 const cfgValues = useCfgPrompt ? { guidanceScale: cfgGuidanceScale, negativePrompt: await getCombinedPrompt(true) } : null;
4654 generate_data = getTextGenGenerationData(finalPrompt, maxLength, isImpersonate, isContinue, cfgValues, type);4654 generate_data = await getTextGenGenerationData(finalPrompt, maxLength, isImpersonate, isContinue, cfgValues, type);
4655 break;4655 break;
4656 }4656 }
4657 case 'novel': {4657 case 'novel': {
@@ -6991,7 +6991,7 @@ export async function getSettings() {
6991 loadProxyPresets(settings);6991 loadProxyPresets(settings);
69926992
6993 // Allow subscribers to mutate settings6993 // Allow subscribers to mutate settings
6994 eventSource.emit(event_types.SETTINGS_LOADED_AFTER, settings);6994 await eventSource.emit(event_types.SETTINGS_LOADED_AFTER, settings);
69956995
6996 // Set context size after loading power user (may override the max value)6996 // Set context size after loading power user (may override the max value)
6997 $('#max_context').val(max_context);6997 $('#max_context').val(max_context);
@@ -7051,7 +7051,7 @@ export async function getSettings() {
7051 }7051 }
7052 await validateDisabledSamplers();7052 await validateDisabledSamplers();
7053 settingsReady = true;7053 settingsReady = true;
7054 eventSource.emit(event_types.SETTINGS_LOADED);7054 await eventSource.emit(event_types.SETTINGS_LOADED);
7055}7055}
70567056
7057function selectKoboldGuiPreset() {7057function selectKoboldGuiPreset() {
@@ -11468,7 +11468,7 @@ jQuery(async function () {
11468 );11468 );
11469 break;*/11469 break;*/
11470 default:11470 default:
11471 eventSource.emit('charManagementDropdown', target);11471 await eventSource.emit('charManagementDropdown', target);
11472 }11472 }
11473 $('#char-management-dropdown').prop('selectedIndex', 0);11473 $('#char-management-dropdown').prop('selectedIndex', 0);
11474 });11474 });
@@ -11630,7 +11630,7 @@ jQuery(async function () {
1163011630
11631 $(document).on('click', '.open_characters_library', async function () {11631 $(document).on('click', '.open_characters_library', async function () {
11632 await getCharacters();11632 await getCharacters();
11633 eventSource.emit(event_types.OPEN_CHARACTER_LIBRARY);11633 await eventSource.emit(event_types.OPEN_CHARACTER_LIBRARY);
11634 });11634 });
1163511635
11636 // Added here to prevent execution before script.js is loaded and get rid of quirky timeouts11636 // Added here to prevent execution before script.js is loaded and get rid of quirky timeouts
public/scripts/power-user.js+1 -1
@@ -2451,7 +2451,7 @@ async function resetMovablePanels(type) {
2451 }2451 }
24522452
2453 saveSettingsDebounced();2453 saveSettingsDebounced();
2454 eventSource.emit(event_types.MOVABLE_PANELS_RESET);2454 await eventSource.emit(event_types.MOVABLE_PANELS_RESET);
24552455
2456 eventSource.once(event_types.SETTINGS_UPDATED, () => {2456 eventSource.once(event_types.SETTINGS_UPDATED, () => {
2457 $('.resizing').removeClass('resizing');2457 $('.resizing').removeClass('resizing');
public/scripts/textgen-settings.js+2 -2
@@ -1221,7 +1221,7 @@ function replaceMacrosInList(str) {
1221 }1221 }
1222}1222}
12231223
1224export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate, isContinue, cfgValues, type) {1224export async function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate, isContinue, cfgValues, type) {
1225 const canMultiSwipe = !isContinue && !isImpersonate && type !== 'quiet';1225 const canMultiSwipe = !isContinue && !isImpersonate && type !== 'quiet';
1226 const dynatemp = isDynamicTemperatureSupported();1226 const dynatemp = isDynamicTemperatureSupported();
1227 const { banned_tokens, banned_strings } = getCustomTokenBans();1227 const { banned_tokens, banned_strings } = getCustomTokenBans();
@@ -1449,7 +1449,7 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate,
1449 }1449 }
1450 }1450 }
14511451
1452 eventSource.emitAndWait(event_types.TEXT_COMPLETION_SETTINGS_READY, params);1452 await eventSource.emit(event_types.TEXT_COMPLETION_SETTINGS_READY, params);
14531453
1454 // Grammar conflicts with with json_schema1454 // Grammar conflicts with with json_schema
1455 if (settings.type === LLAMACPP) {1455 if (settings.type === LLAMACPP) {
public/scripts/world-info.js+1 -1
@@ -3452,7 +3452,7 @@ async function _save(name, data) {
3452 headers: getRequestHeaders(),3452 headers: getRequestHeaders(),
3453 body: JSON.stringify({ name: name, data: data }),3453 body: JSON.stringify({ name: name, data: data }),
3454 });3454 });
3455 eventSource.emit(event_types.WORLDINFO_UPDATED, name, data);3455 await eventSource.emit(event_types.WORLDINFO_UPDATED, name, data);
3456}3456}
34573457
34583458