mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
/api returns current name if no params
This commit is contained in:
@@ -8020,12 +8020,14 @@ const swipe_right = () => {
|
|||||||
|
|
||||||
const CONNECT_API_MAP = {
|
const CONNECT_API_MAP = {
|
||||||
'kobold': {
|
'kobold': {
|
||||||
|
selected: 'kobold',
|
||||||
button: '#api_button',
|
button: '#api_button',
|
||||||
},
|
},
|
||||||
'horde': {
|
'horde': {
|
||||||
selected: 'koboldhorde',
|
selected: 'koboldhorde',
|
||||||
},
|
},
|
||||||
'novel': {
|
'novel': {
|
||||||
|
selected: 'novel',
|
||||||
button: '#api_button_novel',
|
button: '#api_button_novel',
|
||||||
},
|
},
|
||||||
'ooba': {
|
'ooba': {
|
||||||
@@ -8063,6 +8065,11 @@ const CONNECT_API_MAP = {
|
|||||||
button: '#api_button_textgenerationwebui',
|
button: '#api_button_textgenerationwebui',
|
||||||
type: textgen_types.APHRODITE,
|
type: textgen_types.APHRODITE,
|
||||||
},
|
},
|
||||||
|
'koboldcpp': {
|
||||||
|
selected: 'textgenerationwebui',
|
||||||
|
button: '#api_button_textgenerationwebui',
|
||||||
|
type: textgen_types.KOBOLDCPP,
|
||||||
|
},
|
||||||
'kcpp': {
|
'kcpp': {
|
||||||
selected: 'textgenerationwebui',
|
selected: 'textgenerationwebui',
|
||||||
button: '#api_button_textgenerationwebui',
|
button: '#api_button_textgenerationwebui',
|
||||||
@@ -8073,6 +8080,11 @@ const CONNECT_API_MAP = {
|
|||||||
button: '#api_button_textgenerationwebui',
|
button: '#api_button_textgenerationwebui',
|
||||||
type: textgen_types.TOGETHERAI,
|
type: textgen_types.TOGETHERAI,
|
||||||
},
|
},
|
||||||
|
'openai': {
|
||||||
|
selected: 'openai',
|
||||||
|
button: '#api_button_openai',
|
||||||
|
source: chat_completion_sources.OPENAI,
|
||||||
|
},
|
||||||
'oai': {
|
'oai': {
|
||||||
selected: 'openai',
|
selected: 'openai',
|
||||||
button: '#api_button_openai',
|
button: '#api_button_openai',
|
||||||
@@ -8200,7 +8212,29 @@ async function disableInstructCallback() {
|
|||||||
* @param {string} text API name
|
* @param {string} text API name
|
||||||
*/
|
*/
|
||||||
async function connectAPISlash(_, text) {
|
async function connectAPISlash(_, text) {
|
||||||
if (!text) return;
|
if (!text.trim()) {
|
||||||
|
for (const [key, config] of Object.entries(CONNECT_API_MAP)) {
|
||||||
|
if (config.selected !== main_api) continue;
|
||||||
|
|
||||||
|
if (config.source) {
|
||||||
|
if (oai_settings.chat_completion_source === config.source) {
|
||||||
|
return key;
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.type) {
|
||||||
|
if (textgen_settings.type === config.type) {
|
||||||
|
return key;
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const apiConfig = CONNECT_API_MAP[text.toLowerCase()];
|
const apiConfig = CONNECT_API_MAP[text.toLowerCase()];
|
||||||
if (!apiConfig) {
|
if (!apiConfig) {
|
||||||
@@ -8646,7 +8680,7 @@ jQuery(async function () {
|
|||||||
],
|
],
|
||||||
helpString: `
|
helpString: `
|
||||||
<div>
|
<div>
|
||||||
Connect to an API.
|
Connect to an API. If no argument is provided, it will return the currently connected API.
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<strong>Available APIs:</strong>
|
<strong>Available APIs:</strong>
|
||||||
|
Reference in New Issue
Block a user