Add awaits to event emissions
| @@ -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); |
| 6992 | 6992 | ||
| 6993 | // Allow subscribers to mutate settings | 6993 | // Allow subscribers to mutate settings |
| 6994 | eventSource.emit(event_types.SETTINGS_LOADED_AFTER, settings); | 6994 | await eventSource.emit(event_types.SETTINGS_LOADED_AFTER, settings); |
| 6995 | 6995 | ||
| 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 | } |
| 7056 | 7056 | ||
| 7057 | function selectKoboldGuiPreset() { | 7057 | function 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 () { | |||
| 11630 | 11630 | ||
| 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 | }); |
| 11635 | 11635 | ||
| 11636 | // Added here to prevent execution before script.js is loaded and get rid of quirky timeouts | 11636 | // Added here to prevent execution before script.js is loaded and get rid of quirky timeouts |
| @@ -2451,7 +2451,7 @@ async function resetMovablePanels(type) { | |||
| 2451 | } | 2451 | } |
| 2452 | 2452 | ||
| 2453 | saveSettingsDebounced(); | 2453 | saveSettingsDebounced(); |
| 2454 | eventSource.emit(event_types.MOVABLE_PANELS_RESET); | 2454 | await eventSource.emit(event_types.MOVABLE_PANELS_RESET); |
| 2455 | 2455 | ||
| 2456 | eventSource.once(event_types.SETTINGS_UPDATED, () => { | 2456 | eventSource.once(event_types.SETTINGS_UPDATED, () => { |
| 2457 | $('.resizing').removeClass('resizing'); | 2457 | $('.resizing').removeClass('resizing'); |
| @@ -1221,7 +1221,7 @@ function replaceMacrosInList(str) { | |||
| 1221 | } | 1221 | } |
| 1222 | } | 1222 | } |
| 1223 | 1223 | ||
| 1224 | export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate, isContinue, cfgValues, type) { | 1224 | export 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 | } |
| 1451 | 1451 | ||
| 1452 | eventSource.emitAndWait(event_types.TEXT_COMPLETION_SETTINGS_READY, params); | 1452 | await eventSource.emit(event_types.TEXT_COMPLETION_SETTINGS_READY, params); |
| 1453 | 1453 | ||
| 1454 | // Grammar conflicts with with json_schema | 1454 | // Grammar conflicts with with json_schema |
| 1455 | if (settings.type === LLAMACPP) { | 1455 | if (settings.type === LLAMACPP) { |
| @@ -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 | } |
| 3457 | 3457 | ||
| 3458 | 3458 | ||