Merge pull request #3558 from bmen25124/new_exports New exports - getChatCompletionModel

f0c7ea062be9f64160fe98384cbb10b4369a1960

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

Signed
2 files changed, +11 -4Ignore whitespace
public/scripts/openai.js+9 -3
@@ -1497,8 +1497,14 @@ async function sendWindowAIRequest(messages, signal, stream) {
1497 }1497 }
1498}1498}
14991499
1500export function getChatCompletionModel() {1500/**
1501 switch (oai_settings.chat_completion_source) {1501 * Gets the API model for the selected chat completion source.
1502 * @param {string} source If it's set, ignores active source
1503 * @returns {string} API model
1504 */
1505export function getChatCompletionModel(source = null) {
1506 const activeSource = source ?? oai_settings.chat_completion_source;
1507 switch (activeSource) {
1502 case chat_completion_sources.CLAUDE:1508 case chat_completion_sources.CLAUDE:
1503 return oai_settings.claude_model;1509 return oai_settings.claude_model;
1504 case chat_completion_sources.OPENAI:1510 case chat_completion_sources.OPENAI:
@@ -1532,7 +1538,7 @@ export function getChatCompletionModel() {
1532 case chat_completion_sources.DEEPSEEK:1538 case chat_completion_sources.DEEPSEEK:
1533 return oai_settings.deepseek_model;1539 return oai_settings.deepseek_model;
1534 default:1540 default:
1535 throw new Error(`Unknown chat completion source: ${oai_settings.chat_completion_source}`);1541 throw new Error(`Unknown chat completion source: ${activeSource}`);
1536 }1542 }
1537}1543}
15381544
public/scripts/st-context.js+2 -1
@@ -57,7 +57,7 @@ import { groups, openGroupChat, selected_group } from './group-chats.js';
57import { t, translate } from './i18n.js';57import { t, translate } from './i18n.js';
58import { hideLoader, showLoader } from './loader.js';58import { hideLoader, showLoader } from './loader.js';
59import { MacrosParser } from './macros.js';59import { MacrosParser } from './macros.js';
60import { oai_settings } from './openai.js';60import { getChatCompletionModel, oai_settings } from './openai.js';
61import { callGenericPopup, Popup, POPUP_RESULT, POPUP_TYPE } from './popup.js';61import { callGenericPopup, Popup, POPUP_RESULT, POPUP_TYPE } from './popup.js';
62import { power_user, registerDebugFunction } from './power-user.js';62import { power_user, registerDebugFunction } from './power-user.js';
63import { getPresetManager } from './preset-manager.js';63import { getPresetManager } from './preset-manager.js';
@@ -200,6 +200,7 @@ export function getContext() {
200 getTextGenServer,200 getTextGenServer,
201 extractMessageFromData,201 extractMessageFromData,
202 getPresetManager,202 getPresetManager,
203 getChatCompletionModel,
203 };204 };
204}205}
205206