Merge pull request #2634 from splitclover/staging

Add events for chat completion import/export
This commit is contained in:
Cohee 2024-08-10 02:21:53 +03:00 committed by GitHub
commit 218416010f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 0 deletions

View File

@ -425,6 +425,8 @@ export const event_types = {
CHATCOMPLETION_MODEL_CHANGED: 'chatcompletion_model_changed',
OAI_PRESET_CHANGED_BEFORE: 'oai_preset_changed_before',
OAI_PRESET_CHANGED_AFTER: 'oai_preset_changed_after',
OAI_PRESET_EXPORT_READY: 'oai_preset_export_ready',
OAI_PRESET_IMPORT_READY: 'oai_preset_import_ready',
WORLDINFO_SETTINGS_UPDATED: 'worldinfo_settings_updated',
WORLDINFO_UPDATED: 'worldinfo_updated',
CHARACTER_EDITED: 'character_edited',

View File

@ -3597,6 +3597,8 @@ async function onPresetImportFileChange(e) {
}
}
await eventSource.emit(event_types.OAI_PRESET_IMPORT_READY, { data: presetBody, presetName: name });
const savePresetSettings = await fetch(`/api/presets/save-openai?name=${name}`, {
method: 'POST',
headers: getRequestHeaders(),
@ -3652,6 +3654,7 @@ async function onExportPresetClick() {
sensitiveFields.forEach(field => delete preset[field]);
}
await eventSource.emit(event_types.OAI_PRESET_EXPORT_READY, preset);
const presetJsonString = JSON.stringify(preset, null, 4);
const presetFileName = `${oai_settings.preset_settings_openai}.json`;
download(presetJsonString, presetFileName, 'application/json');