WIP textgen API custom sampler display

This commit is contained in:
RossAscends
2024-05-19 15:06:29 +09:00
parent 4e9a113a35
commit c7232ae23c
4 changed files with 492 additions and 31 deletions

View File

@ -231,6 +231,7 @@ import { SlashCommandParser } from './scripts/slash-commands/SlashCommandParser.
import { SlashCommand } from './scripts/slash-commands/SlashCommand.js';
import { ARGUMENT_TYPE, SlashCommandArgument } from './scripts/slash-commands/SlashCommandArgument.js';
import { SlashCommandBrowser } from './scripts/slash-commands/SlashCommandBrowser.js';
import { initCustomSelectedSamplers, validateDisabledSamplers } from './scripts/samplerSelect.js';
//exporting functions and vars for mods
export {
@ -2718,7 +2719,7 @@ class StreamingProcessor {
let messageId = -1;
if (this.type == 'impersonate') {
$('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles:true }));
$('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles: true }));
}
else {
await saveReply(this.type, text, true);
@ -2754,7 +2755,7 @@ class StreamingProcessor {
}
if (isImpersonate) {
$('#send_textarea').val(processedText)[0].dispatchEvent(new Event('input', { bubbles:true }));
$('#send_textarea').val(processedText)[0].dispatchEvent(new Event('input', { bubbles: true }));
}
else {
let currentTime = new Date();
@ -3133,7 +3134,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
if (!pingResult) {
unblockGeneration(type);
toastr.error('Verify that the server is running and accessible.', 'ST Server cannot be reached' );
toastr.error('Verify that the server is running and accessible.', 'ST Server cannot be reached');
throw new Error('Server unreachable');
}
@ -3196,7 +3197,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
if (type !== 'regenerate' && type !== 'swipe' && type !== 'quiet' && !isImpersonate && !dryRun) {
is_send_press = true;
textareaText = String($('#send_textarea').val());
$('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles:true }));
$('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles: true }));
} else {
textareaText = '';
if (chat.length && chat[chat.length - 1]['is_user']) {
@ -4158,7 +4159,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
if (getMessage.length > 0) {
if (isImpersonate) {
$('#send_textarea').val(getMessage)[0].dispatchEvent(new Event('input', { bubbles:true }));
$('#send_textarea').val(getMessage)[0].dispatchEvent(new Event('input', { bubbles: true }));
generatedPromptCache = '';
await eventSource.emit(event_types.IMPERSONATE_READY, getMessage);
}
@ -5933,7 +5934,7 @@ export function changeMainAPI() {
getStatusHorde();
getHordeModels(true);
}
validateDisabledSamplers()
setupChatCompletionPromptManager(oai_settings);
forceCharacterEditorTokenize();
}
@ -6087,6 +6088,7 @@ export async function getSettings() {
// TextGen
loadTextGenSettings(data, settings);
// OpenAI
loadOpenAISettings(data, settings.oai_settings ?? settings);
@ -6132,6 +6134,7 @@ export async function getSettings() {
);
changeMainAPI();
//Load User's Name and Avatar
initUserAvatar(settings.user_avatar);
setPersonaDescription();
@ -6162,7 +6165,7 @@ export async function getSettings() {
firstRun = false;
}
}
await validateDisabledSamplers()
settingsReady = true;
eventSource.emit(event_types.SETTINGS_LOADED);
}
@ -8564,11 +8567,13 @@ jQuery(async function () {
toastr.success('Chat and settings saved.');
}
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'dupe',
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'dupe',
callback: DupeChar,
helpString: 'Duplicates the currently selected character.',
}));
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'api',
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'api',
callback: connectAPISlash,
namedArgumentList: [],
unnamedArgumentList: [
@ -8591,7 +8596,8 @@ jQuery(async function () {
</div>
`,
}));
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'impersonate',
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'impersonate',
callback: doImpersonate,
aliases: ['imp'],
unnamedArgumentList: [
@ -8613,7 +8619,8 @@ jQuery(async function () {
</div>
`,
}));
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'delchat',
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'delchat',
callback: doDeleteChat,
helpString: 'Deletes the current chat.',
}));
@ -8627,25 +8634,30 @@ jQuery(async function () {
],
helpString: 'Renames the current chat.',
}));
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'getchatname',
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'getchatname',
callback: doGetChatName,
returns: 'chat file name',
helpString: 'Returns the name of the current chat file into the pipe.',
}));
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'closechat',
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'closechat',
callback: doCloseChat,
helpString: 'Closes the current chat.',
}));
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'panels',
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'panels',
callback: doTogglePanels,
aliases: ['togglepanels'],
helpString: 'Toggle UI panels on/off',
}));
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'forcesave',
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'forcesave',
callback: doForceSave,
helpString: 'Forces a save of the current chat and settings',
}));
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'instruct',
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'instruct',
callback: selectInstructCallback,
returns: 'current preset',
namedArgumentList: [],
@ -8668,15 +8680,18 @@ jQuery(async function () {
</div>
`,
}));
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'instruct-on',
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'instruct-on',
callback: enableInstructCallback,
helpString: 'Enables instruct mode.',
}));
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'instruct-off',
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'instruct-off',
callback: disableInstructCallback,
helpString: 'Disables instruct mode',
}));
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'context',
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'context',
callback: selectContextCallback,
returns: 'template name',
unnamedArgumentList: [
@ -8686,7 +8701,8 @@ jQuery(async function () {
],
helpString: 'Selects context template by name. Gets the current template if no name is provided',
}));
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'chat-manager',
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'chat-manager',
callback: () => $('#option_select_chat').trigger('click'),
aliases: ['chat-history', 'manage-chats'],
helpString: 'Opens the chat manager for the current character/group.',
@ -10338,7 +10354,7 @@ jQuery(async function () {
$('#character_replace_file').off('change').on('change', uploadReplacementCard).trigger('click');
}
} break;
case 'import_tags':{
case 'import_tags': {
await importTags(characters[this_chid]);
} break;
/*case 'delete_button':
@ -10546,4 +10562,6 @@ jQuery(async function () {
eventSource.on(event_types.GROUP_CHAT_DELETED, async (name) => {
await deleteItemizedPrompts(name);
});
initCustomSelectedSamplers();
});