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 = () => {
8303};8303};
83048304
8305const CONNECT_API_MAP = {8305const CONNECT_API_MAP = {
8306 // Default APIs not contined inside text gen / chat gen
8306 'kobold': {8307 'kobold': {
8307 selected: 'kobold',8308 selected: 'kobold',
8308 button: '#api_button',8309 button: '#api_button',
@@ -8314,152 +8315,48 @@ const CONNECT_API_MAP = {
8314 selected: 'novel',8315 selected: 'novel',
8315 button: '#api_button_novel',8316 button: '#api_button_novel',
8316 },8317 },
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 },
8357 'kcpp': {8319 'kcpp': {
8358 selected: 'textgenerationwebui',8320 selected: 'textgenerationwebui',
8359 button: '#api_button_textgenerationwebui',8321 button: '#api_button_textgenerationwebui',
8360 type: textgen_types.KOBOLDCPP,8322 type: textgen_types.KOBOLDCPP,
8361 },8323 },
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 },
8372 'oai': {8325 'oai': {
8373 selected: 'openai',8326 selected: 'openai',
8374 button: '#api_button_openai',8327 button: '#api_button_openai',
8375 source: chat_completion_sources.OPENAI,8328 source: chat_completion_sources.OPENAI,
8376 },8329 },
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 },
8387 'openrouter': {8331 'openrouter': {
8388 selected: 'openai',8332 selected: 'openai',
8389 button: '#api_button_openai',8333 button: '#api_button_openai',
8390 source: chat_completion_sources.OPENROUTER,8334 source: chat_completion_sources.OPENROUTER,
8391 },8335 },
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 },
8447 'openrouter-text': {8336 'openrouter-text': {
8448 selected: 'textgenerationwebui',8337 selected: 'textgenerationwebui',
8449 button: '#api_button_textgenerationwebui',8338 button: '#api_button_textgenerationwebui',
8450 type: textgen_types.OPENROUTER,8339 type: textgen_types.OPENROUTER,
8451 },8340 },
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,8344for (const textGenType of Object.values(textgen_types)) {
8456 },8345 if (CONNECT_API_MAP[textGenType]) continue;
8457 'huggingface': {8346 CONNECT_API_MAP[textGenType] = {
8458 selected: 'textgenerationwebui',8347 selected: 'textgenerationwebui',
8459 button: '#api_button_textgenerationwebui',8348 button: '#api_button_textgenerationwebui',
8460 type: textgen_types.HUGGINGFACE,8349 type: textGenType,
8461 },
8462 };8350 };
8351}
8352for (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
8464async function selectContextCallback(_, name) {8361async function selectContextCallback(_, name) {
8465 if (!name) {8362 if (!name) {