Use Fuse only as fallback

This commit is contained in:
Cohee 2024-09-20 00:02:14 +03:00
parent 1dd3be9479
commit 75f44e24e9

View File

@ -123,15 +123,20 @@ function selectSystemPromptCallback(args, name) {
const quiet = isTrueBoolean(args?.quiet);
const instructNames = system_prompts.map(preset => preset.name);
const fuse = new Fuse(instructNames);
const result = fuse.search(name);
let foundName = instructNames.find(x => x.toLowerCase() === name.toLowerCase());
if (result.length === 0) {
!quiet && toastr.warning(`System prompt "${name}" not found`);
return '';
if (!foundName) {
const fuse = new Fuse(instructNames);
const result = fuse.search(name);
if (result.length === 0) {
!quiet && toastr.warning(`System prompt "${name}" not found`);
return '';
}
foundName = result[0].item;
}
const foundName = result[0].item;
$select.val(foundName).trigger('input');
!quiet && toastr.success(`System prompt "${foundName}" selected`);
return foundName;