Check instruct activation regex before selecting bound context template match
| @@ -208,16 +208,7 @@ export function autoSelectInstructPreset(modelId) { | ||
| 208 | 208 | |
| 209 | 209 | // Select matching instruct preset |
| 210 | 210 | let foundMatch = false; |
| 211 | - for (const instruct_preset of instruct_presets) { | |
| 211 | + | |
| 212 | - // If instruct preset matches the context template | |
| 213 | - if (power_user.instruct.bind_to_context && instruct_preset.name === power_user.context.preset) { | |
| 214 | - foundMatch = true; | |
| 215 | - selectInstructPreset(instruct_preset.name, { isAuto: true }); | |
| 216 | - break; | |
| 217 | - } | |
| 218 | - } | |
| 219 | - // If no match was found, auto-select instruct preset | |
| 220 | - if (!foundMatch) { | |
| 221 | 212 | for (const preset of instruct_presets) { |
| 222 | 213 | // If activation regex is set, check if it matches the model id |
| 223 | 214 | if (preset.activation_regex) { |
| @@ -227,8 +218,8 @@ export function autoSelectInstructPreset(modelId) { | ||
| 227 | 218 | // Stop on first match so it won't cycle back and forth between presets if multiple regexes match |
| 228 | 219 | if (regex instanceof RegExp && regex.test(modelId)) { |
| 229 | 220 | selectInstructPreset(preset.name, { isAuto: true }); |
| 230 | - | |
| 221 | + foundMatch = true; | |
| 231 | - return true; | |
| 222 | + break; | |
| 232 | 223 | } |
| 233 | 224 | } catch { |
| 234 | 225 | // If regex is invalid, ignore it |
| @@ -236,9 +227,20 @@ export function autoSelectInstructPreset(modelId) { | ||
| 236 | 227 | } |
| 237 | 228 | } |
| 238 | 229 | } |
| 230 | + | |
| 231 | + // If no match was found, auto-select instruct preset | |
| 232 | + if (!foundMatch && power_user.instruct.bind_to_context) { | |
| 233 | + for (const instruct_preset of instruct_presets) { | |
| 234 | + // If instruct preset matches the context template | |
| 235 | + if (instruct_preset.name === power_user.context.preset) { | |
| 236 | + selectInstructPreset(instruct_preset.name, { isAuto: true }); | |
| 237 | + foundMatch = true; | |
| 238 | + break; | |
| 239 | + } | |
| 240 | + } | |
| 239 | 241 | } |
| 240 | 242 | |
| 241 | 243 | return falsefoundMatch; |
| 242 | 244 | } |
| 243 | 245 | |
| 244 | 246 | /** |