Merge pull request #2578 from SillyTavern/improve-building-CONNECT_API_MAP Improve building CONNECT_API_MAP

712f8a56e44d2ace3d09a74542dd379f39f04c10

Cohee <18619528+Cohee1207@users.noreply.github.com>

Signed
1 files changed, +20 -123Showing whitespace changes
public/script.js+20 -123
@@ -8310,6 +8310,7 @@ const swipe_right = () => {
8310};8310};
83118311
8312const CONNECT_API_MAP = {8312const CONNECT_API_MAP = {
8313 // Default APIs not contined inside text gen / chat gen
8313 'kobold': {8314 'kobold': {
8314 selected: 'kobold',8315 selected: 'kobold',
8315 button: '#api_button',8316 button: '#api_button',
@@ -8321,152 +8322,48 @@ const CONNECT_API_MAP = {
8321 selected: 'novel',8322 selected: 'novel',
8322 button: '#api_button_novel',8323 button: '#api_button_novel',
8323 },8324 },
8324 'ooba': {8325 // KoboldCpp alias
8325 selected: 'textgenerationwebui',
8326 button: '#api_button_textgenerationwebui',
8327 type: textgen_types.OOBA,
8328 },
8329 'tabby': {
8330 selected: 'textgenerationwebui',
8331 button: '#api_button_textgenerationwebui',
8332 type: textgen_types.TABBY,
8333 },
8334 'llamacpp': {
8335 selected: 'textgenerationwebui',
8336 button: '#api_button_textgenerationwebui',
8337 type: textgen_types.LLAMACPP,
8338 },
8339 'ollama': {
8340 selected: 'textgenerationwebui',
8341 button: '#api_button_textgenerationwebui',
8342 type: textgen_types.OLLAMA,
8343 },
8344 'mancer': {
8345 selected: 'textgenerationwebui',
8346 button: '#api_button_textgenerationwebui',
8347 type: textgen_types.MANCER,
8348 },
8349 'vllm': {
8350 selected: 'textgenerationwebui',
8351 button: '#api_button_textgenerationwebui',
8352 type: textgen_types.VLLM,
8353 },
8354 'aphrodite': {
8355 selected: 'textgenerationwebui',
8356 button: '#api_button_textgenerationwebui',
8357 type: textgen_types.APHRODITE,
8358 },
8359 'koboldcpp': {
8360 selected: 'textgenerationwebui',
8361 button: '#api_button_textgenerationwebui',
8362 type: textgen_types.KOBOLDCPP,
8363 },
8364 'kcpp': {8326 'kcpp': {
8365 selected: 'textgenerationwebui',8327 selected: 'textgenerationwebui',
8366 button: '#api_button_textgenerationwebui',8328 button: '#api_button_textgenerationwebui',
8367 type: textgen_types.KOBOLDCPP,8329 type: textgen_types.KOBOLDCPP,
8368 },8330 },
8369 'togetherai': {8331 // OpenAI alias
8370 selected: 'textgenerationwebui',
8371 button: '#api_button_textgenerationwebui',
8372 type: textgen_types.TOGETHERAI,
8373 },
8374 'openai': {
8375 selected: 'openai',
8376 button: '#api_button_openai',
8377 source: chat_completion_sources.OPENAI,
8378 },
8379 'oai': {8332 'oai': {
8380 selected: 'openai',8333 selected: 'openai',
8381 button: '#api_button_openai',8334 button: '#api_button_openai',
8382 source: chat_completion_sources.OPENAI,8335 source: chat_completion_sources.OPENAI,
8383 },8336 },
8384 'claude': {8337 // OpenRouter special naming, to differentiate between chat comp and text comp
8385 selected: 'openai',
8386 button: '#api_button_openai',
8387 source: chat_completion_sources.CLAUDE,
8388 },
8389 'windowai': {
8390 selected: 'openai',
8391 button: '#api_button_openai',
8392 source: chat_completion_sources.WINDOWAI,
8393 },
8394 'openrouter': {8338 'openrouter': {
8395 selected: 'openai',8339 selected: 'openai',
8396 button: '#api_button_openai',8340 button: '#api_button_openai',
8397 source: chat_completion_sources.OPENROUTER,8341 source: chat_completion_sources.OPENROUTER,
8398 },8342 },
8399 'scale': {
8400 selected: 'openai',
8401 button: '#api_button_openai',
8402 source: chat_completion_sources.SCALE,
8403 },
8404 'ai21': {
8405 selected: 'openai',
8406 button: '#api_button_openai',
8407 source: chat_completion_sources.AI21,
8408 },
8409 'makersuite': {
8410 selected: 'openai',
8411 button: '#api_button_openai',
8412 source: chat_completion_sources.MAKERSUITE,
8413 },
8414 'mistralai': {
8415 selected: 'openai',
8416 button: '#api_button_openai',
8417 source: chat_completion_sources.MISTRALAI,
8418 },
8419 'custom': {
8420 selected: 'openai',
8421 button: '#api_button_openai',
8422 source: chat_completion_sources.CUSTOM,
8423 },
8424 'cohere': {
8425 selected: 'openai',
8426 button: '#api_button_openai',
8427 source: chat_completion_sources.COHERE,
8428 },
8429 'perplexity': {
8430 selected: 'openai',
8431 button: '#api_button_openai',
8432 source: chat_completion_sources.PERPLEXITY,
8433 },
8434 'groq': {
8435 selected: 'openai',
8436 button: '#api_button_openai',
8437 source: chat_completion_sources.GROQ,
8438 },
8439 '01ai': {
8440 selected: 'openai',
8441 button: '#api_button_openai',
8442 source: chat_completion_sources.ZEROONEAI,
8443 },
8444 'infermaticai': {
8445 selected: 'textgenerationwebui',
8446 button: '#api_button_textgenerationwebui',
8447 type: textgen_types.INFERMATICAI,
8448 },
8449 'dreamgen': {
8450 selected: 'textgenerationwebui',
8451 button: '#api_button_textgenerationwebui',
8452 type: textgen_types.DREAMGEN,
8453 },
8454 'openrouter-text': {8343 'openrouter-text': {
8455 selected: 'textgenerationwebui',8344 selected: 'textgenerationwebui',
8456 button: '#api_button_textgenerationwebui',8345 button: '#api_button_textgenerationwebui',
8457 type: textgen_types.OPENROUTER,8346 type: textgen_types.OPENROUTER,
8458 },8347 },
8459 'featherless': {8348};
8460 selected: 'textgenerationwebui',8349
8461 button: '#api_button_textgenerationwebui',8350// Fill connections map from textgen_types and chat_completion_sources
8462 type: textgen_types.FEATHERLESS,8351for (const textGenType of Object.values(textgen_types)) {
8463 },8352 if (CONNECT_API_MAP[textGenType]) continue;
8464 'huggingface': {8353 CONNECT_API_MAP[textGenType] = {
8465 selected: 'textgenerationwebui',8354 selected: 'textgenerationwebui',
8466 button: '#api_button_textgenerationwebui',8355 button: '#api_button_textgenerationwebui',
8467 type: textgen_types.HUGGINGFACE,8356 type: textGenType,
8468 },
8469 };8357 };
8358}
8359for (const chatCompletionSource of Object.values(chat_completion_sources)) {
8360 if (CONNECT_API_MAP[chatCompletionSource]) continue;
8361 CONNECT_API_MAP[chatCompletionSource] = {
8362 selected: 'openai',
8363 button: '#api_button_openai',
8364 source: chatCompletionSource,
8365 };
8366}
84708367
8471async function selectContextCallback(_, name) {8368async function selectContextCallback(_, name) {
8472 if (!name) {8369 if (!name) {