Merge pull request #3558 from bmen25124/new_exports New exports - getChatCompletionModel
Signed| @@ -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 | 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 | } |
| 1538 | 1544 | ||
| @@ -57,7 +57,7 @@ import { groups, openGroupChat, selected_group } from './group-chats.js'; | |||
| 57 | import { t, translate } from './i18n.js'; | 57 | import { t, translate } from './i18n.js'; |
| 58 | import { hideLoader, showLoader } from './loader.js'; | 58 | import { hideLoader, showLoader } from './loader.js'; |
| 59 | import { MacrosParser } from './macros.js'; | 59 | import { MacrosParser } from './macros.js'; |
| 60 | import { oai_settings } from './openai.js'; | 60 | import { getChatCompletionModel, oai_settings } from './openai.js'; |
| 61 | import { callGenericPopup, Popup, POPUP_RESULT, POPUP_TYPE } from './popup.js'; | 61 | import { callGenericPopup, Popup, POPUP_RESULT, POPUP_TYPE } from './popup.js'; |
| 62 | import { power_user, registerDebugFunction } from './power-user.js'; | 62 | import { power_user, registerDebugFunction } from './power-user.js'; |
| 63 | import { getPresetManager } from './preset-manager.js'; | 63 | import { 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 | } |
| 205 | 206 | ||