| 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 | const fuse = new Fuse(instructNames); | 126 | let foundName = instructNames.find(x => x.toLowerCase() === name.toLowerCase()); |
| 127 | const result = fuse.search(name); | | |
| 128 | | 127 | |
| 129 | if (result.length === 0) { | 128 | if (!foundName) { |
| 130 | !quiet && toastr.warning(`System prompt "${name}" not found`); | 129 | const fuse = new Fuse(instructNames); |
| 131 | return ''; | 130 | const result = fuse.search(name); |
| | 131 | |
| | 132 | if (result.length === 0) { |
| | 133 | !quiet && toastr.warning(`System prompt "${name}" not found`); |
| | 134 | return ''; |
| | 135 | } |
| | 136 | |
| | 137 | foundName = result[0].item; |
| 132 | } | 138 | } |
| 133 | | 139 | |
| 134 | const foundName = result[0].item; | | |
| 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; |