Add Start Reply With to master import/export (#4716)
Signed| @@ -187,6 +187,23 @@ class PresetManager { | |||
| 187 | }, | 187 | }, |
| 188 | isValid: (data) => PresetManager.isPossiblyReasoningData(data), | 188 | isValid: (data) => PresetManager.isPossiblyReasoningData(data), |
| 189 | }, | 189 | }, |
| 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 | }, | ||
| 190 | }; | 207 | }; |
| 191 | 208 | ||
| 192 | static isPossiblyInstructData(data) { | 209 | static isPossiblyInstructData(data) { |
| @@ -214,6 +231,10 @@ class PresetManager { | |||
| 214 | return data && reasoningProps.every(prop => Object.keys(data).includes(prop)); | 231 | return data && reasoningProps.every(prop => Object.keys(data).includes(prop)); |
| 215 | } | 232 | } |
| 216 | 233 | ||
| 234 | static isPossiblyStartReplyWithData(data) { | ||
| 235 | return data && 'value' in data && 'show' in data; | ||
| 236 | } | ||
| 237 | |||
| 217 | /** | 238 | /** |
| 218 | * Imports master settings from JSON data. | 239 | * Imports master settings from JSON data. |
| 219 | * @param {object} data Data to import | 240 | * @param {object} data Data to import |
| @@ -313,7 +334,7 @@ class PresetManager { | |||
| 313 | */ | 334 | */ |
| 314 | static async performMasterExport() { | 335 | static async performMasterExport() { |
| 315 | const sectionNames = Object.entries(this.masterSections).reduce((acc, [key, section]) => { | 336 | const sectionNames = Object.entries(this.masterSections).reduce((acc, [key, section]) => { |
| 316 | acc[key] = { key: key, name: section.name, checked: key !== 'preset' }; | 337 | acc[key] = { key: key, name: section.name, checked: !['preset', 'srw'].includes(key) }; |
| 317 | return acc; | 338 | return acc; |
| 318 | }, {}); | 339 | }, {}); |
| 319 | const html = $(await renderTemplateAsync('masterExport', { sections: sectionNames })); | 340 | const html = $(await renderTemplateAsync('masterExport', { sections: sectionNames })); |