Merge branch 'staging' into optimize-chat-manager
| @@ -11,103 +11,105 @@ declare var SillyTavern: { | ||
| 11 | 11 | libs: typeof libs; |
| 12 | 12 | }; |
| 13 | 13 | |
| 14 | -// Jquery plugins | |
| 14 | +declare global { | |
| 15 | -interface JQuery { | |
| 15 | + // Jquery plugins | |
| 16 | - nanogallery2(options?: any): JQuery; | |
| 16 | + interface JQuery { | |
| 17 | 17 | nanogallery2(method: string, options?: any): JQuery; |
| 18 | - pagination(method: 'getCurrentPageNum'): number; | |
| 18 | + nanogallery2(method: string, options?: any): JQuery; | |
| 19 | 19 | pagination(method: string, options?: any'getCurrentPageNum'): JQuerynumber; |
| 20 | 20 | pagination(method: string, options?: any): JQuery; |
| 21 | 21 | transition pagination(options?: any, complete?: function): JQuery; |
| 22 | 22 | autocomplete transition(options?: any, complete?: function): JQuery; |
| 23 | 23 | autocomplete(method: string, options?: any): JQuery; |
| 24 | 24 | slider autocomplete(method: string, options?: any): JQuery; |
| 25 | 25 | slider(method: string, func: string, options?: any): JQuery; |
| 26 | 26 | cropper slider(method: string, func: string, options?: any): JQuery; |
| 27 | 27 | izoomify cropper(options?: any): JQuery; |
| 28 | - | |
| 28 | + izoomify(options?: any): JQuery; | |
| 29 | - //#region select2 | |
| 29 | + | |
| 30 | - | |
| 30 | + //#region select2 | |
| 31 | - /** | |
| 31 | + | |
| 32 | - * Initializes or modifies a select2 instance with provided options | |
| 32 | + /** | |
| 33 | - * | |
| 33 | + * Initializes or modifies a select2 instance with provided options | |
| 34 | - * @param options - Configuration options for the select2 instance | |
| 34 | + * | |
| 35 | 35 | * @returnsparam Theoptions jQuery- objectConfiguration options for chainingthe select2 instance |
| 36 | - */ | |
| 36 | + * @returns The jQuery object for chaining | |
| 37 | - select2(options?: Select2Options): JQuery; | |
| 37 | + */ | |
| 38 | - | |
| 38 | + select2(options?: Select2Options): JQuery; | |
| 39 | - /** | |
| 39 | + | |
| 40 | - * Retrieves data currently selected in the select2 instance | |
| 40 | + /** | |
| 41 | - * | |
| 41 | + * Retrieves data currently selected in the select2 instance | |
| 42 | - * @param field - A string specifying the 'data' method | |
| 42 | + * | |
| 43 | - * @returns An array of selected items | |
| 43 | + * @param field - A string specifying the 'data' method | |
| 44 | - */ | |
| 44 | + * @returns An array of selected items | |
| 45 | - select2(field: 'data'): any[]; | |
| 45 | + */ | |
| 46 | - | |
| 46 | + select2(field: 'data'): any[]; | |
| 47 | - /** | |
| 47 | + | |
| 48 | - * Calls the specified select2 method | |
| 48 | + /** | |
| 49 | - * | |
| 49 | + * Calls the specified select2 method | |
| 50 | - * @param method - The name of the select2 method to invoke | |
| 50 | + * | |
| 51 | - * @returns The jQuery object for chaining | |
| 51 | + * @param method - The name of the select2 method to invoke | |
| 52 | - */ | |
| 52 | + * @returns The jQuery object for chaining | |
| 53 | - select2(method: 'open' | 'close' | 'destroy' | 'focus' | 'val', value?: any): JQuery; | |
| 53 | + */ | |
| 54 | - | |
| 54 | + select2(method: 'open' | 'close' | 'destroy' | 'focus' | 'val', value?: any): JQuery; | |
| 55 | - //#endregion | |
| 55 | + | |
| 56 | - | |
| 56 | + //#endregion | |
| 57 | - //#region sortable | |
| 57 | + | |
| 58 | - | |
| 58 | + //#region sortable | |
| 59 | - /** | |
| 59 | + | |
| 60 | - * Initializes or updates a sortable instance with the provided options | |
| 60 | + /** | |
| 61 | - * | |
| 61 | + * Initializes or updates a sortable instance with the provided options | |
| 62 | - * @param options - Configuration options for the sortable instance | |
| 62 | + * | |
| 63 | 63 | * @returnsparam Theoptions jQuery- objectConfiguration options for chainingthe sortable instance |
| 64 | - */ | |
| 64 | + * @returns The jQuery object for chaining | |
| 65 | - sortable(options?: SortableOptions): JQuery; | |
| 65 | + */ | |
| 66 | - | |
| 66 | + sortable(options?: SortableOptions): JQuery; | |
| 67 | - /** | |
| 67 | + | |
| 68 | - * Calls a sortable method to perform actions on the instance | |
| 68 | + /** | |
| 69 | - * | |
| 69 | + * Calls a sortable method to perform actions on the instance | |
| 70 | - * @param method - The name of the sortable method to invoke | |
| 70 | + * | |
| 71 | - * @returns The jQuery object for chaining | |
| 71 | + * @param method - The name of the sortable method to invoke | |
| 72 | - */ | |
| 72 | + * @returns The jQuery object for chaining | |
| 73 | - sortable(method: 'destroy' | 'disable' | 'enable' | 'refresh' | 'toArray'): JQuery; | |
| 73 | + */ | |
| 74 | - | |
| 74 | + sortable(method: 'destroy' | 'disable' | 'enable' | 'refresh' | 'toArray'): JQuery; | |
| 75 | - /** | |
| 75 | + | |
| 76 | - * Retrieves the sortable's instance object. If the element does not have an associated instance, undefined is returned. | |
| 76 | + /** | |
| 77 | - * | |
| 77 | + * Retrieves the sortable's instance object. If the element does not have an associated instance, undefined is returned. | |
| 78 | - * @returns The instance of the sortable object | |
| 78 | + * | |
| 79 | - */ | |
| 79 | + * @returns The instance of the sortable object | |
| 80 | - sortable(method: 'instance'): object; | |
| 80 | + */ | |
| 81 | - | |
| 81 | + sortable(method: 'instance'): object; | |
| 82 | - /** | |
| 82 | + | |
| 83 | - * Retrieves the current option value for the specified option | |
| 83 | + /** | |
| 84 | - * | |
| 84 | + * Retrieves the current option value for the specified option | |
| 85 | - * @param method - The string 'option' to retrieve an option value | |
| 85 | + * | |
| 86 | 86 | * @param optionNamemethod - The name of thestring 'option' to retrieve an option value |
| 87 | 87 | * @returnsparam optionName - The valuename of the specified option to retrieve |
| 88 | - */ | |
| 88 | + * @returns The value of the specified option | |
| 89 | - sortable(method: 'option', optionName: string): any; | |
| 89 | + */ | |
| 90 | - | |
| 90 | + sortable(method: 'option', optionName: string): any; | |
| 91 | - /** | |
| 91 | + | |
| 92 | - * Sets the value of the specified option | |
| 92 | + /** | |
| 93 | - * | |
| 93 | + * Sets the value of the specified option | |
| 94 | - * @param method - The string 'option' to set an option value | |
| 94 | + * | |
| 95 | 95 | * @param optionNamemethod - The name of thestring 'option' to set an option value |
| 96 | 96 | * @param valueoptionName - The value to assignname toof the option to set |
| 97 | - * @returns The jQuery object for chaining | |
| 97 | + * @param value - The value to assign to the option | |
| 98 | - */ | |
| 98 | + * @returns The jQuery object for chaining | |
| 99 | - sortable(method: 'option', optionName: string, value: any): JQuery; | |
| 99 | + */ | |
| 100 | - | |
| 100 | + sortable(method: 'option', optionName: string, value: any): JQuery; | |
| 101 | - /** | |
| 101 | + | |
| 102 | - * Sets multiple options using an object | |
| 102 | + /** | |
| 103 | - * | |
| 103 | + * Sets multiple options using an object | |
| 104 | - * @param method - The string 'option' to set options | |
| 104 | + * | |
| 105 | 105 | * @param optionsmethod - An object containingThe multiplestring 'option' key-valueto pairsset options |
| 106 | - * @returns The jQuery object for chaining | |
| 106 | + * @param options - An object containing multiple option key-value pairs | |
| 107 | - */ | |
| 107 | + * @returns The jQuery object for chaining | |
| 108 | - sortable(method: 'option', options: SortableOptions): JQuery; | |
| 108 | + */ | |
| 109 | - | |
| 109 | + sortable(method: 'option', options: SortableOptions): JQuery; | |
| 110 | - //#endregion | |
| 110 | + | |
| 111 | + //#endregion | |
| 112 | + } | |
| 111 | 113 | } |
| 112 | 114 | |
| 113 | 115 | //#region select2 |
| @@ -0,0 +1,43 @@ | ||
| 1 | +<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
| 2 | +<!-- Created with Inkscape (http://www.inkscape.org/) --> | |
| 3 | + | |
| 4 | +<svg | |
| 5 | + width="190.91216mm" | |
| 6 | + height="201.47243mm" | |
| 7 | + viewBox="0 0 190.91216 201.47243" | |
| 8 | + version="1.1" | |
| 9 | + id="svg1" | |
| 10 | + xmlns="http://www.w3.org/2000/svg" | |
| 11 | + xmlns:svg="http://www.w3.org/2000/svg"> | |
| 12 | + <defs | |
| 13 | + id="defs1" /> | |
| 14 | + <g | |
| 15 | + id="layer1" | |
| 16 | + transform="translate(-2.2086436)"> | |
| 17 | + <g | |
| 18 | + id="g8" | |
| 19 | + transform="matrix(0.99583856,0,0,1.0472862,2.2086437,-7.9847956)"> | |
| 20 | + <path | |
| 21 | + style="font-weight:bold;font-size:89.3125px;font-family:'Courier New';-inkscape-font-specification:'Courier New Bold';letter-spacing:-8.37308px;stroke-width:1.73283" | |
| 22 | + d="m 161.17775,117.85719 v 23.36554 q 0,20.76935 -10.30578,39.77331 -10.21695,19.00395 -29.31819,19.00395 -11.01653,0 -18.65701,-5.60771 -7.551611,-5.71157 -14.392485,-20.8732 -6.752041,-15.26549 -6.752041,-32.29635 v -23.36554 q 0,-20.665499 10.216893,-39.669461 10.216893,-19.107806 29.318113,-19.107806 10.92769,0 18.47935,5.607725 7.64049,5.607727 14.48139,20.873203 6.92976,15.161629 6.92976,32.296339 z m -18.30165,0 q 0,-17.3424 -8.26241,-30.32325 -4.70867,-7.165428 -13.2376,-7.165428 -8.26239,0 -13.50413,7.892355 -7.906998,11.942383 -7.906998,29.596323 v 23.36554 q 0,17.44626 8.351218,30.32326 4.61983,7.16543 13.2376,7.16543 8.17356,0 13.4153,-7.89237 7.90702,-11.94237 7.90702,-29.59632 z" | |
| 23 | + id="path8" /> | |
| 24 | + <path | |
| 25 | + style="font-weight:bold;font-size:89.3125px;font-family:'Courier New';-inkscape-font-specification:'Courier New Bold';letter-spacing:-8.37308px;stroke-width:1.67461" | |
| 26 | + d="M 54.800839,58.349248 V 166.67311 H 73.27526 q 6.604382,0 9.371083,2.79982 2.855949,2.70327 2.855949,7.14436 0,4.34453 -2.855949,7.14435 -2.766701,2.70327 -9.371083,2.70327 H 18.030494 q -6.604382,0 -9.4603308,-2.70327 -2.7667007,-2.79982 -2.7667007,-7.2409 0,-4.34454 2.7667007,-7.04781 2.8559488,-2.79982 9.4603308,-2.79982 H 36.504915 V 84.126852 l -16.332459,4.634176 q -3.926929,1.158544 -5.890395,1.158544 -3.480687,0 -6.0688915,-2.992905 -2.4989554,-2.992906 -2.4989554,-7.337446 0,-3.958358 1.8742165,-6.178902 1.8742167,-2.317087 7.8538604,-4.054903 z" | |
| 27 | + transform="matrix(0.99545738,0,0,1.0756271,-5.6882567,-3.6821097)" | |
| 28 | + id="path7" /> | |
| 29 | + </g> | |
| 30 | + <g | |
| 31 | + id="g1" | |
| 32 | + transform="matrix(0.84984007,0,0,0.87855774,28.999003,5.2337341e-7)"> | |
| 33 | + <path | |
| 34 | + style="font-weight:bold;font-size:89.3125px;font-family:'Courier New';-inkscape-font-specification:'Courier New Bold';letter-spacing:-8.37308px;stroke-width:1.73283" | |
| 35 | + d="m 184.13459,37.01017 q -3.34269,3.095908 -6.12102,4.409323 -2.77834,1.266508 -5.86056,1.266508 -7.1629,0 -12.54593,-6.191815 -5.33961,-6.191816 -5.33961,-15.385722 0,-7.176877 3.68997,-13.0403372 Q 162.99318,4.3096483e-6 172.15301,4.3096483e-6 q 6.55514,0 11.46064,4.2685995903517 4.90551,4.2216915 7.20632,12.2429061 2.30081,7.974308 2.30081,16.65223 0,14.729014 -10.549,23.641474 -8.16137,6.848524 -17.88555,6.848524 -5.38303,0 -8.33501,-2.345385 -1.99693,-1.547954 -1.99693,-4.080969 0,-2.063938 1.25893,-3.424261 1.30235,-1.407231 3.16905,-1.407231 1.04187,0 2.34422,0.703615 1.69304,0.938154 3.55974,0.938154 6.72879,0 12.4157,-4.925307 5.68691,-4.972215 7.03266,-12.102184 z m -1.25893,-15.151183 q -1.43258,-6.660892 -4.25433,-9.428446 -2.77834,-2.814461 -6.38149,-2.814461 -3.77681,0 -6.42491,3.142816 -2.6481,3.095907 -2.6481,8.255753 0,5.394384 2.6481,8.72483 2.69151,3.330446 6.12102,3.330446 6.03421,0 10.93971,-11.210938 z" | |
| 36 | + id="path6" /> | |
| 37 | + <path | |
| 38 | + style="font-weight:bold;font-size:89.3125px;font-family:'Courier New';-inkscape-font-specification:'Courier New Bold';letter-spacing:-8.37308px;stroke-width:1.51638" | |
| 39 | + d="m 142.10195,39.730816 h -22.30654 q -3.49058,0 -4.15545,-0.234538 -0.99731,-0.375262 -1.69543,-1.641769 -0.69812,-1.313415 -0.69812,-2.955185 0,-1.594861 0.69812,-2.908276 0.69812,-1.313416 1.72867,-1.641769 0.66488,-0.234539 4.12221,-0.234539 h 22.30654 q 3.49059,0 4.15545,0.234539 0.99732,0.375261 1.69543,1.688676 0.69812,1.266508 0.69812,2.861369 0,1.64177 -0.69812,2.955185 -0.69811,1.266507 -1.72867,1.641769 -0.66487,0.234538 -4.12221,0.234538 z" | |
| 40 | + id="text2" /> | |
| 41 | + </g> | |
| 42 | + </g> | |
| 43 | +</svg> | |
| @@ -2601,6 +2601,7 @@ | ||
| 2601 | 2601 | <option value="groq">Groq</option> |
| 2602 | 2602 | <option value="makersuite">Google AI Studio</option> |
| 2603 | 2603 | <option value="mistralai">MistralAI</option> |
| 2604 | + <option value="nanogpt">NanoGPT</option> | |
| 2604 | 2605 | <option value="openrouter">OpenRouter</option> |
| 2605 | 2606 | <option value="perplexity">Perplexity</option> |
| 2606 | 2607 | <option value="scale">Scale</option> |
| @@ -3083,6 +3084,22 @@ | ||
| 3083 | 3084 | </optgroup> |
| 3084 | 3085 | </select> |
| 3085 | 3086 | </div> |
| 3087 | + <div id="nanogpt_form" data-source="nanogpt"> | |
| 3088 | + <h4 data-i18n="NanoGPT API Key">NanoGPT API Key</h4> | |
| 3089 | + <div class="flex-container"> | |
| 3090 | + <input id="api_key_nanogpt" name="api_key_nanogpt" class="text_pole flex1" value="" type="text" autocomplete="off"> | |
| 3091 | + <div title="Clear your API key" data-i18n="[title]Clear your API key" class="menu_button fa-solid fa-circle-xmark clear-api-key" data-key="api_key_nanogpt"></div> | |
| 3092 | + </div> | |
| 3093 | + <div data-for="api_key_nanogpt" class="neutral_warning" data-i18n="For privacy reasons, your API key will be hidden after you reload the page."> | |
| 3094 | + For privacy reasons, your API key will be hidden after you reload the page. | |
| 3095 | + </div> | |
| 3096 | + <div> | |
| 3097 | + <h4 data-i18n="NanoGPT Model">NanoGPT Model</h4> | |
| 3098 | + <select id="model_nanogpt_select"> | |
| 3099 | + <option value="" data-i18n="-- Connect to the API --">-- Connect to the API --</option> | |
| 3100 | + </select> | |
| 3101 | + </div> | |
| 3102 | + </div> | |
| 3086 | 3103 | <div id="perplexity_form" data-source="perplexity"> |
| 3087 | 3104 | <h4 data-i18n="Perplexity API Key">Perplexity API Key</h4> |
| 3088 | 3105 | <div class="flex-container"> |
| @@ -388,6 +388,7 @@ function RA_autoconnect(PrevApi) { | ||
| 388 | 388 | || (secret_state[SECRET_KEYS.GROQ] && oai_settings.chat_completion_source == chat_completion_sources.GROQ) |
| 389 | 389 | || (secret_state[SECRET_KEYS.ZEROONEAI] && oai_settings.chat_completion_source == chat_completion_sources.ZEROONEAI) |
| 390 | 390 | || (secret_state[SECRET_KEYS.BLOCKENTROPY] && oai_settings.chat_completion_source == chat_completion_sources.BLOCKENTROPY) |
| 391 | + || (secret_state[SECRET_KEYS.NANOGPT] && oai_settings.chat_completion_source == chat_completion_sources.NANOGPT) | |
| 391 | 392 | || (isValidUrl(oai_settings.custom_url) && oai_settings.chat_completion_source == chat_completion_sources.CUSTOM) |
| 392 | 393 | ) { |
| 393 | 394 | $('#api_button_openai').trigger('click'); |
| @@ -182,6 +182,7 @@ export const chat_completion_sources = { | ||
| 182 | 182 | GROQ: 'groq', |
| 183 | 183 | ZEROONEAI: '01ai', |
| 184 | 184 | BLOCKENTROPY: 'blockentropy', |
| 185 | + NANOGPT: 'nanogpt', | |
| 185 | 186 | }; |
| 186 | 187 | |
| 187 | 188 | const character_names_behavior = { |
| @@ -251,6 +252,7 @@ const default_settings = { | ||
| 251 | 252 | cohere_model: 'command-r-plus', |
| 252 | 253 | perplexity_model: 'llama-3.1-70b-instruct', |
| 253 | 254 | groq_model: 'llama-3.1-70b-versatile', |
| 255 | + nanogpt_model: 'gpt-4o-mini', | |
| 254 | 256 | zerooneai_model: 'yi-large', |
| 255 | 257 | blockentropy_model: 'be-70b-base-llama3.1', |
| 256 | 258 | custom_model: '', |
| @@ -327,6 +329,7 @@ const oai_settings = { | ||
| 327 | 329 | cohere_model: 'command-r-plus', |
| 328 | 330 | perplexity_model: 'llama-3.1-70b-instruct', |
| 329 | 331 | groq_model: 'llama-3.1-70b-versatile', |
| 332 | + nanogpt_model: 'gpt-4o-mini', | |
| 330 | 333 | zerooneai_model: 'yi-large', |
| 331 | 334 | blockentropy_model: 'be-70b-base-llama3.1', |
| 332 | 335 | custom_model: '', |
| @@ -1480,6 +1483,8 @@ function getChatCompletionModel() { | ||
| 1480 | 1483 | return oai_settings.zerooneai_model; |
| 1481 | 1484 | case chat_completion_sources.BLOCKENTROPY: |
| 1482 | 1485 | return oai_settings.blockentropy_model; |
| 1486 | + case chat_completion_sources.NANOGPT: | |
| 1487 | + return oai_settings.nanogpt_model; | |
| 1483 | 1488 | default: |
| 1484 | 1489 | throw new Error(`Unknown chat completion source: ${oai_settings.chat_completion_source}`); |
| 1485 | 1490 | } |
| @@ -1637,6 +1642,24 @@ function saveModelList(data) { | ||
| 1637 | 1642 | } |
| 1638 | 1643 | } |
| 1639 | 1644 | } |
| 1645 | + | |
| 1646 | + if (oai_settings.chat_completion_source == chat_completion_sources.NANOGPT) { | |
| 1647 | + $('#model_nanogpt_select').empty(); | |
| 1648 | + model_list.forEach((model) => { | |
| 1649 | + $('#model_nanogpt_select').append( | |
| 1650 | + $('<option>', { | |
| 1651 | + value: model.id, | |
| 1652 | + text: model.id, | |
| 1653 | + })); | |
| 1654 | + }); | |
| 1655 | + | |
| 1656 | + const selectedModel = model_list.find(model => model.id === oai_settings.nanogpt_model); | |
| 1657 | + if (model_list.length > 0 && (!selectedModel || !oai_settings.nanogpt_model)) { | |
| 1658 | + oai_settings.nanogpt_model = model_list[0].id; | |
| 1659 | + } | |
| 1660 | + | |
| 1661 | + $('#model_nanogpt_select').val(oai_settings.nanogpt_model).trigger('change'); | |
| 1662 | + } | |
| 1640 | 1663 | } |
| 1641 | 1664 | |
| 1642 | 1665 | function appendOpenRouterOptions(model_list, groupModels = false, sort = false) { |
| @@ -2961,6 +2984,7 @@ function loadOpenAISettings(data, settings) { | ||
| 2961 | 2984 | oai_settings.cohere_model = settings.cohere_model ?? default_settings.cohere_model; |
| 2962 | 2985 | oai_settings.perplexity_model = settings.perplexity_model ?? default_settings.perplexity_model; |
| 2963 | 2986 | oai_settings.groq_model = settings.groq_model ?? default_settings.groq_model; |
| 2987 | + oai_settings.nanogpt_model = settings.nanogpt_model ?? default_settings.nanogpt_model; | |
| 2964 | 2988 | oai_settings.blockentropy_model = settings.blockentropy_model ?? default_settings.blockentropy_model; |
| 2965 | 2989 | oai_settings.zerooneai_model = settings.zerooneai_model ?? default_settings.zerooneai_model; |
| 2966 | 2990 | oai_settings.custom_model = settings.custom_model ?? default_settings.custom_model; |
| @@ -3041,6 +3065,8 @@ function loadOpenAISettings(data, settings) { | ||
| 3041 | 3065 | $(`#model_perplexity_select option[value="${oai_settings.perplexity_model}"`).attr('selected', true); |
| 3042 | 3066 | $('#model_groq_select').val(oai_settings.groq_model); |
| 3043 | 3067 | $(`#model_groq_select option[value="${oai_settings.groq_model}"`).attr('selected', true); |
| 3068 | + $('#model_nanogpt_select').val(oai_settings.nanogpt_model); | |
| 3069 | + $(`#model_nanogpt_select option[value="${oai_settings.nanogpt_model}"`).attr('selected', true); | |
| 3044 | 3070 | $('#model_01ai_select').val(oai_settings.zerooneai_model); |
| 3045 | 3071 | $('#model_blockentropy_select').val(oai_settings.blockentropy_model); |
| 3046 | 3072 | $('#custom_model_id').val(oai_settings.custom_model); |
| @@ -3735,6 +3761,7 @@ function onSettingsPresetChange() { | ||
| 3735 | 3761 | cohere_model: ['#model_cohere_select', 'cohere_model', false], |
| 3736 | 3762 | perplexity_model: ['#model_perplexity_select', 'perplexity_model', false], |
| 3737 | 3763 | groq_model: ['#model_groq_select', 'groq_model', false], |
| 3764 | + nanogpt_model: ['#model_nanogpt_select', 'nanogpt_model', false], | |
| 3738 | 3765 | zerooneai_model: ['#model_01ai_select', 'zerooneai_model', false], |
| 3739 | 3766 | blockentropy_model: ['#model_blockentropy_select', 'blockentropy_model', false], |
| 3740 | 3767 | custom_model: ['#custom_model_id', 'custom_model', false], |
| @@ -3984,6 +4011,16 @@ async function onModelChange() { | ||
| 3984 | 4011 | oai_settings.groq_model = value; |
| 3985 | 4012 | } |
| 3986 | 4013 | |
| 4014 | + if ($(this).is('#model_nanogpt_select')) { | |
| 4015 | + if (!value) { | |
| 4016 | + console.debug('Null NanoGPT model selected. Ignoring.'); | |
| 4017 | + return; | |
| 4018 | + } | |
| 4019 | + | |
| 4020 | + console.log('NanoGPT model changed to', value); | |
| 4021 | + oai_settings.nanogpt_model = value; | |
| 4022 | + } | |
| 4023 | + | |
| 3987 | 4024 | if (value && $(this).is('#model_01ai_select')) { |
| 3988 | 4025 | console.log('01.AI model changed to', value); |
| 3989 | 4026 | oai_settings.zerooneai_model = value; |
| @@ -4294,6 +4331,18 @@ async function onModelChange() { | ||
| 4294 | 4331 | $('#temp_openai').attr('max', oai_max_temp).val(oai_settings.temp_openai).trigger('input'); |
| 4295 | 4332 | } |
| 4296 | 4333 | |
| 4334 | + if (oai_settings.chat_completion_source === chat_completion_sources.NANOGPT) { | |
| 4335 | + if (oai_settings.max_context_unlocked) { | |
| 4336 | + $('#openai_max_context').attr('max', unlocked_max); | |
| 4337 | + } else { | |
| 4338 | + $('#openai_max_context').attr('max', max_128k); | |
| 4339 | + } | |
| 4340 | + | |
| 4341 | + oai_settings.openai_max_context = Math.min(Number($('#openai_max_context').attr('max')), oai_settings.openai_max_context); | |
| 4342 | + $('#openai_max_context').val(oai_settings.openai_max_context).trigger('input'); | |
| 4343 | + $('#temp_openai').attr('max', oai_max_temp).val(oai_settings.temp_openai).trigger('input'); | |
| 4344 | + } | |
| 4345 | + | |
| 4297 | 4346 | if (oai_settings.chat_completion_source === chat_completion_sources.COHERE) { |
| 4298 | 4347 | oai_settings.pres_pen_openai = Math.min(Math.max(0, oai_settings.pres_pen_openai), 1); |
| 4299 | 4348 | $('#pres_pen_openai').attr('max', 1).attr('min', 0).val(oai_settings.pres_pen_openai).trigger('input'); |
| @@ -4498,6 +4547,19 @@ async function onConnectButtonClick(e) { | ||
| 4498 | 4547 | } |
| 4499 | 4548 | } |
| 4500 | 4549 | |
| 4550 | + if (oai_settings.chat_completion_source == chat_completion_sources.NANOGPT) { | |
| 4551 | + const api_key_nanogpt = String($('#api_key_nanogpt').val()).trim(); | |
| 4552 | + | |
| 4553 | + if (api_key_nanogpt.length) { | |
| 4554 | + await writeSecret(SECRET_KEYS.NANOGPT, api_key_nanogpt); | |
| 4555 | + } | |
| 4556 | + | |
| 4557 | + if (!secret_state[SECRET_KEYS.NANOGPT]) { | |
| 4558 | + console.log('No secret key saved for NanoGPT'); | |
| 4559 | + return; | |
| 4560 | + } | |
| 4561 | + } | |
| 4562 | + | |
| 4501 | 4563 | if (oai_settings.chat_completion_source == chat_completion_sources.ZEROONEAI) { |
| 4502 | 4564 | const api_key_01ai = String($('#api_key_01ai').val()).trim(); |
| 4503 | 4565 | |
| @@ -4567,6 +4629,9 @@ function toggleChatCompletionForms() { | ||
| 4567 | 4629 | else if (oai_settings.chat_completion_source == chat_completion_sources.GROQ) { |
| 4568 | 4630 | $('#model_groq_select').trigger('change'); |
| 4569 | 4631 | } |
| 4632 | + else if (oai_settings.chat_completion_source == chat_completion_sources.NANOGPT) { | |
| 4633 | + $('#model_nanogpt_select').trigger('change'); | |
| 4634 | + } | |
| 4570 | 4635 | else if (oai_settings.chat_completion_source == chat_completion_sources.ZEROONEAI) { |
| 4571 | 4636 | $('#model_01ai_select').trigger('change'); |
| 4572 | 4637 | } |
| @@ -5288,6 +5353,7 @@ export function initOpenAI() { | ||
| 5288 | 5353 | $('#model_cohere_select').on('change', onModelChange); |
| 5289 | 5354 | $('#model_perplexity_select').on('change', onModelChange); |
| 5290 | 5355 | $('#model_groq_select').on('change', onModelChange); |
| 5356 | + $('#model_nanogpt_select').on('change', onModelChange); | |
| 5291 | 5357 | $('#model_01ai_select').on('change', onModelChange); |
| 5292 | 5358 | $('#model_blockentropy_select').on('change', onModelChange); |
| 5293 | 5359 | $('#model_custom_select').on('change', onModelChange); |
| @@ -35,6 +35,7 @@ export const SECRET_KEYS = { | ||
| 35 | 35 | STABILITY: 'api_key_stability', |
| 36 | 36 | BLOCKENTROPY: 'api_key_blockentropy', |
| 37 | 37 | CUSTOM_OPENAI_TTS: 'api_key_custom_openai_tts', |
| 38 | + NANOGPT: 'api_key_nanogpt', | |
| 38 | 39 | TAVILY: 'api_key_tavily', |
| 39 | 40 | }; |
| 40 | 41 | |
| @@ -68,6 +69,7 @@ const INPUT_MAP = { | ||
| 68 | 69 | [SECRET_KEYS.ZEROONEAI]: '#api_key_01ai', |
| 69 | 70 | [SECRET_KEYS.HUGGINGFACE]: '#api_key_huggingface', |
| 70 | 71 | [SECRET_KEYS.BLOCKENTROPY]: '#api_key_blockentropy', |
| 72 | + [SECRET_KEYS.NANOGPT]: '#api_key_nanogpt', | |
| 71 | 73 | }; |
| 72 | 74 | |
| 73 | 75 | async function clearSecret() { |
| @@ -3634,6 +3634,7 @@ function getModelOptions(quiet) { | ||
| 3634 | 3634 | { id: 'model_cohere_select', api: 'openai', type: chat_completion_sources.COHERE }, |
| 3635 | 3635 | { id: 'model_perplexity_select', api: 'openai', type: chat_completion_sources.PERPLEXITY }, |
| 3636 | 3636 | { id: 'model_groq_select', api: 'openai', type: chat_completion_sources.GROQ }, |
| 3637 | + { id: 'model_nanogpt_select', api: 'openai', type: chat_completion_sources.NANOGPT }, | |
| 3637 | 3638 | { id: 'model_01ai_select', api: 'openai', type: chat_completion_sources.ZEROONEAI }, |
| 3638 | 3639 | { id: 'model_blockentropy_select', api: 'openai', type: chat_completion_sources.BLOCKENTROPY }, |
| 3639 | 3640 | { id: 'model_novel_select', api: 'novel', type: null }, |
| @@ -200,6 +200,7 @@ export const CHAT_COMPLETION_SOURCES = { | ||
| 200 | 200 | GROQ: 'groq', |
| 201 | 201 | ZEROONEAI: '01ai', |
| 202 | 202 | BLOCKENTROPY: 'blockentropy', |
| 203 | + NANOGPT: 'nanogpt', | |
| 203 | 204 | }; |
| 204 | 205 | |
| 205 | 206 | /** |
| @@ -48,6 +48,7 @@ const API_MAKERSUITE = 'https://generativelanguage.googleapis.com'; | ||
| 48 | 48 | const API_01AI = 'https://api.01.ai/v1'; |
| 49 | 49 | const API_BLOCKENTROPY = 'https://api.blockentropy.ai/v1'; |
| 50 | 50 | const API_AI21 = 'https://api.ai21.com/studio/v1'; |
| 51 | +const API_NANOGPT = 'https://nano-gpt.com/api/v1'; | |
| 51 | 52 | |
| 52 | 53 | /** |
| 53 | 54 | * Applies a post-processing step to the generated messages. |
| @@ -656,6 +657,10 @@ router.post('/status', jsonParser, async function (request, response_getstatus_o | ||
| 656 | 657 | api_url = API_BLOCKENTROPY; |
| 657 | 658 | api_key_openai = readSecret(request.user.directories, SECRET_KEYS.BLOCKENTROPY); |
| 658 | 659 | headers = {}; |
| 660 | + } else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.NANOGPT) { | |
| 661 | + api_url = API_NANOGPT; | |
| 662 | + api_key_openai = readSecret(request.user.directories, SECRET_KEYS.NANOGPT); | |
| 663 | + headers = {}; | |
| 659 | 664 | } else { |
| 660 | 665 | console.log('This chat completion source is not supported yet.'); |
| 661 | 666 | return response_getstatus_openai.status(400).send({ error: true }); |
| @@ -906,6 +911,11 @@ router.post('/generate', jsonParser, function (request, response) { | ||
| 906 | 911 | apiKey = readSecret(request.user.directories, SECRET_KEYS.GROQ); |
| 907 | 912 | headers = {}; |
| 908 | 913 | bodyParams = {}; |
| 914 | + } else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.NANOGPT) { | |
| 915 | + apiUrl = API_NANOGPT; | |
| 916 | + apiKey = readSecret(request.user.directories, SECRET_KEYS.NANOGPT); | |
| 917 | + headers = {}; | |
| 918 | + bodyParams = {}; | |
| 909 | 919 | } else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.ZEROONEAI) { |
| 910 | 920 | apiUrl = API_01AI; |
| 911 | 921 | apiKey = readSecret(request.user.directories, SECRET_KEYS.ZEROONEAI); |
| @@ -48,6 +48,7 @@ export const SECRET_KEYS = { | ||
| 48 | 48 | BLOCKENTROPY: 'api_key_blockentropy', |
| 49 | 49 | CUSTOM_OPENAI_TTS: 'api_key_custom_openai_tts', |
| 50 | 50 | TAVILY: 'api_key_tavily', |
| 51 | + NANOGPT: 'api_key_nanogpt', | |
| 51 | 52 | }; |
| 52 | 53 | |
| 53 | 54 | // These are the keys that are safe to expose, even if allowKeysExposure is false |