Improve building CONNECT_API_MAP - Automatically fill `CONNECT_API_MAP` based on the registered text comp and chat comp APIs. - Allow custom APIs and custom overrides to be set first.

5aad29bd5be4ab56655db8fe40aa5b5dc2df63ae

Wolfsblvt <wolfsblvt@gmail.com>

1 files changed, +20 -123Showing whitespace changes
public/script.js+20 -123
@@ -8303,6 +8303,7 @@ const swipe_right = () => {
83038303};
83048304
83058305const CONNECT_API_MAP = {
8306+ // Default APIs not contined inside text gen / chat gen
83068307 'kobold': {
83078308 selected: 'kobold',
83088309 button: '#api_button',
@@ -8314,152 +8315,48 @@ const CONNECT_API_MAP = {
83148315 selected: 'novel',
83158316 button: '#api_button_novel',
83168317 },
8317- 'ooba': {
8318+ // KoboldCpp alias
8318- selected: 'textgenerationwebui',
8319- button: '#api_button_textgenerationwebui',
8320- type: textgen_types.OOBA,
8321- },
8322- 'tabby': {
8323- selected: 'textgenerationwebui',
8324- button: '#api_button_textgenerationwebui',
8325- type: textgen_types.TABBY,
8326- },
8327- 'llamacpp': {
8328- selected: 'textgenerationwebui',
8329- button: '#api_button_textgenerationwebui',
8330- type: textgen_types.LLAMACPP,
8331- },
8332- 'ollama': {
8333- selected: 'textgenerationwebui',
8334- button: '#api_button_textgenerationwebui',
8335- type: textgen_types.OLLAMA,
8336- },
8337- 'mancer': {
8338- selected: 'textgenerationwebui',
8339- button: '#api_button_textgenerationwebui',
8340- type: textgen_types.MANCER,
8341- },
8342- 'vllm': {
8343- selected: 'textgenerationwebui',
8344- button: '#api_button_textgenerationwebui',
8345- type: textgen_types.VLLM,
8346- },
8347- 'aphrodite': {
8348- selected: 'textgenerationwebui',
8349- button: '#api_button_textgenerationwebui',
8350- type: textgen_types.APHRODITE,
8351- },
8352- 'koboldcpp': {
8353- selected: 'textgenerationwebui',
8354- button: '#api_button_textgenerationwebui',
8355- type: textgen_types.KOBOLDCPP,
8356- },
83578319 'kcpp': {
83588320 selected: 'textgenerationwebui',
83598321 button: '#api_button_textgenerationwebui',
83608322 type: textgen_types.KOBOLDCPP,
83618323 },
8362- 'togetherai': {
8324+ // OpenAI alias
8363- selected: 'textgenerationwebui',
8364- button: '#api_button_textgenerationwebui',
8365- type: textgen_types.TOGETHERAI,
8366- },
8367- 'openai': {
8368- selected: 'openai',
8369- button: '#api_button_openai',
8370- source: chat_completion_sources.OPENAI,
8371- },
83728325 'oai': {
83738326 selected: 'openai',
83748327 button: '#api_button_openai',
83758328 source: chat_completion_sources.OPENAI,
83768329 },
8377- 'claude': {
8330+ // OpenRouter special naming, to differentiate between chat comp and text comp
8378- selected: 'openai',
8379- button: '#api_button_openai',
8380- source: chat_completion_sources.CLAUDE,
8381- },
8382- 'windowai': {
8383- selected: 'openai',
8384- button: '#api_button_openai',
8385- source: chat_completion_sources.WINDOWAI,
8386- },
83878331 'openrouter': {
83888332 selected: 'openai',
83898333 button: '#api_button_openai',
83908334 source: chat_completion_sources.OPENROUTER,
83918335 },
8392- 'scale': {
8393- selected: 'openai',
8394- button: '#api_button_openai',
8395- source: chat_completion_sources.SCALE,
8396- },
8397- 'ai21': {
8398- selected: 'openai',
8399- button: '#api_button_openai',
8400- source: chat_completion_sources.AI21,
8401- },
8402- 'makersuite': {
8403- selected: 'openai',
8404- button: '#api_button_openai',
8405- source: chat_completion_sources.MAKERSUITE,
8406- },
8407- 'mistralai': {
8408- selected: 'openai',
8409- button: '#api_button_openai',
8410- source: chat_completion_sources.MISTRALAI,
8411- },
8412- 'custom': {
8413- selected: 'openai',
8414- button: '#api_button_openai',
8415- source: chat_completion_sources.CUSTOM,
8416- },
8417- 'cohere': {
8418- selected: 'openai',
8419- button: '#api_button_openai',
8420- source: chat_completion_sources.COHERE,
8421- },
8422- 'perplexity': {
8423- selected: 'openai',
8424- button: '#api_button_openai',
8425- source: chat_completion_sources.PERPLEXITY,
8426- },
8427- 'groq': {
8428- selected: 'openai',
8429- button: '#api_button_openai',
8430- source: chat_completion_sources.GROQ,
8431- },
8432- '01ai': {
8433- selected: 'openai',
8434- button: '#api_button_openai',
8435- source: chat_completion_sources.ZEROONEAI,
8436- },
8437- 'infermaticai': {
8438- selected: 'textgenerationwebui',
8439- button: '#api_button_textgenerationwebui',
8440- type: textgen_types.INFERMATICAI,
8441- },
8442- 'dreamgen': {
8443- selected: 'textgenerationwebui',
8444- button: '#api_button_textgenerationwebui',
8445- type: textgen_types.DREAMGEN,
8446- },
84478336 'openrouter-text': {
84488337 selected: 'textgenerationwebui',
84498338 button: '#api_button_textgenerationwebui',
84508339 type: textgen_types.OPENROUTER,
84518340 },
8452- 'featherless': {
8341+};
8453- selected: 'textgenerationwebui',
8342+
8454- button: '#api_button_textgenerationwebui',
8343+// Fill connections map from textgen_types and chat_completion_sources
8455- type: textgen_types.FEATHERLESS,
8344+for (const textGenType of Object.values(textgen_types)) {
8456- },
8345+ if (CONNECT_API_MAP[textGenType]) continue;
8457- 'huggingface': {
8346+ CONNECT_API_MAP[textGenType] = {
84588347 selected: 'textgenerationwebui',
84598348 button: '#api_button_textgenerationwebui',
84608349 type: textgen_types.HUGGINGFACEtextGenType,
8461- },
84628350 };
8351+}
8352+for (const chatCompletionSource of Object.values(chat_completion_sources)) {
8353+ if (CONNECT_API_MAP[chatCompletionSource]) continue;
8354+ CONNECT_API_MAP[chatCompletionSource] = {
8355+ selected: 'openai',
8356+ button: '#api_button_openai',
8357+ source: chatCompletionSource,
8358+ };
8359+}
84638360
84648361async function selectContextCallback(_, name) {
84658362 if (!name) {