|
7875 | 7875 | }
|
7876 | 7876 | }
|
7877 | 7877 |
|
| 7878 | + function get_oai_model_dropdown() |
| 7879 | + { |
| 7880 | + let ddval = document.getElementById("customapidropdown").value; |
| 7881 | + switch(ddval) |
| 7882 | + { |
| 7883 | + case 3: |
| 7884 | + return document.getElementById("custom_openrouter_model"); |
| 7885 | + case 7: |
| 7886 | + return document.getElementById("custom_mistralai_model"); |
| 7887 | + default: |
| 7888 | + return document.getElementById("custom_oai_model"); |
| 7889 | + } |
| 7890 | + } |
| 7891 | + function ep_should_always_use_chat_completions() |
| 7892 | + { |
| 7893 | + let epchoice = document.getElementById("customapidropdown").value; |
| 7894 | + return (epchoice==3 || epchoice==7); |
| 7895 | + } |
| 7896 | + |
7878 | 7897 | function select_custom_oai_model()
|
7879 | 7898 | {
|
7880 |
| - let isOpenrouter = (document.getElementById("customapidropdown").value==3); |
7881 |
| - let isMistralai = (document.getElementById("customapidropdown").value==7); |
7882 | 7899 | inputBox("Enter custom model name","Custom Model Name",localsettings.saved_oai_custommodel,"", ()=>{
|
7883 | 7900 | let coai = getInputBoxValue().trim();
|
7884 |
| - let dropdown = (isMistralai?document.getElementById("custom_mistralai_model"):(isOpenrouter?document.getElementById("custom_openrouter_model"):document.getElementById("custom_oai_model"))); |
7885 |
| - let mdlopt = (isMistralai?document.getElementById("custom_mistralai_model_option"):(isOpenrouter?"custom_openrouter_model_option":"custom_oai_model_option")); |
| 7901 | + let dropdown = get_oai_model_dropdown(); |
| 7902 | + var mdlopt = dropdown.querySelector('option.custom_model_option'); |
7886 | 7903 | if(coai!="")
|
7887 | 7904 | {
|
7888 |
| - document.getElementById(mdlopt).value = coai; |
7889 |
| - document.getElementById(mdlopt).innerText = coai; |
7890 |
| - document.getElementById(mdlopt).style.display = ""; |
| 7905 | + mdlopt.value = coai; |
| 7906 | + mdlopt.innerText = coai; |
| 7907 | + mdlopt.style.display = ""; |
7891 | 7908 | dropdown.selectedIndex = dropdown.options.length - 1;
|
7892 | 7909 | }
|
7893 |
| - oai_model_change(isOpenrouter||isMistralai); |
| 7910 | + oai_model_change(ep_should_always_use_chat_completions()); |
7894 | 7911 | },false);
|
7895 | 7912 | }
|
7896 | 7913 | function oai_model_change(autotoggle_check = false)
|
7897 | 7914 | {
|
7898 |
| - let isOpenrouter = (document.getElementById("customapidropdown").value==3); |
7899 |
| - let isMistralai = (document.getElementById("customapidropdown").value==7); |
7900 |
| - let dropdown = (isMistralai?document.getElementById("custom_mistralai_model"):(isOpenrouter?document.getElementById("custom_openrouter_model"):document.getElementById("custom_oai_model"))); |
| 7915 | + let dropdown = get_oai_model_dropdown(); |
7901 | 7916 | let non_completions = (dropdown.value.includes("davinci-002") || dropdown.value.includes("text-davinci-003") || dropdown.value.includes("text-davinci-002")
|
7902 | 7917 | || dropdown.value.includes("text-davinci-001") || dropdown.value.includes("gpt-3.5-turbo-instruct") || dropdown.value == "davinci");
|
7903 | 7918 | if(autotoggle_check)
|
7904 | 7919 | {
|
7905 |
| - if(isMistralai || isOpenrouter || dropdown.selectedIndex==dropdown.options.length-1) |
| 7920 | + if(ep_should_always_use_chat_completions() || dropdown.selectedIndex==dropdown.options.length-1) |
7906 | 7921 | {
|
7907 | 7922 | document.getElementById("useoaichatcompl").checked = true;
|
7908 | 7923 | } else {
|
|
7958 | 7973 | if (!data.error && data.data && data.data.length > 0)
|
7959 | 7974 | {
|
7960 | 7975 | let isOpenrouter = (document.getElementById("customapidropdown").value==3);
|
7961 |
| - let isMistralai = (document.getElementById("customapidropdown").value==7); |
7962 |
| - let dropdown = (isMistralai?document.getElementById("custom_mistralai_model"):(isOpenrouter?document.getElementById("custom_openrouter_model"):document.getElementById("custom_oai_model"))); |
| 7976 | + let dropdown = get_oai_model_dropdown(); |
7963 | 7977 | var lastOption = dropdown.lastElementChild;
|
7964 | 7978 | for (var i = dropdown.options.length - 1; i >= 0; i--) {
|
7965 | 7979 | var option = dropdown.options[i];
|
|
8065 | 8079 | document.getElementById("custom_oai_key").value = localsettings.saved_mistralai_key;
|
8066 | 8080 | document.getElementById("custom_oai_endpoint").value = default_mistralai_base;
|
8067 | 8081 | }
|
8068 |
| - else |
| 8082 | + else //openrouter supports autofetch |
8069 | 8083 | {
|
8070 | 8084 | document.getElementById("oaidesc").classList.add("hidden");
|
8071 | 8085 | document.getElementById("openrouterdesc").classList.remove("hidden");
|
|
8084 | 8098 | }
|
8085 | 8099 | }
|
8086 | 8100 | }
|
8087 |
| - oai_model_change(epchoice==3 || epchoice==7 || force_autotoggle_chatcompl); |
| 8101 | + oai_model_change(ep_should_always_use_chat_completions() || force_autotoggle_chatcompl); |
8088 | 8102 | toggleoaichatcompl();
|
8089 | 8103 | }
|
8090 | 8104 | else if(epchoice==4)
|
|
8480 | 8494 | }
|
8481 | 8495 | localsettings.saved_oai_role = document.getElementById("oairoledropdown").value;
|
8482 | 8496 | localsettings.saved_oai_jailbreak2 = document.getElementById("jailbreakprompttext2").value;
|
8483 |
| - let isOpenrouter = (document.getElementById("customapidropdown").value==3); |
8484 |
| - let isMistralai = (document.getElementById("customapidropdown").value==7); |
8485 |
| - let dropdown = (isMistralai?document.getElementById("custom_mistralai_model"):(isOpenrouter?document.getElementById("custom_openrouter_model"):document.getElementById("custom_oai_model"))); |
| 8497 | + let dropdown = get_oai_model_dropdown(); |
8486 | 8498 | custom_oai_model = dropdown.value.trim();
|
8487 | 8499 | localsettings.saved_oai_custommodel = custom_oai_model;
|
8488 | 8500 | selected_models = [{ "performance": 100.0, "queued": 0.0, "eta": 0, "name": custom_oai_model, "count": 1 }];
|
|
17069 | 17081 | <option value="gpt-4-turbo">gpt-4-turbo</option>
|
17070 | 17082 | <option value="gpt-4o">gpt-4o</option>
|
17071 | 17083 | <option value="gpt-4-32k">gpt-4-32k</option>
|
17072 |
| - <option style="display:none;" id="custom_oai_model_option" value="custom">[Custom]</option> |
| 17084 | + <option style="display:none;" class="custom_model_option" value="custom">[Custom]</option> |
17073 | 17085 | </select>
|
17074 | 17086 | <select style="padding:4px;display:inline;width:calc(100% - 220px)" class="form-control hidden" id="custom_openrouter_model" onchange="oai_model_change(true)">
|
17075 | 17087 | <option value="openai/gpt-3.5-turbo">openai/gpt-3.5-turbo</option>
|
|
17079 | 17091 | <option value="gryphe/mythomax-l2-13b">gryphe/mythomax-l2-13b</option>
|
17080 | 17092 | <option value="huggingfaceh4/zephyr-7b-beta">huggingfaceh4/zephyr-7b-beta</option>
|
17081 | 17093 | <option value="anthropic/claude-2">anthropic/claude-2</option>
|
17082 |
| - <option style="display:none;" id="custom_openrouter_model_option" value="custom">[Custom]</option> |
| 17094 | + <option style="display:none;" class="custom_model_option" value="custom">[Custom]</option> |
17083 | 17095 | </select>
|
17084 | 17096 | <select style="padding:4px;display:inline;width:calc(100% - 220px)" class="form-control hidden" id="custom_mistralai_model" onchange="oai_model_change(true)">
|
17085 | 17097 | <option value="open-mistral-7b">open-mistral-7b</option>
|
|
17089 | 17101 | <option value="open-mixtral-8x22b">open-mixtral-8x22b</option>
|
17090 | 17102 | <option value="mistral-medium">mistral-medium</option>
|
17091 | 17103 | <option value="mistral-large-latest">mistral-large-latest</option>
|
17092 |
| - <option style="display:none;" id="custom_mistralai_model_option" value="custom">[Custom]</option> |
| 17104 | + <option style="display:none;" class="custom_model_option" value="custom">[Custom]</option> |
17093 | 17105 | </select>
|
17094 | 17106 | <button type="button" class="btn btn-primary" style="display:inline;width:105px;" id="oaifetchlist" onclick="oai_fetch_models()">Fetch List</button>
|
17095 | 17107 | <button type="button" class="btn btn-primary" style="display:inline;width:105px;" id="oaiusecustom" onclick="select_custom_oai_model()">Use Custom</button>
|
|
0 commit comments