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
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);
128127
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 }
133139
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;