mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-02-13 18:50:39 +01:00
Use Fuse only as fallback
This commit is contained in:
parent
1dd3be9479
commit
75f44e24e9
@ -123,15 +123,20 @@ function selectSystemPromptCallback(args, name) {
|
|||||||
|
|
||||||
const quiet = isTrueBoolean(args?.quiet);
|
const quiet = isTrueBoolean(args?.quiet);
|
||||||
const instructNames = system_prompts.map(preset => preset.name);
|
const instructNames = system_prompts.map(preset => preset.name);
|
||||||
const fuse = new Fuse(instructNames);
|
let foundName = instructNames.find(x => x.toLowerCase() === name.toLowerCase());
|
||||||
const result = fuse.search(name);
|
|
||||||
|
|
||||||
if (result.length === 0) {
|
if (!foundName) {
|
||||||
!quiet && toastr.warning(`System prompt "${name}" not found`);
|
const fuse = new Fuse(instructNames);
|
||||||
return '';
|
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');
|
$select.val(foundName).trigger('input');
|
||||||
!quiet && toastr.success(`System prompt "${foundName}" selected`);
|
!quiet && toastr.success(`System prompt "${foundName}" selected`);
|
||||||
return foundName;
|
return foundName;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user