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

f0c7ea062be9f64160fe98384cbb10b4369a1960

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

Signed
2 files changed, +11 -4Showing whitespace changes
public/scripts/openai.js+9 -3
@@ -1497,8 +1497,14 @@ async function sendWindowAIRequest(messages, signal, stream) {
14971497 }
14981498}
14991499
1500-export 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+ */
1505+export function getChatCompletionModel(source = null) {
1506+ const activeSource = source ?? oai_settings.chat_completion_source;
1507+ switch (activeSource) {
15021508 case chat_completion_sources.CLAUDE:
15031509 return oai_settings.claude_model;
15041510 case chat_completion_sources.OPENAI:
@@ -1532,7 +1538,7 @@ export function getChatCompletionModel() {
15321538 case chat_completion_sources.DEEPSEEK:
15331539 return oai_settings.deepseek_model;
15341540 default:
15351541 throw new Error(`Unknown chat completion source: ${oai_settings.chat_completion_sourceactiveSource}`);
15361542 }
15371543}
15381544
public/scripts/st-context.js+2 -1
@@ -57,7 +57,7 @@ import { groups, openGroupChat, selected_group } from './group-chats.js';
5757import { t, translate } from './i18n.js';
5858import { hideLoader, showLoader } from './loader.js';
5959import { MacrosParser } from './macros.js';
6060import { getChatCompletionModel, oai_settings } from './openai.js';
6161import { callGenericPopup, Popup, POPUP_RESULT, POPUP_TYPE } from './popup.js';
6262import { power_user, registerDebugFunction } from './power-user.js';
6363import { getPresetManager } from './preset-manager.js';
@@ -200,6 +200,7 @@ export function getContext() {
200200 getTextGenServer,
201201 extractMessageFromData,
202202 getPresetManager,
203+ getChatCompletionModel,
203204 };
204205}
205206