Move isHiddenReasoningModel
| @@ -113,7 +113,6 @@ import { | ||
| 113 | 113 | loadProxyPresets, |
| 114 | 114 | selected_proxy, |
| 115 | 115 | initOpenAI, |
| 116 | - isHiddenReasoningModel, | |
| 117 | 116 | } from './scripts/openai.js'; |
| 118 | 117 | |
| 119 | 118 | import { |
| @@ -270,7 +269,7 @@ import { initSettingsSearch } from './scripts/setting-search.js'; | ||
| 270 | 269 | import { initBulkEdit } from './scripts/bulk-edit.js'; |
| 271 | 270 | import { deriveTemplatesFromChatTemplate } from './scripts/chat-templates.js'; |
| 272 | 271 | import { getContext } from './scripts/st-context.js'; |
| 273 | 272 | import { extractReasoningFromData, initReasoning, PromptReasoningisHiddenReasoningModel, updateReasoningTimeUIPromptReasoning, updateReasoningUI } from './scripts/reasoning.js'; |
| 274 | 273 | |
| 275 | 274 | // API OBJECT FOR EXTERNAL WIRING |
| 276 | 275 | globalThis.SillyTavern = { |
| @@ -4995,54 +4995,6 @@ export function isImageInliningSupported() { | ||
| 4995 | 4995 | } |
| 4996 | 4996 | } |
| 4997 | 4997 | |
| 4998 | - | |
| 4999 | - | |
| 5000 | -/** | |
| 5001 | - * Check if the model supports reasoning, but does not send back the reasoning | |
| 5002 | - * @returns {boolean} True if the model supports reasoning | |
| 5003 | - */ | |
| 5004 | -export function isHiddenReasoningModel() { | |
| 5005 | - if (main_api !== 'openai') { | |
| 5006 | - return false; | |
| 5007 | - } | |
| 5008 | - | |
| 5009 | - /** @typedef {Object.<chat_completion_sources, { currentModel: string; models: ({ name: string; startsWith: boolean?; matchingFunc: (model: string) => boolean?; }|string)[]; }>} */ | |
| 5010 | - const hiddenReasoningModels = { | |
| 5011 | - [chat_completion_sources.OPENAI]: { | |
| 5012 | - currentModel: oai_settings.openai_model, | |
| 5013 | - models: [ | |
| 5014 | - { name: 'o1', startsWith: true }, | |
| 5015 | - { name: 'o3', startsWith: true }, | |
| 5016 | - ], | |
| 5017 | - }, | |
| 5018 | - [chat_completion_sources.MAKERSUITE]: { | |
| 5019 | - currentModel: oai_settings.google_model, | |
| 5020 | - models: [ | |
| 5021 | - { name: 'gemini-2.0-flash-thinking-exp', startsWith: true }, | |
| 5022 | - { name: 'gemini-2.0-pro-exp', startsWith: true }, | |
| 5023 | - ], | |
| 5024 | - }, | |
| 5025 | - }; | |
| 5026 | - | |
| 5027 | - const sourceConfig = hiddenReasoningModels[oai_settings.chat_completion_source]; | |
| 5028 | - if (!sourceConfig) { | |
| 5029 | - return false; | |
| 5030 | - } | |
| 5031 | - | |
| 5032 | - return sourceConfig.models.some(model => { | |
| 5033 | - if (typeof model === 'string') { | |
| 5034 | - return sourceConfig.currentModel === model; | |
| 5035 | - } | |
| 5036 | - if (model.startsWith) { | |
| 5037 | - return (sourceConfig.currentModel).startsWith(model.name); | |
| 5038 | - } | |
| 5039 | - if (model.matchingFunc) { | |
| 5040 | - return model.matchingFunc(sourceConfig.currentModel); | |
| 5041 | - } | |
| 5042 | - return false; | |
| 5043 | - }); | |
| 5044 | -} | |
| 5045 | - | |
| 5046 | 4998 | /** |
| 5047 | 4999 | * Proxy stuff |
| 5048 | 5000 | */ |
| @@ -5,7 +5,7 @@ import { chat, closeMessageEditor, event_types, eventSource, main_api, messageFo | ||
| 5 | 5 | import { getRegexedString, regex_placement } from './extensions/regex/engine.js'; |
| 6 | 6 | import { getCurrentLocale, t } from './i18n.js'; |
| 7 | 7 | import { MacrosParser } from './macros.js'; |
| 8 | 8 | import { chat_completion_sources, isHiddenReasoningModel, oai_settings } from './openai.js'; |
| 9 | 9 | import { Popup } from './popup.js'; |
| 10 | 10 | import { power_user } from './power-user.js'; |
| 11 | 11 | import { SlashCommand } from './slash-commands/SlashCommand.js'; |
| @@ -71,6 +71,52 @@ export function extractReasoningFromData(data) { | ||
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | + * Check if the model supports reasoning, but does not send back the reasoning | |
| 75 | + * @returns {boolean} True if the model supports reasoning | |
| 76 | + */ | |
| 77 | +export function isHiddenReasoningModel() { | |
| 78 | + if (main_api !== 'openai') { | |
| 79 | + return false; | |
| 80 | + } | |
| 81 | + | |
| 82 | + /** @typedef {Object.<chat_completion_sources, { currentModel: string; models: ({ name: string; startsWith: boolean?; matchingFunc: (model: string) => boolean?; }|string)[]; }>} */ | |
| 83 | + const hiddenReasoningModels = { | |
| 84 | + [chat_completion_sources.OPENAI]: { | |
| 85 | + currentModel: oai_settings.openai_model, | |
| 86 | + models: [ | |
| 87 | + { name: 'o1', startsWith: true }, | |
| 88 | + { name: 'o3', startsWith: true }, | |
| 89 | + ], | |
| 90 | + }, | |
| 91 | + [chat_completion_sources.MAKERSUITE]: { | |
| 92 | + currentModel: oai_settings.google_model, | |
| 93 | + models: [ | |
| 94 | + { name: 'gemini-2.0-flash-thinking-exp', startsWith: true }, | |
| 95 | + { name: 'gemini-2.0-pro-exp', startsWith: true }, | |
| 96 | + ], | |
| 97 | + }, | |
| 98 | + }; | |
| 99 | + | |
| 100 | + const sourceConfig = hiddenReasoningModels[oai_settings.chat_completion_source]; | |
| 101 | + if (!sourceConfig) { | |
| 102 | + return false; | |
| 103 | + } | |
| 104 | + | |
| 105 | + return sourceConfig.models.some(model => { | |
| 106 | + if (typeof model === 'string') { | |
| 107 | + return sourceConfig.currentModel === model; | |
| 108 | + } | |
| 109 | + if (model.startsWith) { | |
| 110 | + return (sourceConfig.currentModel).startsWith(model.name); | |
| 111 | + } | |
| 112 | + if (model.matchingFunc) { | |
| 113 | + return model.matchingFunc(sourceConfig.currentModel); | |
| 114 | + } | |
| 115 | + return false; | |
| 116 | + }); | |
| 117 | +} | |
| 118 | + | |
| 119 | +/** | |
| 74 | 120 | * Updates the Reasoning UI. |
| 75 | 121 | * @param {number|JQuery<HTMLElement>|HTMLElement} messageIdOrElement The message ID or the message element. |
| 76 | 122 | * @param {string|null} [reasoning=null] The reasoning content. |