Add Fireworks AI Provider Support (#4374) * add fireworks provider * fix * add context length * Fireworks fixes * Add logo image --------- Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>
Signed| @@ -0,0 +1 @@ | |||
| 1 | <svg preserveAspectRatio="xMinYMid meet" class="h-5" viewBox="0 0 638 315" xmlns="http://www.w3.org/2000/svg"><path d="M318.563 221.755C300.863 221.755 284.979 211.247 278.206 194.978L196.549 0H244.342L318.842 178.361L393.273 0H441.066L358.92 195.048C352.112 211.247 336.263 221.755 318.563 221.755Z"></path><path d="M425.111 314.933C407.481 314.933 391.667 304.494 384.824 288.366C377.947 272.097 381.507 253.524 393.936 240.921L542.657 90.2803L561.229 134.094L425.076 271.748L619.147 270.666L637.72 314.479L425.146 315.003L425.076 314.933H425.111Z"></path><path d="M0 314.408L18.5727 270.595L212.643 271.677L76.525 133.988L95.0977 90.1748L243.819 240.816C256.247 253.384 259.843 272.026 252.93 288.26C246.088 304.424 230.203 314.827 212.643 314.827L0.0698221 314.339L0 314.408Z"></path></svg> | ||
| @@ -691,7 +691,7 @@ | |||
| 691 | </span> | 691 | </span> |
| 692 | </div> | 692 | </div> |
| 693 | </div> | 693 | </div> |
| 694 | <div class="range-block" data-source="openai,claude,aimlapi,openrouter,ai21,makersuite,vertexai,mistralai,custom,cohere,perplexity,groq,nanogpt,deepseek,xai,pollinations,moonshot"> | 694 | <div class="range-block" data-source="openai,claude,aimlapi,openrouter,ai21,makersuite,vertexai,mistralai,custom,cohere,perplexity,groq,nanogpt,deepseek,xai,pollinations,moonshot,fireworks"> |
| 695 | <div class="range-block-title" data-i18n="Temperature"> | 695 | <div class="range-block-title" data-i18n="Temperature"> |
| 696 | Temperature | 696 | Temperature |
| 697 | </div> | 697 | </div> |
| @@ -704,7 +704,7 @@ | |||
| 704 | </div> | 704 | </div> |
| 705 | </div> | 705 | </div> |
| 706 | </div> | 706 | </div> |
| 707 | <div class="range-block" data-source="openai,aimlapi,openrouter,custom,cohere,perplexity,groq,mistralai,nanogpt,deepseek,xai,pollinations,moonshot"> | 707 | <div class="range-block" data-source="openai,aimlapi,openrouter,custom,cohere,perplexity,groq,mistralai,nanogpt,deepseek,xai,pollinations,moonshot,fireworks"> |
| 708 | <div class="range-block-title" data-i18n="Frequency Penalty"> | 708 | <div class="range-block-title" data-i18n="Frequency Penalty"> |
| 709 | Frequency Penalty | 709 | Frequency Penalty |
| 710 | </div> | 710 | </div> |
| @@ -717,7 +717,7 @@ | |||
| 717 | </div> | 717 | </div> |
| 718 | </div> | 718 | </div> |
| 719 | </div> | 719 | </div> |
| 720 | <div class="range-block" data-source="openai,aimlapi,openrouter,custom,cohere,perplexity,groq,mistralai,nanogpt,deepseek,xai,pollinations,moonshot"> | 720 | <div class="range-block" data-source="openai,aimlapi,openrouter,custom,cohere,perplexity,groq,mistralai,nanogpt,deepseek,xai,pollinations,moonshot,fireworks"> |
| 721 | <div class="range-block-title" data-i18n="Presence Penalty"> | 721 | <div class="range-block-title" data-i18n="Presence Penalty"> |
| 722 | Presence Penalty | 722 | Presence Penalty |
| 723 | </div> | 723 | </div> |
| @@ -743,7 +743,7 @@ | |||
| 743 | </div> | 743 | </div> |
| 744 | </div> | 744 | </div> |
| 745 | </div> | 745 | </div> |
| 746 | <div class="range-block" data-source="openai,claude,aimlapi,openrouter,ai21,makersuite,vertexai,mistralai,custom,cohere,perplexity,groq,nanogpt,deepseek,xai,pollinations,moonshot"> | 746 | <div class="range-block" data-source="openai,claude,aimlapi,openrouter,ai21,makersuite,vertexai,mistralai,custom,cohere,perplexity,groq,nanogpt,deepseek,xai,pollinations,moonshot,fireworks"> |
| 747 | <div class="range-block-title" data-i18n="Top P"> | 747 | <div class="range-block-title" data-i18n="Top P"> |
| 748 | Top P | 748 | Top P |
| 749 | </div> | 749 | </div> |
| @@ -1984,7 +1984,7 @@ | |||
| 1984 | </b> | 1984 | </b> |
| 1985 | </div> | 1985 | </div> |
| 1986 | </div> | 1986 | </div> |
| 1987 | <div class="range-block" data-source="openai,cohere,mistralai,custom,claude,aimlapi,openrouter,groq,deepseek,makersuite,vertexai,ai21,xai,pollinations,moonshot"> | 1987 | <div class="range-block" data-source="openai,cohere,mistralai,custom,claude,aimlapi,openrouter,groq,deepseek,makersuite,vertexai,ai21,xai,pollinations,moonshot,fireworks"> |
| 1988 | <label for="openai_function_calling" class="checkbox_label flexWrap widthFreeExpand"> | 1988 | <label for="openai_function_calling" class="checkbox_label flexWrap widthFreeExpand"> |
| 1989 | <input id="openai_function_calling" type="checkbox" /> | 1989 | <input id="openai_function_calling" type="checkbox" /> |
| 1990 | <span data-i18n="Enable function calling">Enable function calling</span> | 1990 | <span data-i18n="Enable function calling">Enable function calling</span> |
| @@ -2065,7 +2065,7 @@ | |||
| 2065 | </span> | 2065 | </span> |
| 2066 | </div> | 2066 | </div> |
| 2067 | </div> | 2067 | </div> |
| 2068 | <div class="range-block" data-source="deepseek,aimlapi,openrouter,custom,claude,xai,makersuite,vertexai,pollinations,moonshot,mistralai"> | 2068 | <div class="range-block" data-source="deepseek,aimlapi,openrouter,custom,claude,xai,makersuite,vertexai,pollinations,moonshot,mistralai,fireworks"> |
| 2069 | <label for="openai_show_thoughts" class="checkbox_label widthFreeExpand"> | 2069 | <label for="openai_show_thoughts" class="checkbox_label widthFreeExpand"> |
| 2070 | <input id="openai_show_thoughts" type="checkbox" /> | 2070 | <input id="openai_show_thoughts" type="checkbox" /> |
| 2071 | <span data-i18n="Request model reasoning">Request model reasoning</span> | 2071 | <span data-i18n="Request model reasoning">Request model reasoning</span> |
| @@ -2793,6 +2793,7 @@ | |||
| 2793 | <option value="claude">Claude</option> | 2793 | <option value="claude">Claude</option> |
| 2794 | <option value="cohere">Cohere</option> | 2794 | <option value="cohere">Cohere</option> |
| 2795 | <option value="deepseek">DeepSeek</option> | 2795 | <option value="deepseek">DeepSeek</option> |
| 2796 | <option value="fireworks">Fireworks AI</option> | ||
| 2796 | <option value="groq">Groq</option> | 2797 | <option value="groq">Groq</option> |
| 2797 | <option value="makersuite">Google AI Studio</option> | 2798 | <option value="makersuite">Google AI Studio</option> |
| 2798 | <option value="vertexai">Google Vertex AI</option> | 2799 | <option value="vertexai">Google Vertex AI</option> |
| @@ -3484,6 +3485,22 @@ | |||
| 3484 | </select> | 3485 | </select> |
| 3485 | </div> | 3486 | </div> |
| 3486 | </div> | 3487 | </div> |
| 3488 | <div id="fireworks_form" data-source="fireworks"> | ||
| 3489 | <h4 data-i18n="Fireworks AI API Key">Fireworks AI API Key</h4> | ||
| 3490 | <div class="flex-container"> | ||
| 3491 | <input id="api_key_fireworks" name="api_key_fireworks" class="text_pole flex1" value="" type="text" autocomplete="off"> | ||
| 3492 | <div title="Manage API keys" data-i18n="[title]Manage API keys" class="menu_button fa-solid fa-key fa-fw manage-api-keys" data-key="api_key_fireworks"></div> | ||
| 3493 | </div> | ||
| 3494 | <div data-for="api_key_fireworks" class="neutral_warning" data-i18n="For privacy reasons, your API key will be hidden after you click 'Connect'."> | ||
| 3495 | For privacy reasons, your API key will be hidden after you click 'Connect'. | ||
| 3496 | </div> | ||
| 3497 | <div> | ||
| 3498 | <h4 data-i18n="Fireworks AI Model">Fireworks AI Model</h4> | ||
| 3499 | <select id="model_fireworks_select"> | ||
| 3500 | <option value="" data-i18n="-- Connect to the API --">-- Connect to the API --</option> | ||
| 3501 | </select> | ||
| 3502 | </div> | ||
| 3503 | </div> | ||
| 3487 | <div id="perplexity_form" data-source="perplexity"> | 3504 | <div id="perplexity_form" data-source="perplexity"> |
| 3488 | <h4 data-i18n="Perplexity API Key">Perplexity API Key</h4> | 3505 | <h4 data-i18n="Perplexity API Key">Perplexity API Key</h4> |
| 3489 | <div class="flex-container"> | 3506 | <div class="flex-container"> |
| @@ -407,6 +407,7 @@ function RA_autoconnect(PrevApi) { | |||
| 407 | || (secret_state[SECRET_KEYS.XAI] && oai_settings.chat_completion_source == chat_completion_sources.XAI) | 407 | || (secret_state[SECRET_KEYS.XAI] && oai_settings.chat_completion_source == chat_completion_sources.XAI) |
| 408 | || (secret_state[SECRET_KEYS.AIMLAPI] && oai_settings.chat_completion_source == chat_completion_sources.AIMLAPI) | 408 | || (secret_state[SECRET_KEYS.AIMLAPI] && oai_settings.chat_completion_source == chat_completion_sources.AIMLAPI) |
| 409 | || (secret_state[SECRET_KEYS.MOONSHOT] && oai_settings.chat_completion_source == chat_completion_sources.MOONSHOT) | 409 | || (secret_state[SECRET_KEYS.MOONSHOT] && oai_settings.chat_completion_source == chat_completion_sources.MOONSHOT) |
| 410 | || (secret_state[SECRET_KEYS.FIREWORKS] && oai_settings.chat_completion_source == chat_completion_sources.FIREWORKS) | ||
| 410 | || (oai_settings.chat_completion_source === chat_completion_sources.POLLINATIONS) | 411 | || (oai_settings.chat_completion_source === chat_completion_sources.POLLINATIONS) |
| 411 | || (isValidUrl(oai_settings.custom_url) && oai_settings.chat_completion_source == chat_completion_sources.CUSTOM) | 412 | || (isValidUrl(oai_settings.custom_url) && oai_settings.chat_completion_source == chat_completion_sources.CUSTOM) |
| 412 | ) { | 413 | ) { |
| @@ -185,6 +185,7 @@ export const chat_completion_sources = { | |||
| 185 | XAI: 'xai', | 185 | XAI: 'xai', |
| 186 | POLLINATIONS: 'pollinations', | 186 | POLLINATIONS: 'pollinations', |
| 187 | MOONSHOT: 'moonshot', | 187 | MOONSHOT: 'moonshot', |
| 188 | FIREWORKS: 'fireworks', | ||
| 188 | }; | 189 | }; |
| 189 | 190 | ||
| 190 | const character_names_behavior = { | 191 | const character_names_behavior = { |
| @@ -458,6 +459,7 @@ const oai_settings = { | |||
| 458 | xai_model: 'grok-3-beta', | 459 | xai_model: 'grok-3-beta', |
| 459 | pollinations_model: 'openai', | 460 | pollinations_model: 'openai', |
| 460 | moonshot_model: 'kimi-latest', | 461 | moonshot_model: 'kimi-latest', |
| 462 | fireworks_model: 'accounts/fireworks/models/kimi-k2-instruct', | ||
| 461 | custom_model: '', | 463 | custom_model: '', |
| 462 | custom_url: '', | 464 | custom_url: '', |
| 463 | custom_include_body: '', | 465 | custom_include_body: '', |
| @@ -1620,6 +1622,8 @@ export function getChatCompletionModel(source = null) { | |||
| 1620 | return oai_settings.pollinations_model; | 1622 | return oai_settings.pollinations_model; |
| 1621 | case chat_completion_sources.MOONSHOT: | 1623 | case chat_completion_sources.MOONSHOT: |
| 1622 | return oai_settings.moonshot_model; | 1624 | return oai_settings.moonshot_model; |
| 1625 | case chat_completion_sources.FIREWORKS: | ||
| 1626 | return oai_settings.fireworks_model; | ||
| 1623 | default: | 1627 | default: |
| 1624 | console.error(`Unknown chat completion source: ${activeSource}`); | 1628 | console.error(`Unknown chat completion source: ${activeSource}`); |
| 1625 | return ''; | 1629 | return ''; |
| @@ -1872,6 +1876,27 @@ function saveModelList(data) { | |||
| 1872 | 1876 | ||
| 1873 | $('#model_groq_select').val(oai_settings.groq_model).trigger('change'); | 1877 | $('#model_groq_select').val(oai_settings.groq_model).trigger('change'); |
| 1874 | } | 1878 | } |
| 1879 | |||
| 1880 | if (oai_settings.chat_completion_source === chat_completion_sources.FIREWORKS) { | ||
| 1881 | $('#model_fireworks_select').empty(); | ||
| 1882 | model_list.forEach((model) => { | ||
| 1883 | if (!model?.supports_chat) { | ||
| 1884 | return; | ||
| 1885 | } | ||
| 1886 | $('#model_fireworks_select').append( | ||
| 1887 | $('<option>', { | ||
| 1888 | value: model.id, | ||
| 1889 | text: model.id, | ||
| 1890 | })); | ||
| 1891 | }); | ||
| 1892 | |||
| 1893 | const selectedModel = model_list.find(model => model.id === oai_settings.fireworks_model); | ||
| 1894 | if (model_list.length > 0 && (!selectedModel || !oai_settings.fireworks_model)) { | ||
| 1895 | oai_settings.fireworks_model = model_list[0].id; | ||
| 1896 | } | ||
| 1897 | |||
| 1898 | $('#model_fireworks_select').val(oai_settings.fireworks_model).trigger('change'); | ||
| 1899 | } | ||
| 1875 | } | 1900 | } |
| 1876 | 1901 | ||
| 1877 | function appendOpenRouterOptions(model_list, groupModels = false, sort = false) { | 1902 | function appendOpenRouterOptions(model_list, groupModels = false, sort = false) { |
| @@ -4487,6 +4512,31 @@ function getMoonshotMaxContext(model, isUnlocked) { | |||
| 4487 | return Object.entries(contextMap).find(([key]) => model.includes(key))?.[1] || max_32k; | 4512 | return Object.entries(contextMap).find(([key]) => model.includes(key))?.[1] || max_32k; |
| 4488 | } | 4513 | } |
| 4489 | 4514 | ||
| 4515 | /** | ||
| 4516 | * Get the maximum context size for the Fireworks model | ||
| 4517 | * @param {string} model Model identifier | ||
| 4518 | * @param {boolean} isUnlocked Whether context limits are unlocked | ||
| 4519 | * @returns {number} Maximum context size in tokens | ||
| 4520 | */ | ||
| 4521 | function getFireworksMaxContext(model, isUnlocked) { | ||
| 4522 | if (isUnlocked) { | ||
| 4523 | return unlocked_max; | ||
| 4524 | } | ||
| 4525 | |||
| 4526 | // First check if model info is available from model_list | ||
| 4527 | if (Array.isArray(model_list) && model_list.length > 0) { | ||
| 4528 | const modelInfo = model_list.find((record) => record.id === model); | ||
| 4529 | if (modelInfo?.context_length) { | ||
| 4530 | return modelInfo.context_length; | ||
| 4531 | } | ||
| 4532 | if (modelInfo?.context_window) { | ||
| 4533 | return modelInfo.context_window; | ||
| 4534 | } | ||
| 4535 | } | ||
| 4536 | |||
| 4537 | return max_32k; | ||
| 4538 | } | ||
| 4539 | |||
| 4490 | async function onModelChange() { | 4540 | async function onModelChange() { |
| 4491 | biasCache = undefined; | 4541 | biasCache = undefined; |
| 4492 | let value = String($(this).val() || ''); | 4542 | let value = String($(this).val() || ''); |
| @@ -4627,6 +4677,15 @@ async function onModelChange() { | |||
| 4627 | oai_settings.moonshot_model = value; | 4677 | oai_settings.moonshot_model = value; |
| 4628 | } | 4678 | } |
| 4629 | 4679 | ||
| 4680 | if ($(this).is('#model_fireworks_select')) { | ||
| 4681 | if (!value) { | ||
| 4682 | console.debug('Null Fireworks model selected. Ignoring.'); | ||
| 4683 | return; | ||
| 4684 | } | ||
| 4685 | console.log('Fireworks model changed to', value); | ||
| 4686 | oai_settings.fireworks_model = value; | ||
| 4687 | } | ||
| 4688 | |||
| 4630 | if ([chat_completion_sources.MAKERSUITE, chat_completion_sources.VERTEXAI].includes(oai_settings.chat_completion_source)) { | 4689 | if ([chat_completion_sources.MAKERSUITE, chat_completion_sources.VERTEXAI].includes(oai_settings.chat_completion_source)) { |
| 4631 | if (oai_settings.max_context_unlocked) { | 4690 | if (oai_settings.max_context_unlocked) { |
| 4632 | $('#openai_max_context').attr('max', max_2mil); | 4691 | $('#openai_max_context').attr('max', max_2mil); |
| @@ -4899,6 +4958,15 @@ async function onModelChange() { | |||
| 4899 | $('#temp_openai').attr('max', claude_max_temp).val(oai_settings.temp_openai).trigger('input'); | 4958 | $('#temp_openai').attr('max', claude_max_temp).val(oai_settings.temp_openai).trigger('input'); |
| 4900 | } | 4959 | } |
| 4901 | 4960 | ||
| 4961 | if (oai_settings.chat_completion_source === chat_completion_sources.FIREWORKS) { | ||
| 4962 | const maxContext = getFireworksMaxContext(oai_settings.fireworks_model, oai_settings.max_context_unlocked); | ||
| 4963 | $('#openai_max_context').attr('max', maxContext); | ||
| 4964 | oai_settings.openai_max_context = Math.min(Number($('#openai_max_context').attr('max')), oai_settings.openai_max_context); | ||
| 4965 | $('#openai_max_context').val(oai_settings.openai_max_context).trigger('input'); | ||
| 4966 | oai_settings.temp_openai = Math.min(oai_max_temp, oai_settings.temp_openai); | ||
| 4967 | $('#temp_openai').attr('max', oai_max_temp).val(oai_settings.temp_openai).trigger('input'); | ||
| 4968 | } | ||
| 4969 | |||
| 4902 | $('#openai_max_context_counter').attr('max', Number($('#openai_max_context').attr('max'))); | 4970 | $('#openai_max_context_counter').attr('max', Number($('#openai_max_context').attr('max'))); |
| 4903 | 4971 | ||
| 4904 | saveSettingsDebounced(); | 4972 | saveSettingsDebounced(); |
| @@ -5143,6 +5211,19 @@ async function onConnectButtonClick(e) { | |||
| 5143 | } | 5211 | } |
| 5144 | } | 5212 | } |
| 5145 | 5213 | ||
| 5214 | if (oai_settings.chat_completion_source == chat_completion_sources.FIREWORKS) { | ||
| 5215 | const api_key_fireworks = String($('#api_key_fireworks').val()).trim(); | ||
| 5216 | |||
| 5217 | if (api_key_fireworks.length) { | ||
| 5218 | await writeSecret(SECRET_KEYS.FIREWORKS, api_key_fireworks); | ||
| 5219 | } | ||
| 5220 | |||
| 5221 | if (!secret_state[SECRET_KEYS.FIREWORKS]) { | ||
| 5222 | console.log('No secret key saved for Fireworks'); | ||
| 5223 | return; | ||
| 5224 | } | ||
| 5225 | } | ||
| 5226 | |||
| 5146 | startStatusLoading(); | 5227 | startStatusLoading(); |
| 5147 | saveSettingsDebounced(); | 5228 | saveSettingsDebounced(); |
| 5148 | await getStatusOpen(); | 5229 | await getStatusOpen(); |
| @@ -5207,6 +5288,9 @@ function toggleChatCompletionForms() { | |||
| 5207 | else if (oai_settings.chat_completion_source == chat_completion_sources.MOONSHOT) { | 5288 | else if (oai_settings.chat_completion_source == chat_completion_sources.MOONSHOT) { |
| 5208 | $('#model_moonshot_select').trigger('change'); | 5289 | $('#model_moonshot_select').trigger('change'); |
| 5209 | } | 5290 | } |
| 5291 | else if (oai_settings.chat_completion_source == chat_completion_sources.FIREWORKS) { | ||
| 5292 | $('#model_fireworks_select').trigger('change'); | ||
| 5293 | } | ||
| 5210 | $('[data-source]').each(function () { | 5294 | $('[data-source]').each(function () { |
| 5211 | const validSources = $(this).data('source').split(','); | 5295 | const validSources = $(this).data('source').split(','); |
| 5212 | $(this).toggle(validSources.includes(oai_settings.chat_completion_source)); | 5296 | $(this).toggle(validSources.includes(oai_settings.chat_completion_source)); |
| @@ -6139,6 +6223,7 @@ export function initOpenAI() { | |||
| 6139 | $('#model_xai_select').on('change', onModelChange); | 6223 | $('#model_xai_select').on('change', onModelChange); |
| 6140 | $('#model_pollinations_select').on('change', onModelChange); | 6224 | $('#model_pollinations_select').on('change', onModelChange); |
| 6141 | $('#model_moonshot_select').on('change', onModelChange); | 6225 | $('#model_moonshot_select').on('change', onModelChange); |
| 6226 | $('#model_fireworks_select').on('change', onModelChange); | ||
| 6142 | $('#settings_preset_openai').on('change', onSettingsPresetChange); | 6227 | $('#settings_preset_openai').on('change', onSettingsPresetChange); |
| 6143 | $('#new_oai_preset').on('click', onNewPresetClick); | 6228 | $('#new_oai_preset').on('click', onNewPresetClick); |
| 6144 | $('#delete_oai_preset').on('click', onDeletePresetClick); | 6229 | $('#delete_oai_preset').on('click', onDeletePresetClick); |
| @@ -60,6 +60,7 @@ export const SECRET_KEYS = { | |||
| 60 | AIMLAPI: 'api_key_aimlapi', | 60 | AIMLAPI: 'api_key_aimlapi', |
| 61 | FALAI: 'api_key_falai', | 61 | FALAI: 'api_key_falai', |
| 62 | XAI: 'api_key_xai', | 62 | XAI: 'api_key_xai', |
| 63 | FIREWORKS: 'api_key_fireworks', | ||
| 63 | VERTEXAI_SERVICE_ACCOUNT: 'vertexai_service_account_json', | 64 | VERTEXAI_SERVICE_ACCOUNT: 'vertexai_service_account_json', |
| 64 | MINIMAX: 'api_key_minimax', | 65 | MINIMAX: 'api_key_minimax', |
| 65 | MINIMAX_GROUP_ID: 'minimax_group_id', | 66 | MINIMAX_GROUP_ID: 'minimax_group_id', |
| @@ -107,6 +108,7 @@ const FRIENDLY_NAMES = { | |||
| 107 | [SECRET_KEYS.FALAI]: 'FAL.AI', | 108 | [SECRET_KEYS.FALAI]: 'FAL.AI', |
| 108 | [SECRET_KEYS.AZURE_TTS]: 'Azure TTS', | 109 | [SECRET_KEYS.AZURE_TTS]: 'Azure TTS', |
| 109 | [SECRET_KEYS.AIMLAPI]: 'AI/ML API', | 110 | [SECRET_KEYS.AIMLAPI]: 'AI/ML API', |
| 111 | [SECRET_KEYS.FIREWORKS]: 'Fireworks AI', | ||
| 110 | [SECRET_KEYS.DEEPL]: 'DeepL', | 112 | [SECRET_KEYS.DEEPL]: 'DeepL', |
| 111 | [SECRET_KEYS.LIBRE]: 'LibreTranslate', | 113 | [SECRET_KEYS.LIBRE]: 'LibreTranslate', |
| 112 | [SECRET_KEYS.LIBRE_URL]: 'LibreTranslate Endpoint (e.g. http://127.0.0.1:5000/translate)', | 114 | [SECRET_KEYS.LIBRE_URL]: 'LibreTranslate Endpoint (e.g. http://127.0.0.1:5000/translate)', |
| @@ -151,6 +153,7 @@ const INPUT_MAP = { | |||
| 151 | [SECRET_KEYS.XAI]: '#api_key_xai', | 153 | [SECRET_KEYS.XAI]: '#api_key_xai', |
| 152 | [SECRET_KEYS.VERTEXAI_SERVICE_ACCOUNT]: '#vertexai_service_account_json', | 154 | [SECRET_KEYS.VERTEXAI_SERVICE_ACCOUNT]: '#vertexai_service_account_json', |
| 153 | [SECRET_KEYS.MOONSHOT]: '#api_key_moonshot', | 155 | [SECRET_KEYS.MOONSHOT]: '#api_key_moonshot', |
| 156 | [SECRET_KEYS.FIREWORKS]: '#api_key_fireworks', | ||
| 154 | }; | 157 | }; |
| 155 | 158 | ||
| 156 | const getLabel = () => moment().format('L LT'); | 159 | const getLabel = () => moment().format('L LT'); |
| @@ -4855,6 +4855,7 @@ function getModelOptions(quiet) { | |||
| 4855 | { id: 'model_xai_select', api: 'openai', type: chat_completion_sources.XAI }, | 4855 | { id: 'model_xai_select', api: 'openai', type: chat_completion_sources.XAI }, |
| 4856 | { id: 'model_pollinations_select', api: 'openai', type: chat_completion_sources.POLLINATIONS }, | 4856 | { id: 'model_pollinations_select', api: 'openai', type: chat_completion_sources.POLLINATIONS }, |
| 4857 | { id: 'model_moonshot_select', api: 'openai', type: chat_completion_sources.MOONSHOT }, | 4857 | { id: 'model_moonshot_select', api: 'openai', type: chat_completion_sources.MOONSHOT }, |
| 4858 | { id: 'model_fireworks_select', api: 'openai', type: chat_completion_sources.FIREWORKS }, | ||
| 4858 | { id: 'model_novel_select', api: 'novel', type: null }, | 4859 | { id: 'model_novel_select', api: 'novel', type: null }, |
| 4859 | { id: 'horde_model', api: 'koboldhorde', type: null }, | 4860 | { id: 'horde_model', api: 'koboldhorde', type: null }, |
| 4860 | ]; | 4861 | ]; |
| @@ -605,6 +605,13 @@ export class ToolManager { | |||
| 605 | } | 605 | } |
| 606 | } | 606 | } |
| 607 | 607 | ||
| 608 | if (oai_settings.chat_completion_source === chat_completion_sources.FIREWORKS && Array.isArray(model_list)) { | ||
| 609 | const currentModel = model_list.find(model => model.id === oai_settings.fireworks_model); | ||
| 610 | if (currentModel) { | ||
| 611 | return currentModel.supports_tools; | ||
| 612 | } | ||
| 613 | } | ||
| 614 | |||
| 608 | const supportedSources = [ | 615 | const supportedSources = [ |
| 609 | chat_completion_sources.OPENAI, | 616 | chat_completion_sources.OPENAI, |
| 610 | chat_completion_sources.CUSTOM, | 617 | chat_completion_sources.CUSTOM, |
| @@ -621,6 +628,7 @@ export class ToolManager { | |||
| 621 | chat_completion_sources.XAI, | 628 | chat_completion_sources.XAI, |
| 622 | chat_completion_sources.POLLINATIONS, | 629 | chat_completion_sources.POLLINATIONS, |
| 623 | chat_completion_sources.MOONSHOT, | 630 | chat_completion_sources.MOONSHOT, |
| 631 | chat_completion_sources.FIREWORKS, | ||
| 624 | ]; | 632 | ]; |
| 625 | return supportedSources.includes(oai_settings.chat_completion_source); | 633 | return supportedSources.includes(oai_settings.chat_completion_source); |
| 626 | } | 634 | } |
| @@ -179,6 +179,7 @@ export const CHAT_COMPLETION_SOURCES = { | |||
| 179 | XAI: 'xai', | 179 | XAI: 'xai', |
| 180 | POLLINATIONS: 'pollinations', | 180 | POLLINATIONS: 'pollinations', |
| 181 | MOONSHOT: 'moonshot', | 181 | MOONSHOT: 'moonshot', |
| 182 | FIREWORKS: 'fireworks', | ||
| 182 | }; | 183 | }; |
| 183 | 184 | ||
| 184 | /** | 185 | /** |
| @@ -66,6 +66,7 @@ const API_XAI = 'https://api.x.ai/v1'; | |||
| 66 | const API_AIMLAPI = 'https://api.aimlapi.com/v1'; | 66 | const API_AIMLAPI = 'https://api.aimlapi.com/v1'; |
| 67 | const API_POLLINATIONS = 'https://text.pollinations.ai/openai'; | 67 | const API_POLLINATIONS = 'https://text.pollinations.ai/openai'; |
| 68 | const API_MOONSHOT = 'https://api.moonshot.ai/v1'; | 68 | const API_MOONSHOT = 'https://api.moonshot.ai/v1'; |
| 69 | const API_FIREWORKS = 'https://api.fireworks.ai/inference/v1'; | ||
| 69 | 70 | ||
| 70 | /** | 71 | /** |
| 71 | * Gets OpenRouter transforms based on the request. | 72 | * Gets OpenRouter transforms based on the request. |
| @@ -1251,6 +1252,10 @@ router.post('/status', async function (request, statusResponse) { | |||
| 1251 | apiUrl = API_MOONSHOT; | 1252 | apiUrl = API_MOONSHOT; |
| 1252 | apiKey = readSecret(request.user.directories, SECRET_KEYS.MOONSHOT); | 1253 | apiKey = readSecret(request.user.directories, SECRET_KEYS.MOONSHOT); |
| 1253 | headers = {}; | 1254 | headers = {}; |
| 1255 | } else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.FIREWORKS) { | ||
| 1256 | apiUrl = API_FIREWORKS; | ||
| 1257 | apiKey = readSecret(request.user.directories, SECRET_KEYS.FIREWORKS); | ||
| 1258 | headers = {}; | ||
| 1254 | } else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.MAKERSUITE) { | 1259 | } else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.MAKERSUITE) { |
| 1255 | apiKey = request.body.reverse_proxy ? request.body.proxy_password : readSecret(request.user.directories, SECRET_KEYS.MAKERSUITE); | 1260 | apiKey = request.body.reverse_proxy ? request.body.proxy_password : readSecret(request.user.directories, SECRET_KEYS.MAKERSUITE); |
| 1256 | apiUrl = trimTrailingSlash(request.body.reverse_proxy || API_MAKERSUITE); | 1261 | apiUrl = trimTrailingSlash(request.body.reverse_proxy || API_MAKERSUITE); |
| @@ -1609,6 +1614,22 @@ router.post('/generate', function (request, response) { | |||
| 1609 | }, | 1614 | }, |
| 1610 | }; | 1615 | }; |
| 1611 | } | 1616 | } |
| 1617 | } else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.FIREWORKS) { | ||
| 1618 | apiUrl = API_FIREWORKS; | ||
| 1619 | apiKey = readSecret(request.user.directories, SECRET_KEYS.FIREWORKS); | ||
| 1620 | headers = {}; | ||
| 1621 | bodyParams = {}; | ||
| 1622 | if (request.body.json_schema) { | ||
| 1623 | bodyParams['response_format'] = { | ||
| 1624 | type: 'json_schema', | ||
| 1625 | json_schema: { | ||
| 1626 | name: request.body.json_schema.name, | ||
| 1627 | description: request.body.json_schema.description, | ||
| 1628 | schema: request.body.json_schema.value, | ||
| 1629 | strict: request.body.json_schema.strict ?? true, | ||
| 1630 | }, | ||
| 1631 | }; | ||
| 1632 | } | ||
| 1612 | } else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.NANOGPT) { | 1633 | } else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.NANOGPT) { |
| 1613 | apiUrl = API_NANOGPT; | 1634 | apiUrl = API_NANOGPT; |
| 1614 | apiKey = readSecret(request.user.directories, SECRET_KEYS.NANOGPT); | 1635 | apiKey = readSecret(request.user.directories, SECRET_KEYS.NANOGPT); |
| @@ -53,6 +53,7 @@ export const SECRET_KEYS = { | |||
| 53 | SERPER: 'api_key_serper', | 53 | SERPER: 'api_key_serper', |
| 54 | AIMLAPI: 'api_key_aimlapi', | 54 | AIMLAPI: 'api_key_aimlapi', |
| 55 | XAI: 'api_key_xai', | 55 | XAI: 'api_key_xai', |
| 56 | FIREWORKS: 'api_key_fireworks', | ||
| 56 | VERTEXAI_SERVICE_ACCOUNT: 'vertexai_service_account_json', | 57 | VERTEXAI_SERVICE_ACCOUNT: 'vertexai_service_account_json', |
| 57 | MINIMAX: 'api_key_minimax', | 58 | MINIMAX: 'api_key_minimax', |
| 58 | MINIMAX_GROUP_ID: 'minimax_group_id', | 59 | MINIMAX_GROUP_ID: 'minimax_group_id', |