mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-03-02 10:57:45 +01:00
Merge branch 'staging' into optimize-chat-manager
This commit is contained in:
commit
8c568bfa13
170
public/global.d.ts
vendored
170
public/global.d.ts
vendored
@ -11,103 +11,105 @@ declare var SillyTavern: {
|
||||
libs: typeof libs;
|
||||
};
|
||||
|
||||
// Jquery plugins
|
||||
interface JQuery {
|
||||
nanogallery2(options?: any): JQuery;
|
||||
nanogallery2(method: string, options?: any): JQuery;
|
||||
pagination(method: 'getCurrentPageNum'): number;
|
||||
pagination(method: string, options?: any): JQuery;
|
||||
pagination(options?: any): JQuery;
|
||||
transition(options?: any, complete?: function): JQuery;
|
||||
autocomplete(options?: any): JQuery;
|
||||
autocomplete(method: string, options?: any): JQuery;
|
||||
slider(options?: any): JQuery;
|
||||
slider(method: string, func: string, options?: any): JQuery;
|
||||
cropper(options?: any): JQuery;
|
||||
izoomify(options?: any): JQuery;
|
||||
declare global {
|
||||
// Jquery plugins
|
||||
interface JQuery {
|
||||
nanogallery2(options?: any): JQuery;
|
||||
nanogallery2(method: string, options?: any): JQuery;
|
||||
pagination(method: 'getCurrentPageNum'): number;
|
||||
pagination(method: string, options?: any): JQuery;
|
||||
pagination(options?: any): JQuery;
|
||||
transition(options?: any, complete?: function): JQuery;
|
||||
autocomplete(options?: any): JQuery;
|
||||
autocomplete(method: string, options?: any): JQuery;
|
||||
slider(options?: any): JQuery;
|
||||
slider(method: string, func: string, options?: any): JQuery;
|
||||
cropper(options?: any): JQuery;
|
||||
izoomify(options?: any): JQuery;
|
||||
|
||||
//#region select2
|
||||
//#region select2
|
||||
|
||||
/**
|
||||
* Initializes or modifies a select2 instance with provided options
|
||||
*
|
||||
* @param options - Configuration options for the select2 instance
|
||||
* @returns The jQuery object for chaining
|
||||
*/
|
||||
select2(options?: Select2Options): JQuery;
|
||||
/**
|
||||
* Initializes or modifies a select2 instance with provided options
|
||||
*
|
||||
* @param options - Configuration options for the select2 instance
|
||||
* @returns The jQuery object for chaining
|
||||
*/
|
||||
select2(options?: Select2Options): JQuery;
|
||||
|
||||
/**
|
||||
* Retrieves data currently selected in the select2 instance
|
||||
*
|
||||
* @param field - A string specifying the 'data' method
|
||||
* @returns An array of selected items
|
||||
*/
|
||||
select2(field: 'data'): any[];
|
||||
/**
|
||||
* Retrieves data currently selected in the select2 instance
|
||||
*
|
||||
* @param field - A string specifying the 'data' method
|
||||
* @returns An array of selected items
|
||||
*/
|
||||
select2(field: 'data'): any[];
|
||||
|
||||
/**
|
||||
* Calls the specified select2 method
|
||||
*
|
||||
* @param method - The name of the select2 method to invoke
|
||||
* @returns The jQuery object for chaining
|
||||
*/
|
||||
select2(method: 'open' | 'close' | 'destroy' | 'focus' | 'val', value?: any): JQuery;
|
||||
/**
|
||||
* Calls the specified select2 method
|
||||
*
|
||||
* @param method - The name of the select2 method to invoke
|
||||
* @returns The jQuery object for chaining
|
||||
*/
|
||||
select2(method: 'open' | 'close' | 'destroy' | 'focus' | 'val', value?: any): JQuery;
|
||||
|
||||
//#endregion
|
||||
//#endregion
|
||||
|
||||
//#region sortable
|
||||
//#region sortable
|
||||
|
||||
/**
|
||||
* Initializes or updates a sortable instance with the provided options
|
||||
*
|
||||
* @param options - Configuration options for the sortable instance
|
||||
* @returns The jQuery object for chaining
|
||||
*/
|
||||
sortable(options?: SortableOptions): JQuery;
|
||||
/**
|
||||
* Initializes or updates a sortable instance with the provided options
|
||||
*
|
||||
* @param options - Configuration options for the sortable instance
|
||||
* @returns The jQuery object for chaining
|
||||
*/
|
||||
sortable(options?: SortableOptions): JQuery;
|
||||
|
||||
/**
|
||||
* Calls a sortable method to perform actions on the instance
|
||||
*
|
||||
* @param method - The name of the sortable method to invoke
|
||||
* @returns The jQuery object for chaining
|
||||
*/
|
||||
sortable(method: 'destroy' | 'disable' | 'enable' | 'refresh' | 'toArray'): JQuery;
|
||||
/**
|
||||
* Calls a sortable method to perform actions on the instance
|
||||
*
|
||||
* @param method - The name of the sortable method to invoke
|
||||
* @returns The jQuery object for chaining
|
||||
*/
|
||||
sortable(method: 'destroy' | 'disable' | 'enable' | 'refresh' | 'toArray'): JQuery;
|
||||
|
||||
/**
|
||||
* Retrieves the sortable's instance object. If the element does not have an associated instance, undefined is returned.
|
||||
*
|
||||
* @returns The instance of the sortable object
|
||||
*/
|
||||
sortable(method: 'instance'): object;
|
||||
/**
|
||||
* Retrieves the sortable's instance object. If the element does not have an associated instance, undefined is returned.
|
||||
*
|
||||
* @returns The instance of the sortable object
|
||||
*/
|
||||
sortable(method: 'instance'): object;
|
||||
|
||||
/**
|
||||
* Retrieves the current option value for the specified option
|
||||
*
|
||||
* @param method - The string 'option' to retrieve an option value
|
||||
* @param optionName - The name of the option to retrieve
|
||||
* @returns The value of the specified option
|
||||
*/
|
||||
sortable(method: 'option', optionName: string): any;
|
||||
/**
|
||||
* Retrieves the current option value for the specified option
|
||||
*
|
||||
* @param method - The string 'option' to retrieve an option value
|
||||
* @param optionName - The name of the option to retrieve
|
||||
* @returns The value of the specified option
|
||||
*/
|
||||
sortable(method: 'option', optionName: string): any;
|
||||
|
||||
/**
|
||||
* Sets the value of the specified option
|
||||
*
|
||||
* @param method - The string 'option' to set an option value
|
||||
* @param optionName - The name of the option to set
|
||||
* @param value - The value to assign to the option
|
||||
* @returns The jQuery object for chaining
|
||||
*/
|
||||
sortable(method: 'option', optionName: string, value: any): JQuery;
|
||||
/**
|
||||
* Sets the value of the specified option
|
||||
*
|
||||
* @param method - The string 'option' to set an option value
|
||||
* @param optionName - The name of the option to set
|
||||
* @param value - The value to assign to the option
|
||||
* @returns The jQuery object for chaining
|
||||
*/
|
||||
sortable(method: 'option', optionName: string, value: any): JQuery;
|
||||
|
||||
/**
|
||||
* Sets multiple options using an object
|
||||
*
|
||||
* @param method - The string 'option' to set options
|
||||
* @param options - An object containing multiple option key-value pairs
|
||||
* @returns The jQuery object for chaining
|
||||
*/
|
||||
sortable(method: 'option', options: SortableOptions): JQuery;
|
||||
/**
|
||||
* Sets multiple options using an object
|
||||
*
|
||||
* @param method - The string 'option' to set options
|
||||
* @param options - An object containing multiple option key-value pairs
|
||||
* @returns The jQuery object for chaining
|
||||
*/
|
||||
sortable(method: 'option', options: SortableOptions): JQuery;
|
||||
|
||||
//#endregion
|
||||
//#endregion
|
||||
}
|
||||
}
|
||||
|
||||
//#region select2
|
||||
|
43
public/img/nanogpt.svg
Normal file
43
public/img/nanogpt.svg
Normal file
@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="190.91216mm"
|
||||
height="201.47243mm"
|
||||
viewBox="0 0 190.91216 201.47243"
|
||||
version="1.1"
|
||||
id="svg1"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg">
|
||||
<defs
|
||||
id="defs1" />
|
||||
<g
|
||||
id="layer1"
|
||||
transform="translate(-2.2086436)">
|
||||
<g
|
||||
id="g8"
|
||||
transform="matrix(0.99583856,0,0,1.0472862,2.2086437,-7.9847956)">
|
||||
<path
|
||||
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"
|
||||
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"
|
||||
id="path8" />
|
||||
<path
|
||||
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"
|
||||
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"
|
||||
transform="matrix(0.99545738,0,0,1.0756271,-5.6882567,-3.6821097)"
|
||||
id="path7" />
|
||||
</g>
|
||||
<g
|
||||
id="g1"
|
||||
transform="matrix(0.84984007,0,0,0.87855774,28.999003,5.2337341e-7)">
|
||||
<path
|
||||
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"
|
||||
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"
|
||||
id="path6" />
|
||||
<path
|
||||
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"
|
||||
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"
|
||||
id="text2" />
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 4.1 KiB |
@ -2601,6 +2601,7 @@
|
||||
<option value="groq">Groq</option>
|
||||
<option value="makersuite">Google AI Studio</option>
|
||||
<option value="mistralai">MistralAI</option>
|
||||
<option value="nanogpt">NanoGPT</option>
|
||||
<option value="openrouter">OpenRouter</option>
|
||||
<option value="perplexity">Perplexity</option>
|
||||
<option value="scale">Scale</option>
|
||||
@ -3083,6 +3084,22 @@
|
||||
</optgroup>
|
||||
</select>
|
||||
</div>
|
||||
<div id="nanogpt_form" data-source="nanogpt">
|
||||
<h4 data-i18n="NanoGPT API Key">NanoGPT API Key</h4>
|
||||
<div class="flex-container">
|
||||
<input id="api_key_nanogpt" name="api_key_nanogpt" class="text_pole flex1" value="" type="text" autocomplete="off">
|
||||
<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>
|
||||
</div>
|
||||
<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.">
|
||||
For privacy reasons, your API key will be hidden after you reload the page.
|
||||
</div>
|
||||
<div>
|
||||
<h4 data-i18n="NanoGPT Model">NanoGPT Model</h4>
|
||||
<select id="model_nanogpt_select">
|
||||
<option value="" data-i18n="-- Connect to the API --">-- Connect to the API --</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div id="perplexity_form" data-source="perplexity">
|
||||
<h4 data-i18n="Perplexity API Key">Perplexity API Key</h4>
|
||||
<div class="flex-container">
|
||||
|
@ -388,6 +388,7 @@ function RA_autoconnect(PrevApi) {
|
||||
|| (secret_state[SECRET_KEYS.GROQ] && oai_settings.chat_completion_source == chat_completion_sources.GROQ)
|
||||
|| (secret_state[SECRET_KEYS.ZEROONEAI] && oai_settings.chat_completion_source == chat_completion_sources.ZEROONEAI)
|
||||
|| (secret_state[SECRET_KEYS.BLOCKENTROPY] && oai_settings.chat_completion_source == chat_completion_sources.BLOCKENTROPY)
|
||||
|| (secret_state[SECRET_KEYS.NANOGPT] && oai_settings.chat_completion_source == chat_completion_sources.NANOGPT)
|
||||
|| (isValidUrl(oai_settings.custom_url) && oai_settings.chat_completion_source == chat_completion_sources.CUSTOM)
|
||||
) {
|
||||
$('#api_button_openai').trigger('click');
|
||||
|
@ -182,6 +182,7 @@ export const chat_completion_sources = {
|
||||
GROQ: 'groq',
|
||||
ZEROONEAI: '01ai',
|
||||
BLOCKENTROPY: 'blockentropy',
|
||||
NANOGPT: 'nanogpt',
|
||||
};
|
||||
|
||||
const character_names_behavior = {
|
||||
@ -251,6 +252,7 @@ const default_settings = {
|
||||
cohere_model: 'command-r-plus',
|
||||
perplexity_model: 'llama-3.1-70b-instruct',
|
||||
groq_model: 'llama-3.1-70b-versatile',
|
||||
nanogpt_model: 'gpt-4o-mini',
|
||||
zerooneai_model: 'yi-large',
|
||||
blockentropy_model: 'be-70b-base-llama3.1',
|
||||
custom_model: '',
|
||||
@ -327,6 +329,7 @@ const oai_settings = {
|
||||
cohere_model: 'command-r-plus',
|
||||
perplexity_model: 'llama-3.1-70b-instruct',
|
||||
groq_model: 'llama-3.1-70b-versatile',
|
||||
nanogpt_model: 'gpt-4o-mini',
|
||||
zerooneai_model: 'yi-large',
|
||||
blockentropy_model: 'be-70b-base-llama3.1',
|
||||
custom_model: '',
|
||||
@ -1480,6 +1483,8 @@ function getChatCompletionModel() {
|
||||
return oai_settings.zerooneai_model;
|
||||
case chat_completion_sources.BLOCKENTROPY:
|
||||
return oai_settings.blockentropy_model;
|
||||
case chat_completion_sources.NANOGPT:
|
||||
return oai_settings.nanogpt_model;
|
||||
default:
|
||||
throw new Error(`Unknown chat completion source: ${oai_settings.chat_completion_source}`);
|
||||
}
|
||||
@ -1637,6 +1642,24 @@ function saveModelList(data) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (oai_settings.chat_completion_source == chat_completion_sources.NANOGPT) {
|
||||
$('#model_nanogpt_select').empty();
|
||||
model_list.forEach((model) => {
|
||||
$('#model_nanogpt_select').append(
|
||||
$('<option>', {
|
||||
value: model.id,
|
||||
text: model.id,
|
||||
}));
|
||||
});
|
||||
|
||||
const selectedModel = model_list.find(model => model.id === oai_settings.nanogpt_model);
|
||||
if (model_list.length > 0 && (!selectedModel || !oai_settings.nanogpt_model)) {
|
||||
oai_settings.nanogpt_model = model_list[0].id;
|
||||
}
|
||||
|
||||
$('#model_nanogpt_select').val(oai_settings.nanogpt_model).trigger('change');
|
||||
}
|
||||
}
|
||||
|
||||
function appendOpenRouterOptions(model_list, groupModels = false, sort = false) {
|
||||
@ -2961,6 +2984,7 @@ function loadOpenAISettings(data, settings) {
|
||||
oai_settings.cohere_model = settings.cohere_model ?? default_settings.cohere_model;
|
||||
oai_settings.perplexity_model = settings.perplexity_model ?? default_settings.perplexity_model;
|
||||
oai_settings.groq_model = settings.groq_model ?? default_settings.groq_model;
|
||||
oai_settings.nanogpt_model = settings.nanogpt_model ?? default_settings.nanogpt_model;
|
||||
oai_settings.blockentropy_model = settings.blockentropy_model ?? default_settings.blockentropy_model;
|
||||
oai_settings.zerooneai_model = settings.zerooneai_model ?? default_settings.zerooneai_model;
|
||||
oai_settings.custom_model = settings.custom_model ?? default_settings.custom_model;
|
||||
@ -3041,6 +3065,8 @@ function loadOpenAISettings(data, settings) {
|
||||
$(`#model_perplexity_select option[value="${oai_settings.perplexity_model}"`).attr('selected', true);
|
||||
$('#model_groq_select').val(oai_settings.groq_model);
|
||||
$(`#model_groq_select option[value="${oai_settings.groq_model}"`).attr('selected', true);
|
||||
$('#model_nanogpt_select').val(oai_settings.nanogpt_model);
|
||||
$(`#model_nanogpt_select option[value="${oai_settings.nanogpt_model}"`).attr('selected', true);
|
||||
$('#model_01ai_select').val(oai_settings.zerooneai_model);
|
||||
$('#model_blockentropy_select').val(oai_settings.blockentropy_model);
|
||||
$('#custom_model_id').val(oai_settings.custom_model);
|
||||
@ -3735,6 +3761,7 @@ function onSettingsPresetChange() {
|
||||
cohere_model: ['#model_cohere_select', 'cohere_model', false],
|
||||
perplexity_model: ['#model_perplexity_select', 'perplexity_model', false],
|
||||
groq_model: ['#model_groq_select', 'groq_model', false],
|
||||
nanogpt_model: ['#model_nanogpt_select', 'nanogpt_model', false],
|
||||
zerooneai_model: ['#model_01ai_select', 'zerooneai_model', false],
|
||||
blockentropy_model: ['#model_blockentropy_select', 'blockentropy_model', false],
|
||||
custom_model: ['#custom_model_id', 'custom_model', false],
|
||||
@ -3984,6 +4011,16 @@ async function onModelChange() {
|
||||
oai_settings.groq_model = value;
|
||||
}
|
||||
|
||||
if ($(this).is('#model_nanogpt_select')) {
|
||||
if (!value) {
|
||||
console.debug('Null NanoGPT model selected. Ignoring.');
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('NanoGPT model changed to', value);
|
||||
oai_settings.nanogpt_model = value;
|
||||
}
|
||||
|
||||
if (value && $(this).is('#model_01ai_select')) {
|
||||
console.log('01.AI model changed to', value);
|
||||
oai_settings.zerooneai_model = value;
|
||||
@ -4294,6 +4331,18 @@ async function onModelChange() {
|
||||
$('#temp_openai').attr('max', oai_max_temp).val(oai_settings.temp_openai).trigger('input');
|
||||
}
|
||||
|
||||
if (oai_settings.chat_completion_source === chat_completion_sources.NANOGPT) {
|
||||
if (oai_settings.max_context_unlocked) {
|
||||
$('#openai_max_context').attr('max', unlocked_max);
|
||||
} else {
|
||||
$('#openai_max_context').attr('max', max_128k);
|
||||
}
|
||||
|
||||
oai_settings.openai_max_context = Math.min(Number($('#openai_max_context').attr('max')), oai_settings.openai_max_context);
|
||||
$('#openai_max_context').val(oai_settings.openai_max_context).trigger('input');
|
||||
$('#temp_openai').attr('max', oai_max_temp).val(oai_settings.temp_openai).trigger('input');
|
||||
}
|
||||
|
||||
if (oai_settings.chat_completion_source === chat_completion_sources.COHERE) {
|
||||
oai_settings.pres_pen_openai = Math.min(Math.max(0, oai_settings.pres_pen_openai), 1);
|
||||
$('#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) {
|
||||
}
|
||||
}
|
||||
|
||||
if (oai_settings.chat_completion_source == chat_completion_sources.NANOGPT) {
|
||||
const api_key_nanogpt = String($('#api_key_nanogpt').val()).trim();
|
||||
|
||||
if (api_key_nanogpt.length) {
|
||||
await writeSecret(SECRET_KEYS.NANOGPT, api_key_nanogpt);
|
||||
}
|
||||
|
||||
if (!secret_state[SECRET_KEYS.NANOGPT]) {
|
||||
console.log('No secret key saved for NanoGPT');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (oai_settings.chat_completion_source == chat_completion_sources.ZEROONEAI) {
|
||||
const api_key_01ai = String($('#api_key_01ai').val()).trim();
|
||||
|
||||
@ -4567,6 +4629,9 @@ function toggleChatCompletionForms() {
|
||||
else if (oai_settings.chat_completion_source == chat_completion_sources.GROQ) {
|
||||
$('#model_groq_select').trigger('change');
|
||||
}
|
||||
else if (oai_settings.chat_completion_source == chat_completion_sources.NANOGPT) {
|
||||
$('#model_nanogpt_select').trigger('change');
|
||||
}
|
||||
else if (oai_settings.chat_completion_source == chat_completion_sources.ZEROONEAI) {
|
||||
$('#model_01ai_select').trigger('change');
|
||||
}
|
||||
@ -5288,6 +5353,7 @@ export function initOpenAI() {
|
||||
$('#model_cohere_select').on('change', onModelChange);
|
||||
$('#model_perplexity_select').on('change', onModelChange);
|
||||
$('#model_groq_select').on('change', onModelChange);
|
||||
$('#model_nanogpt_select').on('change', onModelChange);
|
||||
$('#model_01ai_select').on('change', onModelChange);
|
||||
$('#model_blockentropy_select').on('change', onModelChange);
|
||||
$('#model_custom_select').on('change', onModelChange);
|
||||
|
@ -35,6 +35,7 @@ export const SECRET_KEYS = {
|
||||
STABILITY: 'api_key_stability',
|
||||
BLOCKENTROPY: 'api_key_blockentropy',
|
||||
CUSTOM_OPENAI_TTS: 'api_key_custom_openai_tts',
|
||||
NANOGPT: 'api_key_nanogpt',
|
||||
TAVILY: 'api_key_tavily',
|
||||
};
|
||||
|
||||
@ -68,6 +69,7 @@ const INPUT_MAP = {
|
||||
[SECRET_KEYS.ZEROONEAI]: '#api_key_01ai',
|
||||
[SECRET_KEYS.HUGGINGFACE]: '#api_key_huggingface',
|
||||
[SECRET_KEYS.BLOCKENTROPY]: '#api_key_blockentropy',
|
||||
[SECRET_KEYS.NANOGPT]: '#api_key_nanogpt',
|
||||
};
|
||||
|
||||
async function clearSecret() {
|
||||
|
@ -3634,6 +3634,7 @@ function getModelOptions(quiet) {
|
||||
{ id: 'model_cohere_select', api: 'openai', type: chat_completion_sources.COHERE },
|
||||
{ id: 'model_perplexity_select', api: 'openai', type: chat_completion_sources.PERPLEXITY },
|
||||
{ id: 'model_groq_select', api: 'openai', type: chat_completion_sources.GROQ },
|
||||
{ id: 'model_nanogpt_select', api: 'openai', type: chat_completion_sources.NANOGPT },
|
||||
{ id: 'model_01ai_select', api: 'openai', type: chat_completion_sources.ZEROONEAI },
|
||||
{ id: 'model_blockentropy_select', api: 'openai', type: chat_completion_sources.BLOCKENTROPY },
|
||||
{ id: 'model_novel_select', api: 'novel', type: null },
|
||||
|
@ -200,6 +200,7 @@ export const CHAT_COMPLETION_SOURCES = {
|
||||
GROQ: 'groq',
|
||||
ZEROONEAI: '01ai',
|
||||
BLOCKENTROPY: 'blockentropy',
|
||||
NANOGPT: 'nanogpt',
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -48,6 +48,7 @@ const API_MAKERSUITE = 'https://generativelanguage.googleapis.com';
|
||||
const API_01AI = 'https://api.01.ai/v1';
|
||||
const API_BLOCKENTROPY = 'https://api.blockentropy.ai/v1';
|
||||
const API_AI21 = 'https://api.ai21.com/studio/v1';
|
||||
const API_NANOGPT = 'https://nano-gpt.com/api/v1';
|
||||
|
||||
/**
|
||||
* Applies a post-processing step to the generated messages.
|
||||
@ -656,6 +657,10 @@ router.post('/status', jsonParser, async function (request, response_getstatus_o
|
||||
api_url = API_BLOCKENTROPY;
|
||||
api_key_openai = readSecret(request.user.directories, SECRET_KEYS.BLOCKENTROPY);
|
||||
headers = {};
|
||||
} else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.NANOGPT) {
|
||||
api_url = API_NANOGPT;
|
||||
api_key_openai = readSecret(request.user.directories, SECRET_KEYS.NANOGPT);
|
||||
headers = {};
|
||||
} else {
|
||||
console.log('This chat completion source is not supported yet.');
|
||||
return response_getstatus_openai.status(400).send({ error: true });
|
||||
@ -906,6 +911,11 @@ router.post('/generate', jsonParser, function (request, response) {
|
||||
apiKey = readSecret(request.user.directories, SECRET_KEYS.GROQ);
|
||||
headers = {};
|
||||
bodyParams = {};
|
||||
} else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.NANOGPT) {
|
||||
apiUrl = API_NANOGPT;
|
||||
apiKey = readSecret(request.user.directories, SECRET_KEYS.NANOGPT);
|
||||
headers = {};
|
||||
bodyParams = {};
|
||||
} else if (request.body.chat_completion_source === CHAT_COMPLETION_SOURCES.ZEROONEAI) {
|
||||
apiUrl = API_01AI;
|
||||
apiKey = readSecret(request.user.directories, SECRET_KEYS.ZEROONEAI);
|
||||
|
@ -48,6 +48,7 @@ export const SECRET_KEYS = {
|
||||
BLOCKENTROPY: 'api_key_blockentropy',
|
||||
CUSTOM_OPENAI_TTS: 'api_key_custom_openai_tts',
|
||||
TAVILY: 'api_key_tavily',
|
||||
NANOGPT: 'api_key_nanogpt',
|
||||
};
|
||||
|
||||
// These are the keys that are safe to expose, even if allowKeysExposure is false
|
||||
|
Loading…
x
Reference in New Issue
Block a user