mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge branch 'staging' into smol-tag-improvements
This commit is contained in:
@ -22,7 +22,7 @@ import {
|
||||
parseTabbyLogprobs,
|
||||
} from './scripts/textgen-settings.js';
|
||||
|
||||
const { MANCER, TOGETHERAI, OOBA, VLLM, APHRODITE, OLLAMA, INFERMATICAI, DREAMGEN, OPENROUTER } = textgen_types;
|
||||
const { MANCER, TOGETHERAI, OOBA, VLLM, APHRODITE, TABBY, OLLAMA, INFERMATICAI, DREAMGEN, OPENROUTER } = textgen_types;
|
||||
|
||||
import {
|
||||
world_info,
|
||||
@ -443,6 +443,8 @@ export const event_types = {
|
||||
FILE_ATTACHMENT_DELETED: 'file_attachment_deleted',
|
||||
WORLDINFO_FORCE_ACTIVATE: 'worldinfo_force_activate',
|
||||
OPEN_CHARACTER_LIBRARY: 'open_character_library',
|
||||
LLM_FUNCTION_TOOL_REGISTER: 'llm_function_tool_register',
|
||||
LLM_FUNCTION_TOOL_CALL: 'llm_function_tool_call',
|
||||
};
|
||||
|
||||
export const eventSource = new EventEmitter();
|
||||
@ -1814,7 +1816,7 @@ export function messageFormatting(mes, ch_name, isSystem, isUser, messageId) {
|
||||
}
|
||||
|
||||
if (Number(messageId) === 0 && !isSystem && !isUser) {
|
||||
mes = substituteParams(mes);
|
||||
mes = substituteParams(mes, undefined, ch_name);
|
||||
}
|
||||
|
||||
mesForShowdownParse = mes;
|
||||
@ -4203,7 +4205,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
|
||||
const displayIncomplete = type === 'quiet' && !quietToLoud;
|
||||
getMessage = cleanUpMessage(getMessage, isImpersonate, isContinue, displayIncomplete);
|
||||
|
||||
if (getMessage.length > 0) {
|
||||
if (getMessage.length > 0 || data.allowEmptyResponse) {
|
||||
if (isImpersonate) {
|
||||
$('#send_textarea').val(getMessage)[0].dispatchEvent(new Event('input', { bubbles: true }));
|
||||
generatedPromptCache = '';
|
||||
@ -5026,7 +5028,7 @@ function extractMultiSwipes(data, type) {
|
||||
return swipes;
|
||||
}
|
||||
|
||||
if (main_api === 'openai' || (main_api === 'textgenerationwebui' && [MANCER, VLLM, APHRODITE].includes(textgen_settings.type))) {
|
||||
if (main_api === 'openai' || (main_api === 'textgenerationwebui' && [MANCER, VLLM, APHRODITE, TABBY].includes(textgen_settings.type))) {
|
||||
if (!Array.isArray(data.choices)) {
|
||||
return swipes;
|
||||
}
|
||||
@ -7852,6 +7854,7 @@ function swipe_left() { // when we swipe left..but no generation.
|
||||
*/
|
||||
async function branchChat(mesId) {
|
||||
const fileName = await createBranch(mesId);
|
||||
await saveItemizedPrompts(fileName);
|
||||
|
||||
if (selected_group) {
|
||||
await openGroupChat(selected_group, fileName);
|
||||
@ -8044,12 +8047,14 @@ const swipe_right = () => {
|
||||
|
||||
const CONNECT_API_MAP = {
|
||||
'kobold': {
|
||||
selected: 'kobold',
|
||||
button: '#api_button',
|
||||
},
|
||||
'horde': {
|
||||
selected: 'koboldhorde',
|
||||
},
|
||||
'novel': {
|
||||
selected: 'novel',
|
||||
button: '#api_button_novel',
|
||||
},
|
||||
'ooba': {
|
||||
@ -8087,6 +8092,11 @@ const CONNECT_API_MAP = {
|
||||
button: '#api_button_textgenerationwebui',
|
||||
type: textgen_types.APHRODITE,
|
||||
},
|
||||
'koboldcpp': {
|
||||
selected: 'textgenerationwebui',
|
||||
button: '#api_button_textgenerationwebui',
|
||||
type: textgen_types.KOBOLDCPP,
|
||||
},
|
||||
'kcpp': {
|
||||
selected: 'textgenerationwebui',
|
||||
button: '#api_button_textgenerationwebui',
|
||||
@ -8097,6 +8107,11 @@ const CONNECT_API_MAP = {
|
||||
button: '#api_button_textgenerationwebui',
|
||||
type: textgen_types.TOGETHERAI,
|
||||
},
|
||||
'openai': {
|
||||
selected: 'openai',
|
||||
button: '#api_button_openai',
|
||||
source: chat_completion_sources.OPENAI,
|
||||
},
|
||||
'oai': {
|
||||
selected: 'openai',
|
||||
button: '#api_button_openai',
|
||||
@ -8224,7 +8239,29 @@ async function disableInstructCallback() {
|
||||
* @param {string} text API name
|
||||
*/
|
||||
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()];
|
||||
if (!apiConfig) {
|
||||
@ -8275,8 +8312,13 @@ export async function processDroppedFiles(files, preserveFileNames = false) {
|
||||
'text/x-yaml',
|
||||
];
|
||||
|
||||
const allowedExtensions = [
|
||||
'charx',
|
||||
];
|
||||
|
||||
for (const file of files) {
|
||||
if (allowedMimeTypes.includes(file.type)) {
|
||||
const extension = file.name.split('.').pop().toLowerCase();
|
||||
if (allowedMimeTypes.includes(file.type) || allowedExtensions.includes(extension)) {
|
||||
await importCharacter(file, preserveFileNames);
|
||||
} else {
|
||||
toastr.warning('Unsupported file type: ' + file.name);
|
||||
@ -8297,7 +8339,7 @@ async function importCharacter(file, preserveFileName = false) {
|
||||
}
|
||||
|
||||
const ext = file.name.match(/\.(\w+)$/);
|
||||
if (!ext || !(['json', 'png', 'yaml', 'yml'].includes(ext[1].toLowerCase()))) {
|
||||
if (!ext || !(['json', 'png', 'yaml', 'yml', 'charx'].includes(ext[1].toLowerCase()))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -8670,7 +8712,7 @@ jQuery(async function () {
|
||||
],
|
||||
helpString: `
|
||||
<div>
|
||||
Connect to an API.
|
||||
Connect to an API. If no argument is provided, it will return the currently connected API.
|
||||
</div>
|
||||
<div>
|
||||
<strong>Available APIs:</strong>
|
||||
|
Reference in New Issue
Block a user