Compare commits

...

4 Commits

Author SHA1 Message Date
Cohee 842b463e60 System same as user for Llama 3 2024-04-21 18:28:44 +03:00
Cohee 274359d1ec Move prompt manager actions row to the top 2024-04-21 14:48:21 +03:00
Cohee dac89a87b7 Fix new characters highlight 2024-04-21 14:20:24 +03:00
Cohee fb5d998cd0 Allow all macro in story strings 2024-04-21 14:06:33 +03:00
4 changed files with 20 additions and 7 deletions

View File

@ -18,7 +18,7 @@
"input_suffix": "<|eot_id|>",
"system_suffix": "<|eot_id|>",
"user_alignment_message": "",
"system_same_as_user": false,
"system_same_as_user": true,
"last_system_sequence": "",
"name": "Llama 3 Instruct"
}

View File

@ -6768,8 +6768,9 @@ function select_rm_info(type, charId, previousCharId = null) {
importFlashTimeout = setTimeout(function () {
if (type === 'char_import' || type === 'char_create') {
// Find the page at which the character is located
const avatarFileName = `${charId}.png`;
const charData = getEntitiesList({ doFilter: true });
const charIndex = charData.findIndex((x) => x?.item?.avatar?.startsWith(charId));
const charIndex = charData.findIndex((x) => x?.item?.avatar?.startsWith(avatarFileName));
if (charIndex === -1) {
console.log(`Could not find character ${charId} in the list`);
@ -6779,7 +6780,7 @@ function select_rm_info(type, charId, previousCharId = null) {
try {
const perPage = Number(localStorage.getItem('Characters_PerPage')) || per_page_default;
const page = Math.floor(charIndex / perPage) + 1;
const selector = `#rm_print_characters_block [title^="${charId}"]`;
const selector = `#rm_print_characters_block [title*="${avatarFileName}"]`;
$('#rm_print_characters_pagination').pagination('go', page);
waitUntilCondition(() => document.querySelector(selector) !== null).then(() => {

View File

@ -1398,7 +1398,8 @@ class PromptManager {
`;
const rangeBlockDiv = promptManagerDiv.querySelector('.range-block');
rangeBlockDiv.insertAdjacentHTML('beforeend', footerHtml);
const headerDiv = promptManagerDiv.querySelector('.completion_prompt_manager_header');
headerDiv.insertAdjacentHTML('afterend', footerHtml);
rangeBlockDiv.querySelector('#prompt-manager-reset-character').addEventListener('click', this.handleCharacterReset);
const footerDiv = rangeBlockDiv.querySelector(`.${this.configuration.prefix}prompt_manager_footer`);
@ -1427,7 +1428,12 @@ class PromptManager {
rangeBlockDiv.insertAdjacentHTML('beforeend', exportPopup);
let exportPopper = Popper.createPopper(
// Destroy previous popper instance if it exists
if (this.exportPopper) {
this.exportPopper.destroy();
}
this.exportPopper = Popper.createPopper(
document.getElementById('prompt-manager-export'),
document.getElementById('prompt-manager-export-format-popup'),
{ placement: 'bottom' },
@ -1440,7 +1446,7 @@ class PromptManager {
if (show) popup.removeAttribute('data-show');
else popup.setAttribute('data-show', '');
exportPopper.update();
this.exportPopper.update();
};
footerDiv.querySelector('#prompt-manager-import').addEventListener('click', this.handleImport);

View File

@ -1,4 +1,4 @@
import { chat, chat_metadata, main_api, getMaxContextSize, getCurrentChatId } from '../script.js';
import { chat, chat_metadata, main_api, getMaxContextSize, getCurrentChatId, substituteParams } from '../script.js';
import { timestampToMoment, isDigitsOnly, getStringHash } from './utils.js';
import { textgenerationwebui_banned_in_macros } from './textgen-settings.js';
import { replaceInstructMacros } from './instruct-mode.js';
@ -6,6 +6,12 @@ import { replaceVariableMacros } from './variables.js';
// Register any macro that you want to leave in the compiled story string
Handlebars.registerHelper('trim', () => '{{trim}}');
// Catch-all helper for any macro that is not defined for story strings
Handlebars.registerHelper('helperMissing', function () {
const options = arguments[arguments.length - 1];
const macroName = options.name;
return substituteParams(`{{${macroName}}}`);
});
/**
* Gets a hashed id of the current chat from the metadata.