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 = () => {
83108310};
83118311
83128312const CONNECT_API_MAP = {
8313+ // Default APIs not contined inside text gen / chat gen
83138314 'kobold': {
83148315 selected: 'kobold',
83158316 button: '#api_button',
@@ -8321,152 +8322,48 @@ const CONNECT_API_MAP = {
83218322 selected: 'novel',
83228323 button: '#api_button_novel',
83238324 },
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- },
83648326 'kcpp': {
83658327 selected: 'textgenerationwebui',
83668328 button: '#api_button_textgenerationwebui',
83678329 type: textgen_types.KOBOLDCPP,
83688330 },
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- },
83798332 'oai': {
83808333 selected: 'openai',
83818334 button: '#api_button_openai',
83828335 source: chat_completion_sources.OPENAI,
83838336 },
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- },
83948338 'openrouter': {
83958339 selected: 'openai',
83968340 button: '#api_button_openai',
83978341 source: chat_completion_sources.OPENROUTER,
83988342 },
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- },
84548343 'openrouter-text': {
84558344 selected: 'textgenerationwebui',
84568345 button: '#api_button_textgenerationwebui',
84578346 type: textgen_types.OPENROUTER,
84588347 },
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,
8351+for (const textGenType of Object.values(textgen_types)) {
8463- },
8352+ if (CONNECT_API_MAP[textGenType]) continue;
8464- 'huggingface': {
8353+ CONNECT_API_MAP[textGenType] = {
84658354 selected: 'textgenerationwebui',
84668355 button: '#api_button_textgenerationwebui',
84678356 type: textgen_types.HUGGINGFACEtextGenType,
8468- },
84698357 };
8358+}
8359+for (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
84718368async function selectContextCallback(_, name) {
84728369 if (!name) {