mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Move isHiddenReasoningModel
This commit is contained in:
@ -113,7 +113,6 @@ import {
|
|||||||
loadProxyPresets,
|
loadProxyPresets,
|
||||||
selected_proxy,
|
selected_proxy,
|
||||||
initOpenAI,
|
initOpenAI,
|
||||||
isHiddenReasoningModel,
|
|
||||||
} from './scripts/openai.js';
|
} from './scripts/openai.js';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -270,7 +269,7 @@ import { initSettingsSearch } from './scripts/setting-search.js';
|
|||||||
import { initBulkEdit } from './scripts/bulk-edit.js';
|
import { initBulkEdit } from './scripts/bulk-edit.js';
|
||||||
import { deriveTemplatesFromChatTemplate } from './scripts/chat-templates.js';
|
import { deriveTemplatesFromChatTemplate } from './scripts/chat-templates.js';
|
||||||
import { getContext } from './scripts/st-context.js';
|
import { getContext } from './scripts/st-context.js';
|
||||||
import { extractReasoningFromData, initReasoning, PromptReasoning, updateReasoningTimeUI, updateReasoningUI } from './scripts/reasoning.js';
|
import { extractReasoningFromData, initReasoning, isHiddenReasoningModel, PromptReasoning, updateReasoningUI } from './scripts/reasoning.js';
|
||||||
|
|
||||||
// API OBJECT FOR EXTERNAL WIRING
|
// API OBJECT FOR EXTERNAL WIRING
|
||||||
globalThis.SillyTavern = {
|
globalThis.SillyTavern = {
|
||||||
|
@ -4995,54 +4995,6 @@ export function isImageInliningSupported() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if the model supports reasoning, but does not send back the reasoning
|
|
||||||
* @returns {boolean} True if the model supports reasoning
|
|
||||||
*/
|
|
||||||
export function isHiddenReasoningModel() {
|
|
||||||
if (main_api !== 'openai') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @typedef {Object.<chat_completion_sources, { currentModel: string; models: ({ name: string; startsWith: boolean?; matchingFunc: (model: string) => boolean?; }|string)[]; }>} */
|
|
||||||
const hiddenReasoningModels = {
|
|
||||||
[chat_completion_sources.OPENAI]: {
|
|
||||||
currentModel: oai_settings.openai_model,
|
|
||||||
models: [
|
|
||||||
{ name: 'o1', startsWith: true },
|
|
||||||
{ name: 'o3', startsWith: true },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
[chat_completion_sources.MAKERSUITE]: {
|
|
||||||
currentModel: oai_settings.google_model,
|
|
||||||
models: [
|
|
||||||
{ name: 'gemini-2.0-flash-thinking-exp', startsWith: true },
|
|
||||||
{ name: 'gemini-2.0-pro-exp', startsWith: true },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const sourceConfig = hiddenReasoningModels[oai_settings.chat_completion_source];
|
|
||||||
if (!sourceConfig) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sourceConfig.models.some(model => {
|
|
||||||
if (typeof model === 'string') {
|
|
||||||
return sourceConfig.currentModel === model;
|
|
||||||
}
|
|
||||||
if (model.startsWith) {
|
|
||||||
return (sourceConfig.currentModel).startsWith(model.name);
|
|
||||||
}
|
|
||||||
if (model.matchingFunc) {
|
|
||||||
return model.matchingFunc(sourceConfig.currentModel);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Proxy stuff
|
* Proxy stuff
|
||||||
*/
|
*/
|
||||||
|
@ -5,7 +5,7 @@ import { chat, closeMessageEditor, event_types, eventSource, main_api, messageFo
|
|||||||
import { getRegexedString, regex_placement } from './extensions/regex/engine.js';
|
import { getRegexedString, regex_placement } from './extensions/regex/engine.js';
|
||||||
import { getCurrentLocale, t } from './i18n.js';
|
import { getCurrentLocale, t } from './i18n.js';
|
||||||
import { MacrosParser } from './macros.js';
|
import { MacrosParser } from './macros.js';
|
||||||
import { chat_completion_sources, isHiddenReasoningModel, oai_settings } from './openai.js';
|
import { chat_completion_sources, oai_settings } from './openai.js';
|
||||||
import { Popup } from './popup.js';
|
import { Popup } from './popup.js';
|
||||||
import { power_user } from './power-user.js';
|
import { power_user } from './power-user.js';
|
||||||
import { SlashCommand } from './slash-commands/SlashCommand.js';
|
import { SlashCommand } from './slash-commands/SlashCommand.js';
|
||||||
@ -70,6 +70,52 @@ export function extractReasoningFromData(data) {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the model supports reasoning, but does not send back the reasoning
|
||||||
|
* @returns {boolean} True if the model supports reasoning
|
||||||
|
*/
|
||||||
|
export function isHiddenReasoningModel() {
|
||||||
|
if (main_api !== 'openai') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @typedef {Object.<chat_completion_sources, { currentModel: string; models: ({ name: string; startsWith: boolean?; matchingFunc: (model: string) => boolean?; }|string)[]; }>} */
|
||||||
|
const hiddenReasoningModels = {
|
||||||
|
[chat_completion_sources.OPENAI]: {
|
||||||
|
currentModel: oai_settings.openai_model,
|
||||||
|
models: [
|
||||||
|
{ name: 'o1', startsWith: true },
|
||||||
|
{ name: 'o3', startsWith: true },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
[chat_completion_sources.MAKERSUITE]: {
|
||||||
|
currentModel: oai_settings.google_model,
|
||||||
|
models: [
|
||||||
|
{ name: 'gemini-2.0-flash-thinking-exp', startsWith: true },
|
||||||
|
{ name: 'gemini-2.0-pro-exp', startsWith: true },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const sourceConfig = hiddenReasoningModels[oai_settings.chat_completion_source];
|
||||||
|
if (!sourceConfig) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sourceConfig.models.some(model => {
|
||||||
|
if (typeof model === 'string') {
|
||||||
|
return sourceConfig.currentModel === model;
|
||||||
|
}
|
||||||
|
if (model.startsWith) {
|
||||||
|
return (sourceConfig.currentModel).startsWith(model.name);
|
||||||
|
}
|
||||||
|
if (model.matchingFunc) {
|
||||||
|
return model.matchingFunc(sourceConfig.currentModel);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the Reasoning UI.
|
* Updates the Reasoning UI.
|
||||||
* @param {number|JQuery<HTMLElement>|HTMLElement} messageIdOrElement The message ID or the message element.
|
* @param {number|JQuery<HTMLElement>|HTMLElement} messageIdOrElement The message ID or the message element.
|
||||||
|
Reference in New Issue
Block a user