Use performFuzzySearch

6ff06ff04bded54c846ce203192243c0908d74b8

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

1 files changed, +3 -5Showing whitespace changes
public/scripts/reasoning.js+3 -5
@@ -1,5 +1,4 @@
1import {1import {
2 Fuse,
3 moment,2 moment,
4} from '../lib.js';3} from '../lib.js';
5import { chat, closeMessageEditor, event_types, eventSource, main_api, messageFormatting, saveChatConditional, saveChatDebounced, saveSettingsDebounced, substituteParams, syncMesToSwipe, updateMessageBlock } from '../script.js';4import { chat, closeMessageEditor, event_types, eventSource, main_api, messageFormatting, saveChatConditional, saveChatDebounced, saveSettingsDebounced, substituteParams, syncMesToSwipe, updateMessageBlock } from '../script.js';
@@ -8,7 +7,7 @@ import { getCurrentLocale, t, translate } from './i18n.js';
8import { MacrosParser } from './macros.js';7import { MacrosParser } from './macros.js';
9import { chat_completion_sources, getChatCompletionModel, oai_settings } from './openai.js';8import { chat_completion_sources, getChatCompletionModel, oai_settings } from './openai.js';
10import { Popup } from './popup.js';9import { Popup } from './popup.js';
11import { power_user } from './power-user.js';10import { performFuzzySearch, power_user } from './power-user.js';
12import { SlashCommand } from './slash-commands/SlashCommand.js';11import { SlashCommand } from './slash-commands/SlashCommand.js';
13import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from './slash-commands/SlashCommandArgument.js';12import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from './slash-commands/SlashCommandArgument.js';
14import { commonEnumProviders, enumIcons } from './slash-commands/SlashCommandCommonEnumsProvider.js';13import { commonEnumProviders, enumIcons } from './slash-commands/SlashCommandCommonEnumsProvider.js';
@@ -91,7 +90,7 @@ export function extractReasoningFromData(data, {
91 mainApi = null,90 mainApi = null,
92 ignoreShowThoughts = false,91 ignoreShowThoughts = false,
93 textGenType = null,92 textGenType = null,
94 chatCompletionSource = null93 chatCompletionSource = null,
95} = {}) {94} = {}) {
96 switch (mainApi ?? main_api) {95 switch (mainApi ?? main_api) {
97 case 'textgenerationwebui':96 case 'textgenerationwebui':
@@ -781,8 +780,7 @@ function selectReasoningTemplateCallback(args, name) {
781 let foundName = templateNames.find(x => x.toLowerCase() === name.toLowerCase());780 let foundName = templateNames.find(x => x.toLowerCase() === name.toLowerCase());
782781
783 if (!foundName) {782 if (!foundName) {
784 const fuse = new Fuse(templateNames);783 const result = performFuzzySearch('reasoning-templates', templateNames, [], name);
785 const result = fuse.search(name);
786784
787 if (result.length === 0) {785 if (result.length === 0) {
788 !quiet && toastr.warning(`Reasoning template "${name}" not found`);786 !quiet && toastr.warning(`Reasoning template "${name}" not found`);