mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Add instruct presets
This commit is contained in:
@ -1180,7 +1180,7 @@
|
||||
Custom Chat Separator
|
||||
</h4>
|
||||
<div>
|
||||
<input id="custom_chat_separator" class="text_pole" type="text" placeholder="<START>" maxlength="100" />
|
||||
<input id="custom_chat_separator" class="text_pole textarea_compact" type="text" placeholder="<START>" maxlength="100" />
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
@ -1189,6 +1189,7 @@
|
||||
<span class="note-link-span">?</span>
|
||||
</a>
|
||||
</h4>
|
||||
<div>
|
||||
<label for="instruct_enabled" class="checkbox_label">
|
||||
<input id="instruct_enabled" type="checkbox" />
|
||||
Enabled
|
||||
@ -1201,10 +1202,9 @@
|
||||
<input id="instruct_names" type="checkbox" />
|
||||
Include Names
|
||||
</label>
|
||||
</div>
|
||||
<label for="instruct_presets">Presets</label>
|
||||
<select id="instruct_presets">
|
||||
<option>--- UNDER CONSTRUCTION ---</option>
|
||||
</select>
|
||||
<select id="instruct_presets"></select>
|
||||
<label>
|
||||
System Prompt
|
||||
</label>
|
||||
@ -1269,7 +1269,7 @@
|
||||
<span class="note-link-span">?</span>
|
||||
</a>
|
||||
</div>
|
||||
<input id="token_padding" class="text_pole" type="number" min="-2048" max="2048" />
|
||||
<input id="token_padding" class="text_pole textarea_compact" type="number" min="-2048" max="2048" />
|
||||
</div>
|
||||
<label class="checkbox_label" for="always-force-name2-checkbox">
|
||||
<input id="always-force-name2-checkbox" type="checkbox" />
|
||||
@ -1306,11 +1306,11 @@
|
||||
<div class="multigen_settings_block">
|
||||
<label for="multigen_1st_chunk">
|
||||
<small>First chunk (tokens)</small>
|
||||
<input id="multigen_first_chunk" type="number" class="text_pole" min="1" max="512" />
|
||||
<input id="multigen_first_chunk" type="number" class="text_pole textarea_compact" min="1" max="512" />
|
||||
</label>
|
||||
<label for="multigen_next_chunk">
|
||||
<small>Next chunks (tokens)</small>
|
||||
<input id="multigen_next_chunks" type="number" class="text_pole" min="1" max="512" />
|
||||
<input id="multigen_next_chunks" type="number" class="text_pole textarea_compact" min="1" max="512" />
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
9
public/instruct/Alpaca.json
Normal file
9
public/instruct/Alpaca.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "Alpaca",
|
||||
"system_prompt": "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\nWrite {{char}}'s next reply in a fictional roleplay chat between {{user}} and {{char}}.",
|
||||
"system_sequence": "",
|
||||
"stop_sequence": "",
|
||||
"input_sequence": "### Instruction:",
|
||||
"output_sequence": "### Response:",
|
||||
"wrap": true
|
||||
}
|
9
public/instruct/Koala.json
Normal file
9
public/instruct/Koala.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "Koala",
|
||||
"system_prompt": "Write {{char}}'s next reply in a fictional roleplay chat between {{user}} and {{char}}.",
|
||||
"system_sequence": "BEGINNING OF CONVERSATION:",
|
||||
"stop_sequence": "",
|
||||
"input_sequence": "USER: ",
|
||||
"output_sequence": "GPT: ",
|
||||
"wrap": true
|
||||
}
|
9
public/instruct/Metharme.json
Normal file
9
public/instruct/Metharme.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "Metharme",
|
||||
"system_prompt": "Write {{char}}'s next reply in a fictional roleplay chat between {{user}} and {{char}}.",
|
||||
"system_sequence": "<|system|>",
|
||||
"stop_sequence": "</s>",
|
||||
"input_sequence": "<|user|>",
|
||||
"output_sequence": "<|model|>",
|
||||
"wrap": false
|
||||
}
|
9
public/instruct/WizardLM.json
Normal file
9
public/instruct/WizardLM.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "WizardLM",
|
||||
"system_prompt": "Write {{char}}'s next reply in a fictional roleplay chat between {{user}} and {{char}}.",
|
||||
"system_sequence": "",
|
||||
"stop_sequence": "",
|
||||
"input_sequence": "### Instruction:",
|
||||
"output_sequence": "### Response:",
|
||||
"wrap": true
|
||||
}
|
@ -121,10 +121,12 @@ let power_user = {
|
||||
stop_sequence: '',
|
||||
input_sequence: '### Instruction:',
|
||||
output_sequence: '### Response:',
|
||||
preset: 'Alpaca',
|
||||
}
|
||||
};
|
||||
|
||||
let themes = [];
|
||||
let instruct_presets = [];
|
||||
|
||||
const storage_keys = {
|
||||
fast_ui_mode: "TavernAI_fast_ui_mode",
|
||||
@ -447,6 +449,10 @@ function loadPowerUserSettings(settings, data) {
|
||||
themes = data.themes;
|
||||
}
|
||||
|
||||
if (data.instruct !== undefined) {
|
||||
instruct_presets = data.instruct;
|
||||
}
|
||||
|
||||
// These are still local storage
|
||||
const fastUi = localStorage.getItem(storage_keys.fast_ui_mode);
|
||||
const waifuMode = localStorage.getItem(storage_keys.waifuMode);
|
||||
@ -556,6 +562,38 @@ function loadInstructMode() {
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
});
|
||||
|
||||
instruct_presets.forEach((preset) => {
|
||||
const name = preset.name;
|
||||
const option = document.createElement('option');
|
||||
option.value = name;
|
||||
option.innerText = name;
|
||||
option.selected = name === power_user.instruct.preset;
|
||||
$('#instruct_presets').append(option);
|
||||
});
|
||||
|
||||
$('#instruct_presets').on('change', function () {
|
||||
const name = $(this).find(':selected').val();
|
||||
const preset = instruct_presets.find(x => x.name === name);
|
||||
|
||||
if (!preset) {
|
||||
return;
|
||||
}
|
||||
|
||||
power_user.instruct.preset = name;
|
||||
controls.forEach(control => {
|
||||
if (preset[control.property] !== undefined) {
|
||||
power_user.instruct[control.property] = preset[control.property];
|
||||
const $element = $(`#${control.id}`);
|
||||
|
||||
if (control.isCheckbox) {
|
||||
$element.prop('checked', power_user.instruct[control.property]).trigger('input');
|
||||
} else {
|
||||
$element.val(power_user.instruct[control.property]).trigger('input');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function formatInstructModeChat(name, mes, isUser) {
|
||||
|
29
server.js
29
server.js
@ -185,7 +185,8 @@ const directories = {
|
||||
thumbnailsBg: 'thumbnails/bg/',
|
||||
thumbnailsAvatar: 'thumbnails/avatar/',
|
||||
themes: 'public/themes',
|
||||
extensions: 'public/scripts/extensions'
|
||||
extensions: 'public/scripts/extensions',
|
||||
instruct: 'public/instruct',
|
||||
};
|
||||
|
||||
// CSRF Protection //
|
||||
@ -1143,6 +1144,7 @@ app.post('/getsettings', jsonParser, (request, response) => { //Wintermute's cod
|
||||
const textgenerationwebui_presets = [];
|
||||
const textgenerationwebui_preset_names = [];
|
||||
const themes = [];
|
||||
const instruct = [];
|
||||
const settings = fs.readFileSync('public/settings.json', 'utf8', (err, data) => {
|
||||
if (err) return response.sendStatus(500);
|
||||
|
||||
@ -1269,6 +1271,30 @@ app.post('/getsettings', jsonParser, (request, response) => { //Wintermute's cod
|
||||
}
|
||||
})
|
||||
|
||||
// Instruct files
|
||||
const instructFiles = fs
|
||||
.readdirSync(directories.instruct)
|
||||
.filter(x => path.parse(x).ext == '.json')
|
||||
.sort();
|
||||
|
||||
instructFiles.forEach(item => {
|
||||
const file = fs.readFileSync(
|
||||
path.join(directories.instruct, item),
|
||||
'utf-8',
|
||||
(err, data) => {
|
||||
if (err) return response.sendStatus(500);
|
||||
return data;
|
||||
}
|
||||
);
|
||||
|
||||
try {
|
||||
instruct.push(json5.parse(file));
|
||||
}
|
||||
catch {
|
||||
// skip
|
||||
}
|
||||
});
|
||||
|
||||
response.send({
|
||||
settings,
|
||||
koboldai_settings,
|
||||
@ -1281,6 +1307,7 @@ app.post('/getsettings', jsonParser, (request, response) => { //Wintermute's cod
|
||||
textgenerationwebui_presets,
|
||||
textgenerationwebui_preset_names,
|
||||
themes,
|
||||
instruct,
|
||||
enable_extensions: enableExtensions,
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user