This commit is contained in:
RossAscends
2023-06-24 00:59:09 +09:00
parent 1d4746b743
commit fed47d7477
2 changed files with 64 additions and 5 deletions

View File

@ -5955,6 +5955,64 @@ function displayOverrideWarnings() {
$('.jailbreak_overridden').toggle(!!(characters[this_chid]?.data?.post_history_instructions));
}
function connectAPISlash(_, text) {
if (!text) return;
const apiMap = {
'kobold': {
button: '#api_button',
},
'horde': {
selected: 'koboldhorde',
},
'novel': {
button: '#api_button_novel',
},
'ooba': {
button: '#api_button_textgenerationwebui',
},
'oai': {
selected: 'openai',
source: 'openai',
button: '#api_button_openai',
},
'claude': {
selected: 'openai',
source: 'claude',
button: '#api_button_openai',
},
'windowai': {
selected: 'openai',
source: 'windowai',
button: '#api_button_openai',
},
'poe': {
button: '#poe_connect',
},
};
const apiConfig = apiMap[text];
if (!apiConfig) {
toastr.error(`Error: ${text} is not a valid API`);
return;
}
$("#main_api option[value='" + (apiConfig.selected || text) + "']").prop("selected", true);
$("#main_api").trigger('change');
if (apiConfig.source) {
$("#chat_completion_source option[value='" + apiConfig.source + "']").prop("selected", true);
$("#chat_completion_source").trigger('change');
}
if (apiConfig.button) {
$(apiConfig.button).trigger('click');
}
toastr.info(`API set to ${text}, trying to connect..`);
}
// Check for override warnings every 5 seconds...
setInterval(displayOverrideWarnings, 5000);
// ...or when the chat changes
@ -6017,6 +6075,7 @@ $(document).ready(function () {
//////////INPUT BAR FOCUS-KEEPING LOGIC/////////////
registerSlashCommand('dupe', DupeChar, [], " duplicates the currently selected character", true, true);
registerSlashCommand('api', connectAPISlash, [], " connect to an API", true, true);
setTimeout(function () {
$("#groupControlsToggle").trigger('click');

View File

@ -91,7 +91,7 @@ function addQuickReplyBar(numButtons) {
$('#send_form').prepend(quickReplyBarFullHtml);
$('.quickReplyButton').on('click', function () {
console.log('got quick reply click');
//console.log('got quick reply click');
let quickReplyButtonID = $(this).attr('id');
sendQuickReply(quickReplyButtonID);
});