Add awaits to event emissions

This commit is contained in:
Cohee
2025-02-08 19:13:05 +02:00
parent 5886bb6b3a
commit d5959a4681
4 changed files with 10 additions and 10 deletions

View File

@ -3514,7 +3514,7 @@ export async function generateRaw(prompt, api, instructOverride, quietToLoud, sy
break;
}
case 'textgenerationwebui':
generateData = getTextGenGenerationData(prompt, amount_gen, false, false, null, 'quiet');
generateData = await getTextGenGenerationData(prompt, amount_gen, false, false, null, 'quiet');
TempResponseLength.restore(api);
break;
case 'openai': {
@ -4651,7 +4651,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
break;
case 'textgenerationwebui': {
const cfgValues = useCfgPrompt ? { guidanceScale: cfgGuidanceScale, negativePrompt: await getCombinedPrompt(true) } : null;
generate_data = getTextGenGenerationData(finalPrompt, maxLength, isImpersonate, isContinue, cfgValues, type);
generate_data = await getTextGenGenerationData(finalPrompt, maxLength, isImpersonate, isContinue, cfgValues, type);
break;
}
case 'novel': {
@ -6991,7 +6991,7 @@ export async function getSettings() {
loadProxyPresets(settings);
// Allow subscribers to mutate settings
eventSource.emit(event_types.SETTINGS_LOADED_AFTER, settings);
await eventSource.emit(event_types.SETTINGS_LOADED_AFTER, settings);
// Set context size after loading power user (may override the max value)
$('#max_context').val(max_context);
@ -7051,7 +7051,7 @@ export async function getSettings() {
}
await validateDisabledSamplers();
settingsReady = true;
eventSource.emit(event_types.SETTINGS_LOADED);
await eventSource.emit(event_types.SETTINGS_LOADED);
}
function selectKoboldGuiPreset() {
@ -11468,7 +11468,7 @@ jQuery(async function () {
);
break;*/
default:
eventSource.emit('charManagementDropdown', target);
await eventSource.emit('charManagementDropdown', target);
}
$('#char-management-dropdown').prop('selectedIndex', 0);
});
@ -11630,7 +11630,7 @@ jQuery(async function () {
$(document).on('click', '.open_characters_library', async function () {
await getCharacters();
eventSource.emit(event_types.OPEN_CHARACTER_LIBRARY);
await eventSource.emit(event_types.OPEN_CHARACTER_LIBRARY);
});
// Added here to prevent execution before script.js is loaded and get rid of quirky timeouts

View File

@ -2451,7 +2451,7 @@ async function resetMovablePanels(type) {
}
saveSettingsDebounced();
eventSource.emit(event_types.MOVABLE_PANELS_RESET);
await eventSource.emit(event_types.MOVABLE_PANELS_RESET);
eventSource.once(event_types.SETTINGS_UPDATED, () => {
$('.resizing').removeClass('resizing');

View File

@ -1221,7 +1221,7 @@ function replaceMacrosInList(str) {
}
}
export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate, isContinue, cfgValues, type) {
export async function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate, isContinue, cfgValues, type) {
const canMultiSwipe = !isContinue && !isImpersonate && type !== 'quiet';
const dynatemp = isDynamicTemperatureSupported();
const { banned_tokens, banned_strings } = getCustomTokenBans();
@ -1449,7 +1449,7 @@ export function getTextGenGenerationData(finalPrompt, maxTokens, isImpersonate,
}
}
eventSource.emitAndWait(event_types.TEXT_COMPLETION_SETTINGS_READY, params);
await eventSource.emit(event_types.TEXT_COMPLETION_SETTINGS_READY, params);
// Grammar conflicts with with json_schema
if (settings.type === LLAMACPP) {

View File

@ -3452,7 +3452,7 @@ async function _save(name, data) {
headers: getRequestHeaders(),
body: JSON.stringify({ name: name, data: data }),
});
eventSource.emit(event_types.WORLDINFO_UPDATED, name, data);
await eventSource.emit(event_types.WORLDINFO_UPDATED, name, data);
}