Exported getChatCompletionModel with optional parameter
| @@ -1497,8 +1497,14 @@ async function sendWindowAIRequest(messages, signal, stream) { | ||
| 1497 | 1497 | } |
| 1498 | 1498 | } |
| 1499 | 1499 | |
| 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) { | |
| 1502 | 1508 | case chat_completion_sources.CLAUDE: |
| 1503 | 1509 | return oai_settings.claude_model; |
| 1504 | 1510 | case chat_completion_sources.OPENAI: |
| @@ -1532,7 +1538,7 @@ export function getChatCompletionModel() { | ||
| 1532 | 1538 | case chat_completion_sources.DEEPSEEK: |
| 1533 | 1539 | return oai_settings.deepseek_model; |
| 1534 | 1540 | default: |
| 1535 | 1541 | throw new Error(`Unknown chat completion source: ${oai_settings.chat_completion_sourceactiveSource}`); |
| 1536 | 1542 | } |
| 1537 | 1543 | } |
| 1538 | 1544 | |
| @@ -57,7 +57,7 @@ import { groups, openGroupChat, selected_group } from './group-chats.js'; | ||
| 57 | 57 | import { t, translate } from './i18n.js'; |
| 58 | 58 | import { hideLoader, showLoader } from './loader.js'; |
| 59 | 59 | import { MacrosParser } from './macros.js'; |
| 60 | 60 | import { getChatCompletionModel, oai_settings } from './openai.js'; |
| 61 | 61 | import { callGenericPopup, Popup, POPUP_RESULT, POPUP_TYPE } from './popup.js'; |
| 62 | 62 | import { power_user, registerDebugFunction } from './power-user.js'; |
| 63 | 63 | import { getPresetManager } from './preset-manager.js'; |
| @@ -200,6 +200,7 @@ export function getContext() { | ||
| 200 | 200 | getTextGenServer, |
| 201 | 201 | extractMessageFromData, |
| 202 | 202 | getPresetManager, |
| 203 | + getChatCompletionModel, | |
| 203 | 204 | }; |
| 204 | 205 | } |
| 205 | 206 | |