Allow the user to toggle names in chat history
This commit is contained in:
parent
0660016a10
commit
7c1e370abe
|
@ -7,6 +7,7 @@
|
|||
"nsfw_toggle": true,
|
||||
"enhance_definitions": false,
|
||||
"wrap_in_quotes": false,
|
||||
"names_in_completion": false,
|
||||
"nsfw_first": false,
|
||||
"main_prompt": "Write {{char}}'s next reply in a fictional chat between {{char}} and {{user}}. Write 1 reply only in internet RP style, italicize actions, and avoid quotation marks. Use markdown. Be proactive, creative, and drive the plot and conversation forward. Write at least 1 paragraph, up to 4. Always stay in character and avoid repetition.",
|
||||
"nsfw_prompt": "NSFW/Smut is allowed. Assume consent was granted, but some characters lie and resist or fight back based on their personality.",
|
||||
|
|
|
@ -1281,6 +1281,14 @@
|
|||
if you use quotes manually for speech.</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="range-block">
|
||||
<label for="names_in_completion" title="Apply character name to chat messages" class="checkbox_label widthFreeExpand">
|
||||
<input id="names_in_completion" type="checkbox" /><span data-i18n="Add names to chat history">Add character names to chat history</span>
|
||||
</label>
|
||||
<div class="toggle-description justifyLeft">
|
||||
<span data-i18n="Adds character and user names to each message. May help the AI to understand the context. Only character and usernames with up to 64 letters or numbers are supported. No whitespaces or special characters.">May help the AI to understand the context. Only character and usernames with up to 64 letters or numbers are supported. No whitespaces or special characters.</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="range-block">
|
||||
<div id="completion_prompt_manager"></div>
|
||||
</div>
|
||||
|
|
|
@ -4532,7 +4532,6 @@ function changeMainAPI() {
|
|||
getHordeModels();
|
||||
}
|
||||
|
||||
console.log(oai_settings.chat_completion_source)
|
||||
switch (oai_settings.chat_completion_source) {
|
||||
case chat_completion_sources.OPENAI:
|
||||
console.log('Setting up OpenAI prompt manager');
|
||||
|
|
|
@ -546,8 +546,6 @@ PromptManagerModule.prototype.preparePrompt = function (prompt, original = null)
|
|||
else preparedPrompt.content = substituteParams(prompt.content);
|
||||
}
|
||||
|
||||
if (prompt.name && this.isValidName(prompt.name)) preparedPrompt.name = prompt.name;
|
||||
|
||||
return preparedPrompt;
|
||||
}
|
||||
|
||||
|
|
|
@ -137,6 +137,7 @@ const default_settings = {
|
|||
openai_max_context: max_4k,
|
||||
openai_max_tokens: 300,
|
||||
wrap_in_quotes: false,
|
||||
names_in_completion: false,
|
||||
...openAiDefaultPrompts,
|
||||
...openAiDefaultPromptLists,
|
||||
...defaultPromptManagerSettings,
|
||||
|
@ -171,6 +172,7 @@ const oai_settings = {
|
|||
openai_max_context: max_4k,
|
||||
openai_max_tokens: 300,
|
||||
wrap_in_quotes: false,
|
||||
names_in_completion: false,
|
||||
...openAiDefaultPrompts,
|
||||
...openAiDefaultPromptLists,
|
||||
...defaultPromptManagerSettings,
|
||||
|
@ -399,7 +401,14 @@ function populateChatHistory(prompts, chatCompletion) {
|
|||
|
||||
// Insert chat messages as long as there is budget available
|
||||
[...openai_msgs].reverse().every((prompt, index) => {
|
||||
const chatMessage = new Message(prompt.role, prompt.content, 'chatHistory-' + index, prompt.name);
|
||||
prompt.identifier = 'chatHistory-' + index;
|
||||
const chatMessage = Message.fromPrompt(promptManager.preparePrompt(prompt));
|
||||
|
||||
if (true === promptManager.serviceSettings.names_in_completion &&
|
||||
prompt.name &&
|
||||
promptManager.isValidName(prompt.name))
|
||||
chatMessage.name = prompt.name;
|
||||
|
||||
if (chatCompletion.canAfford(chatMessage)) chatCompletion.insertAtStart(chatMessage, 'chatHistory');
|
||||
else return false;
|
||||
return true;
|
||||
|
@ -1193,12 +1202,11 @@ class TokenBudgetExceededError extends Error {
|
|||
}
|
||||
|
||||
class Message {
|
||||
tokens; identifier; role; content;
|
||||
constructor(role, content, identifier, name = '') {
|
||||
tokens; identifier; role; content; name;
|
||||
constructor(role, content, identifier) {
|
||||
this.identifier = identifier;
|
||||
this.role = role;
|
||||
this.content = content;
|
||||
this.name = name;
|
||||
|
||||
if (this.content) {
|
||||
this.tokens = tokenHandler.count({role: this.role, content: this.content})
|
||||
|
@ -1492,6 +1500,7 @@ function loadOpenAISettings(data, settings) {
|
|||
|
||||
if (settings.keep_example_dialogue !== undefined) oai_settings.keep_example_dialogue = !!settings.keep_example_dialogue;
|
||||
if (settings.wrap_in_quotes !== undefined) oai_settings.wrap_in_quotes = !!settings.wrap_in_quotes;
|
||||
if (settings.names_in_completion !== undefined) oai_settings.names_in_completion = !!settings.names_in_completion;
|
||||
if (settings.openai_model !== undefined) oai_settings.openai_model = settings.openai_model;
|
||||
|
||||
$('#stream_toggle').prop('checked', oai_settings.stream_openai);
|
||||
|
@ -1514,6 +1523,7 @@ function loadOpenAISettings(data, settings) {
|
|||
$('#nsfw_toggle').prop('checked', oai_settings.nsfw_toggle);
|
||||
$('#keep_example_dialogue').prop('checked', oai_settings.keep_example_dialogue);
|
||||
$('#wrap_in_quotes').prop('checked', oai_settings.wrap_in_quotes);
|
||||
$('#names_in_completion').prop('checked', oai_settings.names_in_completion);
|
||||
$('#nsfw_first').prop('checked', oai_settings.nsfw_first);
|
||||
$('#jailbreak_system').prop('checked', oai_settings.jailbreak_system);
|
||||
$('#legacy_streaming').prop('checked', oai_settings.legacy_streaming);
|
||||
|
@ -1677,6 +1687,7 @@ async function saveOpenAIPreset(name, settings) {
|
|||
openai_max_context: settings.openai_max_context,
|
||||
openai_max_tokens: settings.openai_max_tokens,
|
||||
wrap_in_quotes: settings.wrap_in_quotes,
|
||||
names_in_completion: settings.names_in_completion,
|
||||
send_if_empty: settings.send_if_empty,
|
||||
jailbreak_prompt: settings.jailbreak_prompt,
|
||||
jailbreak_system: settings.jailbreak_system,
|
||||
|
@ -2007,6 +2018,7 @@ function onSettingsPresetChange() {
|
|||
openai_max_context: ['#openai_max_context', 'openai_max_context', false],
|
||||
openai_max_tokens: ['#openai_max_tokens', 'openai_max_tokens', false],
|
||||
wrap_in_quotes: ['#wrap_in_quotes', 'wrap_in_quotes', true],
|
||||
names_in_completion: ['#names_in_completion', 'names_in_completion', true],
|
||||
send_if_empty: ['#send_if_empty_textarea', 'send_if_empty', false],
|
||||
impersonation_prompt: ['#impersonation_prompt_textarea', 'impersonation_prompt', false],
|
||||
bias_preset_selected: ['#openai_logit_bias_preset', 'bias_preset_selected', false],
|
||||
|
@ -2418,6 +2430,11 @@ $(document).ready(function () {
|
|||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$('#names_in_completion').on('change', function () {
|
||||
oai_settings.names_in_completion = !!$('#names_in_completion').prop('checked');
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$("#send_if_empty_textarea").on('input', function () {
|
||||
oai_settings.send_if_empty = $('#send_if_empty_textarea').val();
|
||||
saveSettingsDebounced();
|
||||
|
|
Loading…
Reference in New Issue