Use performFuzzySearch
| @@ -1,5 +1,4 @@ | |||
| 1 | import { | 1 | import { |
| 2 | Fuse, | ||
| 3 | moment, | 2 | moment, |
| 4 | } from '../lib.js'; | 3 | } from '../lib.js'; |
| 5 | import { chat, closeMessageEditor, event_types, eventSource, main_api, messageFormatting, saveChatConditional, saveChatDebounced, saveSettingsDebounced, substituteParams, syncMesToSwipe, updateMessageBlock } from '../script.js'; | 4 | import { 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'; | |||
| 8 | import { MacrosParser } from './macros.js'; | 7 | import { MacrosParser } from './macros.js'; |
| 9 | import { chat_completion_sources, getChatCompletionModel, oai_settings } from './openai.js'; | 8 | import { chat_completion_sources, getChatCompletionModel, oai_settings } from './openai.js'; |
| 10 | import { Popup } from './popup.js'; | 9 | import { Popup } from './popup.js'; |
| 11 | import { power_user } from './power-user.js'; | 10 | import { performFuzzySearch, power_user } from './power-user.js'; |
| 12 | import { SlashCommand } from './slash-commands/SlashCommand.js'; | 11 | import { SlashCommand } from './slash-commands/SlashCommand.js'; |
| 13 | import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from './slash-commands/SlashCommandArgument.js'; | 12 | import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from './slash-commands/SlashCommandArgument.js'; |
| 14 | import { commonEnumProviders, enumIcons } from './slash-commands/SlashCommandCommonEnumsProvider.js'; | 13 | import { 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 = null | 93 | 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()); |
| 782 | 781 | ||
| 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); | ||
| 786 | 784 | ||
| 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`); |