Use Fuse only as fallback
| @@ -123,6 +123,9 @@ function selectSystemPromptCallback(args, name) { | |||
| 123 | 123 | ||
| 124 | const quiet = isTrueBoolean(args?.quiet); | 124 | const quiet = isTrueBoolean(args?.quiet); |
| 125 | const instructNames = system_prompts.map(preset => preset.name); | 125 | const instructNames = system_prompts.map(preset => preset.name); |
| 126 | let foundName = instructNames.find(x => x.toLowerCase() === name.toLowerCase()); | ||
| 127 | |||
| 128 | if (!foundName) { | ||
| 126 | const fuse = new Fuse(instructNames); | 129 | const fuse = new Fuse(instructNames); |
| 127 | const result = fuse.search(name); | 130 | const result = fuse.search(name); |
| 128 | 131 | ||
| @@ -131,7 +134,9 @@ function selectSystemPromptCallback(args, name) { | |||
| 131 | return ''; | 134 | return ''; |
| 132 | } | 135 | } |
| 133 | 136 | ||
| 134 | const foundName = result[0].item; | 137 | foundName = result[0].item; |
| 138 | } | ||
| 139 | |||
| 135 | $select.val(foundName).trigger('input'); | 140 | $select.val(foundName).trigger('input'); |
| 136 | !quiet && toastr.success(`System prompt "${foundName}" selected`); | 141 | !quiet && toastr.success(`System prompt "${foundName}" selected`); |
| 137 | return foundName; | 142 | return foundName; |