Use Fuse only as fallback

75f44e24e9f8838b4b0b2c371f610e11dc71a1b8

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

1 files changed, +11 -6Ignore whitespace
public/scripts/sysprompt.js+11 -6
@@ -123,15 +123,20 @@ function selectSystemPromptCallback(args, name) {
123123
124124 const quiet = isTrueBoolean(args?.quiet);
125125 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);
128127
129128 if (result.length === 0!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;
132138 }
133139
134- const foundName = result[0].item;
135140 $select.val(foundName).trigger('input');
136141 !quiet && toastr.success(`System prompt "${foundName}" selected`);
137142 return foundName;