Merge pull request #3103 from Finadil/staging
Add author's note STscript returns, role changing, and aliases
This commit is contained in:
commit
3af5302714
|
@ -37,12 +37,15 @@ const chara_note_position = {
|
||||||
};
|
};
|
||||||
|
|
||||||
function setNoteTextCommand(_, text) {
|
function setNoteTextCommand(_, text) {
|
||||||
|
if (text) {
|
||||||
$('#extension_floating_prompt').val(text).trigger('input');
|
$('#extension_floating_prompt').val(text).trigger('input');
|
||||||
toastr.success(t`Author's Note text updated`);
|
toastr.success(t`Author's Note text updated`);
|
||||||
return '';
|
}
|
||||||
|
return chat_metadata[metadata_keys.prompt];
|
||||||
}
|
}
|
||||||
|
|
||||||
function setNoteDepthCommand(_, text) {
|
function setNoteDepthCommand(_, text) {
|
||||||
|
if (text) {
|
||||||
const value = Number(text);
|
const value = Number(text);
|
||||||
|
|
||||||
if (Number.isNaN(value)) {
|
if (Number.isNaN(value)) {
|
||||||
|
@ -52,10 +55,12 @@ function setNoteDepthCommand(_, text) {
|
||||||
|
|
||||||
$('#extension_floating_depth').val(Math.abs(value)).trigger('input');
|
$('#extension_floating_depth').val(Math.abs(value)).trigger('input');
|
||||||
toastr.success(t`Author's Note depth updated`);
|
toastr.success(t`Author's Note depth updated`);
|
||||||
return '';
|
}
|
||||||
|
return chat_metadata[metadata_keys.depth];
|
||||||
}
|
}
|
||||||
|
|
||||||
function setNoteIntervalCommand(_, text) {
|
function setNoteIntervalCommand(_, text) {
|
||||||
|
if (text) {
|
||||||
const value = Number(text);
|
const value = Number(text);
|
||||||
|
|
||||||
if (Number.isNaN(value)) {
|
if (Number.isNaN(value)) {
|
||||||
|
@ -65,25 +70,49 @@ function setNoteIntervalCommand(_, text) {
|
||||||
|
|
||||||
$('#extension_floating_interval').val(Math.abs(value)).trigger('input');
|
$('#extension_floating_interval').val(Math.abs(value)).trigger('input');
|
||||||
toastr.success(t`Author's Note frequency updated`);
|
toastr.success(t`Author's Note frequency updated`);
|
||||||
return '';
|
}
|
||||||
|
return chat_metadata[metadata_keys.interval];
|
||||||
}
|
}
|
||||||
|
|
||||||
function setNotePositionCommand(_, text) {
|
function setNotePositionCommand(_, text) {
|
||||||
const validPositions = {
|
const validPositions = {
|
||||||
'scenario': 0,
|
'scenario': 0,
|
||||||
'chat': 1,
|
'chat': 1,
|
||||||
|
'before_scenario': 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (text) {
|
||||||
const position = validPositions[text?.trim()];
|
const position = validPositions[text?.trim()];
|
||||||
|
|
||||||
if (Number.isNaN(position)) {
|
if (typeof position == 'undefined') {
|
||||||
toastr.error(t`Not a valid position`);
|
toastr.error(t`Not a valid position`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$(`input[name="extension_floating_position"][value="${position}"]`).prop('checked', true).trigger('input');
|
$(`input[name="extension_floating_position"][value="${position}"]`).prop('checked', true).trigger('input');
|
||||||
toastr.info(t`Author's Note position updated`);
|
toastr.info(t`Author's Note position updated`);
|
||||||
return '';
|
}
|
||||||
|
return Object.keys(validPositions).find(key => validPositions[key] == chat_metadata[metadata_keys.position]);
|
||||||
|
}
|
||||||
|
function setNoteRoleCommand(_, text) {
|
||||||
|
const validRoles = {
|
||||||
|
'system': 0,
|
||||||
|
'user': 1,
|
||||||
|
'assistant': 2
|
||||||
|
};
|
||||||
|
|
||||||
|
if (text) {
|
||||||
|
const role = validRoles[text?.trim()];
|
||||||
|
|
||||||
|
if (typeof role == 'undefined') {
|
||||||
|
toastr.error(t`Not a valid role`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$(`#extension_floating_role`).val(Math.abs(role)).trigger('input');
|
||||||
|
toastr.info(t`Author's Note role updated`);
|
||||||
|
}
|
||||||
|
return Object.keys(validRoles).find(key => validRoles[key] == chat_metadata[metadata_keys.role]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateSettings() {
|
function updateSettings() {
|
||||||
|
@ -464,55 +493,77 @@ export function initAuthorsNote() {
|
||||||
|
|
||||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'note',
|
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'note',
|
||||||
callback: setNoteTextCommand,
|
callback: setNoteTextCommand,
|
||||||
|
returns: 'current author\'s note',
|
||||||
unnamedArgumentList: [
|
unnamedArgumentList: [
|
||||||
new SlashCommandArgument(
|
new SlashCommandArgument(
|
||||||
'text', [ARGUMENT_TYPE.STRING], true,
|
'text', [ARGUMENT_TYPE.STRING], false,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
helpString: `
|
helpString: `
|
||||||
<div>
|
<div>
|
||||||
Sets an author's note for the currently selected chat.
|
Sets an author's note for the currently selected chat if specified and returns the current note.
|
||||||
</div>
|
</div>
|
||||||
`,
|
`,
|
||||||
}));
|
}));
|
||||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'depth',
|
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'depth',
|
||||||
|
aliases: ['note-depth'],
|
||||||
callback: setNoteDepthCommand,
|
callback: setNoteDepthCommand,
|
||||||
|
returns: 'current author\'s note depth',
|
||||||
unnamedArgumentList: [
|
unnamedArgumentList: [
|
||||||
new SlashCommandArgument(
|
new SlashCommandArgument(
|
||||||
'number', [ARGUMENT_TYPE.NUMBER], true,
|
'number', [ARGUMENT_TYPE.NUMBER], false,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
helpString: `
|
helpString: `
|
||||||
<div>
|
<div>
|
||||||
Sets an author's note depth for in-chat positioning.
|
Sets an author's note depth for in-chat positioning if specified and returns the current depth.
|
||||||
</div>
|
</div>
|
||||||
`,
|
`,
|
||||||
}));
|
}));
|
||||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'freq',
|
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'freq',
|
||||||
|
aliases: ['note-freq'],
|
||||||
callback: setNoteIntervalCommand,
|
callback: setNoteIntervalCommand,
|
||||||
|
returns: 'current author\'s note insertion frequency',
|
||||||
namedArgumentList: [],
|
namedArgumentList: [],
|
||||||
unnamedArgumentList: [
|
unnamedArgumentList: [
|
||||||
new SlashCommandArgument(
|
new SlashCommandArgument(
|
||||||
'number', [ARGUMENT_TYPE.NUMBER], true,
|
'number', [ARGUMENT_TYPE.NUMBER], false,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
helpString: `
|
helpString: `
|
||||||
<div>
|
<div>
|
||||||
Sets an author's note insertion frequency.
|
Sets an author's note insertion frequency if specified and returns the current frequency.
|
||||||
</div>
|
</div>
|
||||||
`,
|
`,
|
||||||
}));
|
}));
|
||||||
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'pos',
|
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'pos',
|
||||||
callback: setNotePositionCommand,
|
callback: setNotePositionCommand,
|
||||||
|
aliases: ['note-pos'],
|
||||||
|
returns: 'current author\'s note insertion position',
|
||||||
namedArgumentList: [],
|
namedArgumentList: [],
|
||||||
unnamedArgumentList: [
|
unnamedArgumentList: [
|
||||||
new SlashCommandArgument(
|
new SlashCommandArgument(
|
||||||
'position', [ARGUMENT_TYPE.STRING], true, false, null, ['chat', 'scenario'],
|
'position', [ARGUMENT_TYPE.STRING], false, false, null, ['chat', 'scenario','before_scenario'],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
helpString: `
|
helpString: `
|
||||||
<div>
|
<div>
|
||||||
Sets an author's note position.
|
Sets an author's note position if specified and returns the current position.
|
||||||
|
</div>
|
||||||
|
`,
|
||||||
|
}));
|
||||||
|
SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'note-role',
|
||||||
|
callback: setNoteRoleCommand,
|
||||||
|
returns: 'current author\'s note chat insertion role',
|
||||||
|
namedArgumentList: [],
|
||||||
|
unnamedArgumentList: [
|
||||||
|
new SlashCommandArgument(
|
||||||
|
'position', [ARGUMENT_TYPE.STRING], false, false, null, ['system', 'user','assistant'],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
helpString: `
|
||||||
|
<div>
|
||||||
|
Sets an author's note chat insertion role if specified and returns the current role.
|
||||||
</div>
|
</div>
|
||||||
`,
|
`,
|
||||||
}));
|
}));
|
||||||
|
|
Loading…
Reference in New Issue