Add Start Reply With to master import/export (#4716)

36557dc1f6b9bba2337bcfee852b0122f693513b

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

Signed
1 files changed, +22 -1Ignore whitespace
public/scripts/preset-manager.js+22 -1
@@ -187,6 +187,23 @@ class PresetManager {
187187 },
188188 isValid: (data) => PresetManager.isPossiblyReasoningData(data),
189189 },
190+ 'srw': {
191+ name: 'Start Reply With',
192+ getData: () => {
193+ return {
194+ value: power_user.user_prompt_bias ?? '',
195+ show: power_user.show_user_prompt_bias ?? false,
196+ };
197+ },
198+ setData: (data) => {
199+ power_user.user_prompt_bias = data.value ?? '';
200+ power_user.show_user_prompt_bias = data.show ?? false;
201+ $('#start_reply_with').val(power_user.user_prompt_bias);
202+ $('#chat-show-reply-prefix-checkbox').prop('checked', power_user.show_user_prompt_bias);
203+ return saveSettingsDebounced();
204+ },
205+ isValid: (data) => PresetManager.isPossiblyStartReplyWithData(data),
206+ },
190207 };
191208
192209 static isPossiblyInstructData(data) {
@@ -214,6 +231,10 @@ class PresetManager {
214231 return data && reasoningProps.every(prop => Object.keys(data).includes(prop));
215232 }
216233
234+ static isPossiblyStartReplyWithData(data) {
235+ return data && 'value' in data && 'show' in data;
236+ }
237+
217238 /**
218239 * Imports master settings from JSON data.
219240 * @param {object} data Data to import
@@ -313,7 +334,7 @@ class PresetManager {
313334 */
314335 static async performMasterExport() {
315336 const sectionNames = Object.entries(this.masterSections).reduce((acc, [key, section]) => {
316337 acc[key] = { key: key, name: section.name, checked: key !== ['preset', 'srw'].includes(key) };
317338 return acc;
318339 }, {});
319340 const html = $(await renderTemplateAsync('masterExport', { sections: sectionNames }));