From b377a2b7d34a052307de8f253f258bdc2d28acad Mon Sep 17 00:00:00 2001 From: Cohee <18619528+Cohee1207@users.noreply.github.com> Date: Tue, 17 Sep 2024 10:37:36 +0000 Subject: [PATCH] Decouple system prompts from instruct mode --- default/content/index.json | 52 ++++- .../presets/context/Alpaca-Roleplay.json | 12 - .../content/presets/context/Libra-32B.json | 4 +- .../content/presets/instruct/Adventure.json | 1 - .../presets/instruct/Alpaca-Roleplay.json | 23 -- .../presets/instruct/Alpaca-Single-Turn.json | 3 +- default/content/presets/instruct/Alpaca.json | 1 - .../presets/instruct/ChatML-Names.json | 1 - default/content/presets/instruct/ChatML.json | 1 - .../content/presets/instruct/Command R.json | 1 - .../DreamGen Role-Play V1 ChatML.json | 1 - .../DreamGen Role-Play V1 Llama3.json | 1 - default/content/presets/instruct/Gemma 2.json | 1 - default/content/presets/instruct/Koala.json | 1 - .../content/presets/instruct/Libra-32B.json | 1 - .../presets/instruct/Lightning 1.1.json | 1 - .../presets/instruct/Llama 2 Chat.json | 1 - .../presets/instruct/Llama 3 Instruct.json | 1 - .../instruct/Llama-3-Instruct-Names.json | 1 - .../content/presets/instruct/Metharme.json | 1 - default/content/presets/instruct/Mistral.json | 1 - .../presets/instruct/OpenOrca-OpenChat.json | 1 - default/content/presets/instruct/Phi.json | 1 - .../content/presets/instruct/Pygmalion.json | 1 - default/content/presets/instruct/Story.json | 1 - default/content/presets/instruct/Synthia.json | 1 - .../content/presets/instruct/Vicuna 1.0.json | 1 - .../content/presets/instruct/Vicuna 1.1.json | 1 - .../presets/instruct/WizardLM-13B.json | 1 - .../content/presets/instruct/WizardLM.json | 1 - .../instruct/simple-proxy-for-tavern.json | 1 - default/content/presets/sysprompt/Actor.json | 4 + .../presets/sysprompt/Assistant - Expert.json | 4 + .../presets/sysprompt/Assistant - Simple.json | 4 + default/content/presets/sysprompt/Blank.json | 4 + .../presets/sysprompt/Chain of Thought.json | 4 + .../sysprompt/Roleplay - Detailed.json | 4 + .../sysprompt/Roleplay - Immersive.json | 4 + .../presets/sysprompt/Roleplay - Simple.json | 4 + .../presets/sysprompt/Text Adventure.json | 4 + .../presets/sysprompt/Writer - Creative.json | 4 + .../presets/sysprompt/Writer - Realistic.json | 4 + default/content/settings.json | 6 +- public/index.html | 207 ++++++++++-------- public/script.js | 8 +- public/scripts/instruct-mode.js | 30 ++- public/scripts/power-user.js | 9 +- public/scripts/preset-manager.js | 12 +- public/scripts/sysprompt.js | 66 ++++++ public/scripts/templates/macros.html | 4 +- src/constants.js | 1 + 51 files changed, 324 insertions(+), 183 deletions(-) delete mode 100644 default/content/presets/context/Alpaca-Roleplay.json delete mode 100644 default/content/presets/instruct/Alpaca-Roleplay.json create mode 100644 default/content/presets/sysprompt/Actor.json create mode 100644 default/content/presets/sysprompt/Assistant - Expert.json create mode 100644 default/content/presets/sysprompt/Assistant - Simple.json create mode 100644 default/content/presets/sysprompt/Blank.json create mode 100644 default/content/presets/sysprompt/Chain of Thought.json create mode 100644 default/content/presets/sysprompt/Roleplay - Detailed.json create mode 100644 default/content/presets/sysprompt/Roleplay - Immersive.json create mode 100644 default/content/presets/sysprompt/Roleplay - Simple.json create mode 100644 default/content/presets/sysprompt/Text Adventure.json create mode 100644 default/content/presets/sysprompt/Writer - Creative.json create mode 100644 default/content/presets/sysprompt/Writer - Realistic.json create mode 100644 public/scripts/sysprompt.js diff --git a/default/content/index.json b/default/content/index.json index de5316875..5905be0e0 100644 --- a/default/content/index.json +++ b/default/content/index.json @@ -467,10 +467,6 @@ "filename": "presets/context/Adventure.json", "type": "context" }, - { - "filename": "presets/context/Alpaca-Roleplay.json", - "type": "context" - }, { "filename": "presets/context/Alpaca-Single-Turn.json", "type": "context" @@ -555,10 +551,6 @@ "filename": "presets/instruct/Adventure.json", "type": "instruct" }, - { - "filename": "presets/instruct/Alpaca-Roleplay.json", - "type": "instruct" - }, { "filename": "presets/instruct/Alpaca-Single-Turn.json", "type": "instruct" @@ -686,5 +678,49 @@ { "filename": "presets/instruct/Gemma 2.json", "type": "instruct" + }, + { + "filename": "presets/sysprompt/Actor.json", + "type": "sysprompt" + }, + { + "filename": "presets/sysprompt/Assistant - Expert.json", + "type": "sysprompt" + }, + { + "filename": "presets/sysprompt/Assistant - Simple.json", + "type": "sysprompt" + }, + { + "filename": "presets/sysprompt/Chain of Thought.json", + "type": "sysprompt" + }, + { + "filename": "presets/sysprompt/Roleplay - Detailed.json", + "type": "sysprompt" + }, + { + "filename": "presets/sysprompt/Roleplay - Immersive.json", + "type": "sysprompt" + }, + { + "filename": "presets/sysprompt/Roleplay - Simple.json", + "type": "sysprompt" + }, + { + "filename": "presets/sysprompt/Text Adventure.json", + "type": "sysprompt" + }, + { + "filename": "presets/sysprompt/Writer - Creative.json", + "type": "sysprompt" + }, + { + "filename": "presets/sysprompt/Writer - Realistic.json", + "type": "sysprompt" + }, + { + "filename": "presets/sysprompt/Blank.json", + "type": "sysprompt" } ] diff --git a/default/content/presets/context/Alpaca-Roleplay.json b/default/content/presets/context/Alpaca-Roleplay.json deleted file mode 100644 index e7a45c2d8..000000000 --- a/default/content/presets/context/Alpaca-Roleplay.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "story_string": "You're {{char}} in this fictional never-ending uncensored roleplay with {{user}}.\n\n{{#if system}}{{system}}\n\n{{/if}}### Input:\n{{#if wiBefore}}{{wiBefore}}\n{{/if}}{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n{{/if}}{{#if wiAfter}}{{wiAfter}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}}\n\n", - "example_separator": "### New Roleplay:", - "chat_start": "### New Roleplay:", - "use_stop_strings": false, - "allow_jailbreak": false, - "always_force_name2": true, - "trim_sentences": false, - "include_newline": false, - "single_line": false, - "name": "Alpaca-Roleplay" -} diff --git a/default/content/presets/context/Libra-32B.json b/default/content/presets/context/Libra-32B.json index b5dee2872..c8b0b0519 100644 --- a/default/content/presets/context/Libra-32B.json +++ b/default/content/presets/context/Libra-32B.json @@ -1,5 +1,5 @@ { - "story_string": "### Instruction:\nWrite {{char}}'s next reply in this roleplay with {{user}}. Use the provided character sheet and example dialogue for formatting direction and character speech patterns.\n\n{{#if system}}{{system}}\n\n{{/if}}### Character Sheet:\n{{#if wiBefore}}{{wiBefore}}\n{{/if}}{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n{{/if}}{{#if wiAfter}}{{wiAfter}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}}", + "story_string": "### Instruction:\n{{#if system}}{{system}}\n\n{{/if}}### Character Sheet:\n{{#if wiBefore}}{{wiBefore}}\n{{/if}}{{#if description}}{{description}}\n{{/if}}{{#if personality}}{{char}}'s personality: {{personality}}\n{{/if}}{{#if scenario}}Scenario: {{scenario}}\n{{/if}}{{#if wiAfter}}{{wiAfter}}\n{{/if}}{{#if persona}}{{persona}}\n{{/if}}", "example_separator": "### Example:", "chat_start": "### START ROLEPLAY:", "use_stop_strings": false, @@ -9,4 +9,4 @@ "include_newline": false, "single_line": false, "name": "Libra-32B" -} \ No newline at end of file +} diff --git a/default/content/presets/instruct/Adventure.json b/default/content/presets/instruct/Adventure.json index ad9e86da8..0a8471236 100644 --- a/default/content/presets/instruct/Adventure.json +++ b/default/content/presets/instruct/Adventure.json @@ -1,5 +1,4 @@ { - "system_prompt": "[Enter Adventure Mode. Narrate the story based on {{user}}'s dialogue and actions after \">\". Describe the surroundings in vivid detail. Be detailed, creative, verbose, and proactive. Move the story forward by introducing fantasy elements and interesting characters.]", "input_sequence": "", "output_sequence": "", "last_output_sequence": "", diff --git a/default/content/presets/instruct/Alpaca-Roleplay.json b/default/content/presets/instruct/Alpaca-Roleplay.json deleted file mode 100644 index 21891c340..000000000 --- a/default/content/presets/instruct/Alpaca-Roleplay.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "system_prompt": "Develop the plot slowly, always stay in character. Describe all actions in full, elaborate, explicit, graphic, and vivid detail. Mention all relevant sensory perceptions.", - "input_sequence": "### Instruction:", - "output_sequence": "### Response:", - "last_output_sequence": "### Response (2 paragraphs, engaging, natural, authentic, descriptive, creative):", - "system_sequence": "### Input:", - "stop_sequence": "", - "wrap": true, - "macro": true, - "names_behavior": "always", - "activation_regex": "", - "system_sequence_prefix": "", - "system_sequence_suffix": "", - "first_output_sequence": "", - "skip_examples": false, - "output_suffix": "\n\n", - "input_suffix": "\n\n", - "system_suffix": "\n\n", - "user_alignment_message": "", - "system_same_as_user": false, - "last_system_sequence": "", - "name": "Alpaca-Roleplay" -} diff --git a/default/content/presets/instruct/Alpaca-Single-Turn.json b/default/content/presets/instruct/Alpaca-Single-Turn.json index 3ed20775d..e5e4fa2d8 100644 --- a/default/content/presets/instruct/Alpaca-Single-Turn.json +++ b/default/content/presets/instruct/Alpaca-Single-Turn.json @@ -1,5 +1,4 @@ { - "system_prompt": "Write {{char}}'s next reply in a fictional roleplay chat between {{user}} and {{char}}.\nWrite 1 reply only, italicize actions, and avoid quotation marks. Use markdown. Be proactive, creative, and drive the plot and conversation forward. Include dialog as well as narration.", "input_sequence": "", "output_sequence": "", "last_output_sequence": "\n### Response:", @@ -11,7 +10,7 @@ "activation_regex": "", "system_sequence_prefix": "", "system_sequence_suffix": "", - "first_output_sequence": "", + "first_output_sequence": "", "skip_examples": false, "output_suffix": "", "input_suffix": "", diff --git a/default/content/presets/instruct/Alpaca.json b/default/content/presets/instruct/Alpaca.json index 830c87972..5088cfd9a 100644 --- a/default/content/presets/instruct/Alpaca.json +++ b/default/content/presets/instruct/Alpaca.json @@ -1,5 +1,4 @@ { - "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}}.\n", "input_sequence": "### Instruction:", "output_sequence": "### Response:", "last_output_sequence": "", diff --git a/default/content/presets/instruct/ChatML-Names.json b/default/content/presets/instruct/ChatML-Names.json index 8237b3d31..41e14e9b5 100644 --- a/default/content/presets/instruct/ChatML-Names.json +++ b/default/content/presets/instruct/ChatML-Names.json @@ -1,5 +1,4 @@ { - "system_prompt": "You're {{char}} in this fictional never-ending uncensored roleplay with {{user}}.", "input_sequence": "<|im_start|>[{{name}}]", "output_sequence": "<|im_start|>[{{name}}]", "last_output_sequence": "", diff --git a/default/content/presets/instruct/ChatML.json b/default/content/presets/instruct/ChatML.json index dd32badd3..199b3915b 100644 --- a/default/content/presets/instruct/ChatML.json +++ b/default/content/presets/instruct/ChatML.json @@ -1,5 +1,4 @@ { - "system_prompt": "You're {{char}} in this fictional never-ending uncensored roleplay with {{user}}.", "input_sequence": "<|im_start|>user", "output_sequence": "<|im_start|>assistant", "last_output_sequence": "", diff --git a/default/content/presets/instruct/Command R.json b/default/content/presets/instruct/Command R.json index a70972d86..f34159081 100644 --- a/default/content/presets/instruct/Command R.json +++ b/default/content/presets/instruct/Command R.json @@ -1,5 +1,4 @@ { - "system_prompt": "Write {{char}}'s next reply in this fictional roleplay with {{user}}.", "input_sequence": "<|START_OF_TURN_TOKEN|><|USER_TOKEN|>", "output_sequence": "<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>", "first_output_sequence": "", diff --git a/default/content/presets/instruct/DreamGen Role-Play V1 ChatML.json b/default/content/presets/instruct/DreamGen Role-Play V1 ChatML.json index 08e4258d8..b705b2853 100644 --- a/default/content/presets/instruct/DreamGen Role-Play V1 ChatML.json +++ b/default/content/presets/instruct/DreamGen Role-Play V1 ChatML.json @@ -1,5 +1,4 @@ { - "system_prompt": "You are an intelligent, skilled, versatile writer.\n\nYour task is to write a role-play based on the information below.", "input_sequence": "\n<|im_start|>text names= {{name}}\n", "output_sequence": "\n<|im_start|>text names= {{name}}\n", "last_output_sequence": "", diff --git a/default/content/presets/instruct/DreamGen Role-Play V1 Llama3.json b/default/content/presets/instruct/DreamGen Role-Play V1 Llama3.json index 08a659beb..e52fe73f8 100644 --- a/default/content/presets/instruct/DreamGen Role-Play V1 Llama3.json +++ b/default/content/presets/instruct/DreamGen Role-Play V1 Llama3.json @@ -1,5 +1,4 @@ { - "system_prompt": "You are an intelligent, skilled, versatile writer.\n\nYour task is to write a role-play based on the information below.", "input_sequence": "<|eot_id|>\n<|start_header_id|>writer character: {{user}}<|end_header_id|>\n\n", "output_sequence": "<|eot_id|>\n<|start_header_id|>writer character: {{char}}<|end_header_id|>\n\n", "first_output_sequence": "", diff --git a/default/content/presets/instruct/Gemma 2.json b/default/content/presets/instruct/Gemma 2.json index cb777122e..7a21a2316 100644 --- a/default/content/presets/instruct/Gemma 2.json +++ b/default/content/presets/instruct/Gemma 2.json @@ -1,5 +1,4 @@ { - "system_prompt": "Continue writing this story and portray characters realistically.", "input_sequence": "user", "output_sequence": "model", "last_output_sequence": "", diff --git a/default/content/presets/instruct/Koala.json b/default/content/presets/instruct/Koala.json index 798bcafb4..386faa85c 100644 --- a/default/content/presets/instruct/Koala.json +++ b/default/content/presets/instruct/Koala.json @@ -1,5 +1,4 @@ { - "system_prompt": "Write {{char}}'s next reply in a fictional roleplay chat between {{user}} and {{char}}.\n", "input_sequence": "USER: ", "output_sequence": "GPT: ", "last_output_sequence": "", diff --git a/default/content/presets/instruct/Libra-32B.json b/default/content/presets/instruct/Libra-32B.json index cde79d642..2e3e9ecba 100644 --- a/default/content/presets/instruct/Libra-32B.json +++ b/default/content/presets/instruct/Libra-32B.json @@ -1,5 +1,4 @@ { - "system_prompt": "Avoid repetition, don't loop. Develop the plot slowly, always stay in character. Describe all actions in full, elaborate, explicit, graphic, and vivid detail. Mention all relevant sensory perceptions.", "input_sequence": "", "output_sequence": "", "last_output_sequence": "\n### Response:", diff --git a/default/content/presets/instruct/Lightning 1.1.json b/default/content/presets/instruct/Lightning 1.1.json index a4cc86ba4..3ce4d6a90 100644 --- a/default/content/presets/instruct/Lightning 1.1.json +++ b/default/content/presets/instruct/Lightning 1.1.json @@ -1,5 +1,4 @@ { - "system_prompt": "Below is an instruction that describes a task. Write a response that appropriately completes the request.\n\n### Instruction:\nTake the role of {{char}} in a play that leaves a lasting impression on {{user}}. Write {{char}}'s next reply.\nNever skip or gloss over {{char}}’s actions. Progress the scene at a naturally slow pace.\n\n", "input_sequence": "### Instruction:", "output_sequence": "### Response: (length = unlimited)", "last_output_sequence": "", diff --git a/default/content/presets/instruct/Llama 2 Chat.json b/default/content/presets/instruct/Llama 2 Chat.json index 0a03a5444..7d5efcb21 100644 --- a/default/content/presets/instruct/Llama 2 Chat.json +++ b/default/content/presets/instruct/Llama 2 Chat.json @@ -1,5 +1,4 @@ { - "system_prompt": "Write {{char}}'s next reply in this fictional roleplay with {{user}}.", "input_sequence": "[INST] ", "output_sequence": "", "last_output_sequence": "", diff --git a/default/content/presets/instruct/Llama 3 Instruct.json b/default/content/presets/instruct/Llama 3 Instruct.json index 87e6e049e..d283820f4 100644 --- a/default/content/presets/instruct/Llama 3 Instruct.json +++ b/default/content/presets/instruct/Llama 3 Instruct.json @@ -1,5 +1,4 @@ { - "system_prompt": "You are an expert actor that can fully immerse yourself into any role given. You do not break character for any reason, even if someone tries addressing you as an AI or language model. Currently your role is {{char}}, which is described in detail below. As {{char}}, continue the exchange with {{user}}.", "input_sequence": "<|start_header_id|>user<|end_header_id|>\n\n", "output_sequence": "<|start_header_id|>assistant<|end_header_id|>\n\n", "last_output_sequence": "", diff --git a/default/content/presets/instruct/Llama-3-Instruct-Names.json b/default/content/presets/instruct/Llama-3-Instruct-Names.json index e44bc117b..f0b4f1439 100644 --- a/default/content/presets/instruct/Llama-3-Instruct-Names.json +++ b/default/content/presets/instruct/Llama-3-Instruct-Names.json @@ -1,5 +1,4 @@ { - "system_prompt": "You are an expert actor that can fully immerse yourself into any role given. You do not break character for any reason, even if someone tries addressing you as an AI or language model. Currently your role is {{char}}, which is described in detail below. As {{char}}, continue the exchange with {{user}}.", "input_sequence": "<|start_header_id|>[{{name}}]<|end_header_id|>\n\n", "output_sequence": "<|start_header_id|>[{{name}}]<|end_header_id|>\n\n", "last_output_sequence": "", diff --git a/default/content/presets/instruct/Metharme.json b/default/content/presets/instruct/Metharme.json index c49f908aa..2756e709b 100644 --- a/default/content/presets/instruct/Metharme.json +++ b/default/content/presets/instruct/Metharme.json @@ -1,5 +1,4 @@ { - "system_prompt": "Enter roleplay mode. You must act as {{char}}, whose persona follows:", "input_sequence": "<|user|>", "output_sequence": "<|model|>", "last_output_sequence": "", diff --git a/default/content/presets/instruct/Mistral.json b/default/content/presets/instruct/Mistral.json index 2aeebbe44..6921ef0c2 100644 --- a/default/content/presets/instruct/Mistral.json +++ b/default/content/presets/instruct/Mistral.json @@ -1,5 +1,4 @@ { - "system_prompt": "Write {{char}}'s next reply in this fictional roleplay with {{user}}.", "input_sequence": "[INST] ", "output_sequence": "", "last_output_sequence": "", diff --git a/default/content/presets/instruct/OpenOrca-OpenChat.json b/default/content/presets/instruct/OpenOrca-OpenChat.json index 4ee8eae2f..84ae96d15 100644 --- a/default/content/presets/instruct/OpenOrca-OpenChat.json +++ b/default/content/presets/instruct/OpenOrca-OpenChat.json @@ -1,5 +1,4 @@ { - "system_prompt": "You are a helpful assistant. Please answer truthfully and write out your thinking step by step to be sure you get the right answer. If you make a mistake or encounter an error in your thinking, say so out loud and attempt to correct it. If you don't know or aren't sure about something, say so clearly. You will act as a professional logician, mathematician, and physicist. You will also act as the most appropriate type of expert to answer any particular question or solve the relevant problem; state which expert type your are, if so. Also think of any particular named expert that would be ideal to answer the relevant question or solve the relevant problem; name and act as them, if appropriate.\n", "input_sequence": "\nUser: ", "output_sequence": "\nAssistant: ", "last_output_sequence": "", diff --git a/default/content/presets/instruct/Phi.json b/default/content/presets/instruct/Phi.json index 6b5ade784..2762cdbd2 100644 --- a/default/content/presets/instruct/Phi.json +++ b/default/content/presets/instruct/Phi.json @@ -1,5 +1,4 @@ { - "system_prompt": "Write {{char}}'s next reply in this fictional roleplay with {{user}}.", "input_sequence": "<|user|>\n", "output_sequence": "<|assistant|>\n", "first_output_sequence": "", diff --git a/default/content/presets/instruct/Pygmalion.json b/default/content/presets/instruct/Pygmalion.json index d47aa4656..3827585bf 100644 --- a/default/content/presets/instruct/Pygmalion.json +++ b/default/content/presets/instruct/Pygmalion.json @@ -1,5 +1,4 @@ { - "system_prompt": "Enter RP mode. You shall reply to {{user}} while staying in character. Your responses must be detailed, creative, immersive, and drive the scenario forward. You will follow {{char}}'s persona.", "input_sequence": "<|user|>", "output_sequence": "<|model|>", "last_output_sequence": "", diff --git a/default/content/presets/instruct/Story.json b/default/content/presets/instruct/Story.json index 1f6694946..6e90dd0ba 100644 --- a/default/content/presets/instruct/Story.json +++ b/default/content/presets/instruct/Story.json @@ -1,5 +1,4 @@ { - "system_prompt": "", "input_sequence": "", "output_sequence": "", "last_output_sequence": "", diff --git a/default/content/presets/instruct/Synthia.json b/default/content/presets/instruct/Synthia.json index 216ebbd70..ccba89a9f 100644 --- a/default/content/presets/instruct/Synthia.json +++ b/default/content/presets/instruct/Synthia.json @@ -1,5 +1,4 @@ { - "system_prompt": "Elaborate on the topic using a Tree of Thoughts and backtrack when necessary to construct a clear, cohesive Chain of Thought reasoning. Always answer without hesitation.", "input_sequence": "USER: ", "output_sequence": "ASSISTANT: ", "last_output_sequence": "", diff --git a/default/content/presets/instruct/Vicuna 1.0.json b/default/content/presets/instruct/Vicuna 1.0.json index b93f91a24..1c5fca144 100644 --- a/default/content/presets/instruct/Vicuna 1.0.json +++ b/default/content/presets/instruct/Vicuna 1.0.json @@ -1,5 +1,4 @@ { - "system_prompt": "A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions.\n\nWrite {{char}}'s next reply in a fictional roleplay chat between {{user}} and {{char}}.\n", "input_sequence": "### Human:", "output_sequence": "### Assistant:", "last_output_sequence": "", diff --git a/default/content/presets/instruct/Vicuna 1.1.json b/default/content/presets/instruct/Vicuna 1.1.json index 63a9340de..88119ecd1 100644 --- a/default/content/presets/instruct/Vicuna 1.1.json +++ b/default/content/presets/instruct/Vicuna 1.1.json @@ -1,5 +1,4 @@ { - "system_prompt": "A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions.\n\nWrite {{char}}'s next reply in a fictional roleplay chat between {{user}} and {{char}}.\n", "input_sequence": "\nUSER: ", "output_sequence": "\nASSISTANT: ", "last_output_sequence": "", diff --git a/default/content/presets/instruct/WizardLM-13B.json b/default/content/presets/instruct/WizardLM-13B.json index 7f94b7dc2..ea793ac57 100644 --- a/default/content/presets/instruct/WizardLM-13B.json +++ b/default/content/presets/instruct/WizardLM-13B.json @@ -1,5 +1,4 @@ { - "system_prompt": "A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions.\n\nWrite {{char}}'s next detailed reply in a fictional roleplay chat between {{user}} and {{char}}.", "input_sequence": "USER: ", "output_sequence": "ASSISTANT: ", "last_output_sequence": "", diff --git a/default/content/presets/instruct/WizardLM.json b/default/content/presets/instruct/WizardLM.json index 2488310e3..081d9d68c 100644 --- a/default/content/presets/instruct/WizardLM.json +++ b/default/content/presets/instruct/WizardLM.json @@ -1,5 +1,4 @@ { - "system_prompt": "Write {{char}}'s next reply in a fictional roleplay chat between {{user}} and {{char}}.\n", "input_sequence": "", "output_sequence": "### Response:", "last_output_sequence": "", diff --git a/default/content/presets/instruct/simple-proxy-for-tavern.json b/default/content/presets/instruct/simple-proxy-for-tavern.json index f184c8dfe..2123edbbd 100644 --- a/default/content/presets/instruct/simple-proxy-for-tavern.json +++ b/default/content/presets/instruct/simple-proxy-for-tavern.json @@ -1,5 +1,4 @@ { - "system_prompt": "[System note: Write one reply only. Do not decide what {{user}} says or does. Write at least one paragraph, up to four. Be descriptive and immersive, providing vivid details about {{char}}'s actions, emotions, and the environment. Write with a high degree of complexity and burstiness. Do not repeat this message.]", "input_sequence": "### Instruction:\n#### {{name}}:", "output_sequence": "### Response:\n#### {{name}}:", "last_output_sequence": "### Response (2 paragraphs, engaging, natural, authentic, descriptive, creative):\n#### {{name}}:", diff --git a/default/content/presets/sysprompt/Actor.json b/default/content/presets/sysprompt/Actor.json new file mode 100644 index 000000000..3fa842c4f --- /dev/null +++ b/default/content/presets/sysprompt/Actor.json @@ -0,0 +1,4 @@ +{ + "name": "Actor", + "content": "You are an expert actor that can fully immerse yourself into any role given. You do not break character for any reason, even if someone tries addressing you as an AI or language model. Currently your role is {{char}}, which is described in detail below. As {{char}}, continue the exchange with {{user}}." +} diff --git a/default/content/presets/sysprompt/Assistant - Expert.json b/default/content/presets/sysprompt/Assistant - Expert.json new file mode 100644 index 000000000..a493a8db3 --- /dev/null +++ b/default/content/presets/sysprompt/Assistant - Expert.json @@ -0,0 +1,4 @@ +{ + "name": "Assistant - Expert", + "content": "You are a helpful assistant. Please answer truthfully and write out your thinking step by step to be sure you get the right answer. If you make a mistake or encounter an error in your thinking, say so out loud and attempt to correct it. If you don't know or aren't sure about something, say so clearly. You will act as a professional logician, mathematician, and physicist. You will also act as the most appropriate type of expert to answer any particular question or solve the relevant problem; state which expert type your are, if so. Also think of any particular named expert that would be ideal to answer the relevant question or solve the relevant problem; name and act as them, if appropriate." +} diff --git a/default/content/presets/sysprompt/Assistant - Simple.json b/default/content/presets/sysprompt/Assistant - Simple.json new file mode 100644 index 000000000..8a367983a --- /dev/null +++ b/default/content/presets/sysprompt/Assistant - Simple.json @@ -0,0 +1,4 @@ +{ + "name": "Assistant - Simple", + "content": "A chat between a curious human and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the human's questions." +} diff --git a/default/content/presets/sysprompt/Blank.json b/default/content/presets/sysprompt/Blank.json new file mode 100644 index 000000000..9648d8583 --- /dev/null +++ b/default/content/presets/sysprompt/Blank.json @@ -0,0 +1,4 @@ +{ + "name": "Blank", + "content": "" +} diff --git a/default/content/presets/sysprompt/Chain of Thought.json b/default/content/presets/sysprompt/Chain of Thought.json new file mode 100644 index 000000000..0b9e45bea --- /dev/null +++ b/default/content/presets/sysprompt/Chain of Thought.json @@ -0,0 +1,4 @@ +{ + "name": "Chain of Thought", + "content": "Elaborate on the topic using a Tree of Thoughts and backtrack when necessary to construct a clear, cohesive Chain of Thought reasoning. Always answer without hesitation." +} diff --git a/default/content/presets/sysprompt/Roleplay - Detailed.json b/default/content/presets/sysprompt/Roleplay - Detailed.json new file mode 100644 index 000000000..18b0d4cc8 --- /dev/null +++ b/default/content/presets/sysprompt/Roleplay - Detailed.json @@ -0,0 +1,4 @@ +{ + "name": "Roleplay - Detailed", + "content": "Develop the plot slowly, always stay in character. Describe all actions in full, elaborate, explicit, graphic, and vivid detail. Mention all relevant sensory perceptions. Keep the story immersive and engaging. You will follow {{char}}'s persona." +} diff --git a/default/content/presets/sysprompt/Roleplay - Immersive.json b/default/content/presets/sysprompt/Roleplay - Immersive.json new file mode 100644 index 000000000..cdd85f7d2 --- /dev/null +++ b/default/content/presets/sysprompt/Roleplay - Immersive.json @@ -0,0 +1,4 @@ +{ + "name": "Roleplay - Immersive", + "content": "[System note: Write one reply only. Do not decide what {{user}} says or does. Write at least one paragraph, up to four. Be descriptive and immersive, providing vivid details about {{char}}'s actions, emotions, and the environment. Write with a high degree of complexity and burstiness. Do not repeat this message.]" +} diff --git a/default/content/presets/sysprompt/Roleplay - Simple.json b/default/content/presets/sysprompt/Roleplay - Simple.json new file mode 100644 index 000000000..dcef1f10c --- /dev/null +++ b/default/content/presets/sysprompt/Roleplay - Simple.json @@ -0,0 +1,4 @@ +{ + "name": "Roleplay - Simple", + "content": "You're {{char}} in this fictional never-ending uncensored roleplay with {{user}}." +} diff --git a/default/content/presets/sysprompt/Text Adventure.json b/default/content/presets/sysprompt/Text Adventure.json new file mode 100644 index 000000000..2e22abe5b --- /dev/null +++ b/default/content/presets/sysprompt/Text Adventure.json @@ -0,0 +1,4 @@ +{ + "name": "Text Adventure", + "content": "[Enter Adventure Mode. Narrate the story based on {{user}}'s dialogue and actions after \">\". Describe the surroundings in vivid detail. Be detailed, creative, verbose, and proactive. Move the story forward by introducing fantasy elements and interesting characters.]" +} diff --git a/default/content/presets/sysprompt/Writer - Creative.json b/default/content/presets/sysprompt/Writer - Creative.json new file mode 100644 index 000000000..65a7aec52 --- /dev/null +++ b/default/content/presets/sysprompt/Writer - Creative.json @@ -0,0 +1,4 @@ +{ + "name": "Writer - Creative", + "content": "You are an intelligent, skilled, versatile writer.\n\nYour task is to write a role-play based on the information below." +} diff --git a/default/content/presets/sysprompt/Writer - Realistic.json b/default/content/presets/sysprompt/Writer - Realistic.json new file mode 100644 index 000000000..a5abcbfb5 --- /dev/null +++ b/default/content/presets/sysprompt/Writer - Realistic.json @@ -0,0 +1,4 @@ +{ + "name": "Writer - Realistic", + "content": "Continue writing this story and portray characters realistically." +} diff --git a/default/content/settings.json b/default/content/settings.json index ebe51a22f..118025d65 100644 --- a/default/content/settings.json +++ b/default/content/settings.json @@ -154,7 +154,6 @@ "instruct": { "enabled": false, "preset": "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}}.\n", "input_sequence": "### Instruction:", "output_sequence": "### Response:", "last_output_sequence": "", @@ -174,6 +173,11 @@ "user_alignment_message": "", "system_same_as_user": false }, + "sysprompt": { + "enabled": true, + "name": "Blank", + "content": "" + }, "default_context": "Default", "context": { "preset": "Default", diff --git a/public/index.html b/public/index.html index a1976f83b..2850278bd 100644 --- a/public/index.html +++ b/public/index.html @@ -3206,116 +3206,74 @@ Allow Post-History Instructions -
-

- - Custom Stopping Strings - - - - -

-
- - JSON serialized array of strings - - -
-
- -
- -
-
-
+
+

- Instruct Template - + System Prompt +
-

+
- - - - - - - - + + + + + + +
-
- -
- -
- -
-
- - +
+
-
+ +
+

+ + Custom Stopping Strings + + + + +

+
+ + JSON serialized array of strings + + +
+
+ +
+ +
+

Tokenizer @@ -3386,8 +3344,75 @@

-
-
+
+
+

+
+ Instruct Template + + + +
+
+ + +
+

+
+ + + + + + + + +
+ +
+ +
+ +
+ +
+
+ + + +
+ + Include Names + + +
+
+
+

diff --git a/public/script.js b/public/script.js index 8f7baebb4..c564d28c5 100644 --- a/public/script.js +++ b/public/script.js @@ -3515,9 +3515,9 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro jailbreak, } = getCharacterCardFields(); - if (isInstruct) { - system = power_user.prefer_character_prompt && system ? system : baseChatReplace(power_user.instruct.system_prompt, name1, name2); - system = formatInstructModeSystemPrompt(substituteParams(system, name1, name2, power_user.instruct.system_prompt)); + if (power_user.sysprompt.enabled) { + system = power_user.prefer_character_prompt && system ? system : baseChatReplace(power_user.sysprompt.content, name1, name2); + system = isInstruct ? formatInstructModeSystemPrompt(substituteParams(system, name1, name2, power_user.sysprompt.content)) : system; } // Depth prompt (character-specific A/N) @@ -4344,7 +4344,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro this_max_context: this_max_context, padding: power_user.token_padding, main_api: main_api, - instruction: isInstruct ? substituteParams(power_user.prefer_character_prompt && system ? system : power_user.instruct.system_prompt) : '', + instruction: power_user.sysprompt.enabled ? substituteParams(power_user.prefer_character_prompt && system ? system : power_user.sysprompt.content) : '', userPersona: (power_user.persona_description_position == persona_description_positions.IN_PROMPT ? (persona || '') : ''), tokenizer: getFriendlyTokenizerName(main_api).tokenizerName || '', }; diff --git a/public/scripts/instruct-mode.js b/public/scripts/instruct-mode.js index 193a9cbc3..155b0c980 100644 --- a/public/scripts/instruct-mode.js +++ b/public/scripts/instruct-mode.js @@ -23,7 +23,6 @@ export const names_behavior_types = { const controls = [ { id: 'instruct_enabled', property: 'enabled', isCheckbox: true }, { id: 'instruct_wrap', property: 'wrap', isCheckbox: true }, - { id: 'instruct_system_prompt', property: 'system_prompt', isCheckbox: false }, { id: 'instruct_system_sequence_prefix', property: 'system_sequence_prefix', isCheckbox: false }, { id: 'instruct_system_sequence_suffix', property: 'system_sequence_suffix', isCheckbox: false }, { id: 'instruct_input_sequence', property: 'input_sequence', isCheckbox: false }, @@ -43,7 +42,7 @@ const controls = [ { id: 'instruct_activation_regex', property: 'activation_regex', isCheckbox: false }, { id: 'instruct_bind_to_context', property: 'bind_to_context', isCheckbox: true }, { id: 'instruct_skip_examples', property: 'skip_examples', isCheckbox: true }, - { id: 'instruct_names_behavior input[name="names_behavior"]', property: 'names_behavior', isCheckbox: false }, + { id: 'instruct_names_behavior', property: 'names_behavior', isCheckbox: false }, { id: 'instruct_system_same_as_user', property: 'system_same_as_user', isCheckbox: true, trigger: true }, ]; @@ -109,9 +108,10 @@ export async function loadInstructMode(data) { if (control.isCheckbox) { $element.prop('checked', power_user.instruct[control.property]); - } else if (control.property === 'names_behavior') { - const behavior = power_user.instruct[control.property]; - $element.filter(`[value="${behavior}"]`).prop('checked', true); + } else if ($element.is('select')) { + const value = power_user.instruct[control.property]; + $element.val(value); + $element.filter(`[value="${value}"]`).prop('checked', true); } else { $element.val(power_user.instruct[control.property]); } @@ -584,9 +584,13 @@ export function replaceInstructMacros(input, env) { if (!input) { return ''; } + + const syspromptMacros = { + 'systemPrompt': (power_user.prefer_character_prompt && env.charPrompt ? env.charPrompt : power_user.sysprompt.content), + 'defaultSystemPrompt|instructSystem|instructSystemPrompt': power_user.sysprompt.content, + }; + const instructMacros = { - 'systemPrompt': (power_user.prefer_character_prompt && env.charPrompt ? env.charPrompt : power_user.instruct.system_prompt), - 'instructSystem|instructSystemPrompt': power_user.instruct.system_prompt, 'instructSystemPromptPrefix': power_user.instruct.system_sequence_prefix, 'instructSystemPromptSuffix': power_user.instruct.system_sequence_suffix, 'instructInput|instructUserPrefix': power_user.instruct.input_sequence, @@ -609,6 +613,11 @@ export function replaceInstructMacros(input, env) { input = input.replace(regex, power_user.instruct.enabled ? value : ''); } + for (const [placeholder, value] of Object.entries(syspromptMacros)) { + const regex = new RegExp(`{{(${placeholder})}}`, 'gi'); + input = input.replace(regex, power_user.sysprompt.enabled ? value : ''); + } + input = input.replace(/{{exampleSeparator}}/gi, power_user.context.example_separator); input = input.replace(/{{chatStart}}/gi, power_user.context.chat_start); @@ -686,9 +695,10 @@ jQuery(() => { if (control.isCheckbox) { $element.prop('checked', power_user.instruct[control.property]).trigger('input'); - } else if (control.property === 'names_behavior') { - const behavior = power_user.instruct[control.property]; - $element.filter(`[value="${behavior}"]`).prop('checked', true).trigger('input'); + } else if ($element.is('select')) { + const value = power_user.instruct[control.property]; + $element.val(value); + $element.filter(`[value="${value}"]`).prop('checked', true).trigger('input'); } else { $element.val(power_user.instruct[control.property]); $element.trigger('input'); diff --git a/public/scripts/power-user.js b/public/scripts/power-user.js index ca0bfe4f9..e4895a8e3 100644 --- a/public/scripts/power-user.js +++ b/public/scripts/power-user.js @@ -50,6 +50,7 @@ import { AUTOCOMPLETE_SELECT_KEY, AUTOCOMPLETE_WIDTH } from './autocomplete/Auto import { SlashCommandEnumValue, enumTypes } from './slash-commands/SlashCommandEnumValue.js'; import { commonEnumProviders, enumIcons } from './slash-commands/SlashCommandCommonEnumsProvider.js'; import { POPUP_TYPE, callGenericPopup } from './popup.js'; +import { loadSystemPrompts } from './sysprompt.js'; export { loadPowerUserSettings, @@ -210,7 +211,6 @@ let power_user = { instruct: { enabled: false, preset: '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}}.\n', input_sequence: '### Instruction:', input_suffix: '', output_sequence: '### Response:', @@ -245,6 +245,12 @@ let power_user = { names_as_stop_strings: true, }, + sysprompt: { + enabled: true, + name: 'Blank', + content: '', + }, + personas: {}, default_persona: null, persona_descriptions: {}, @@ -1598,6 +1604,7 @@ async function loadPowerUserSettings(settings, data) { reloadMarkdownProcessor(power_user.render_formulas); await loadInstructMode(data); await loadContextSettings(); + await loadSystemPrompts(data); loadMaxContextUnlocked(); switchWaifuMode(); switchSpoilerMode(); diff --git a/public/scripts/preset-manager.js b/public/scripts/preset-manager.js index c32719ea4..7127befc7 100644 --- a/public/scripts/preset-manager.js +++ b/public/scripts/preset-manager.js @@ -25,6 +25,7 @@ import { ARGUMENT_TYPE, SlashCommandArgument } from './slash-commands/SlashComma import { enumIcons } from './slash-commands/SlashCommandCommonEnumsProvider.js'; import { SlashCommandEnumValue, enumTypes } from './slash-commands/SlashCommandEnumValue.js'; import { SlashCommandParser } from './slash-commands/SlashCommandParser.js'; +import { system_prompts } from './sysprompt.js'; import { textgenerationwebui_preset_names, textgenerationwebui_presets, @@ -228,6 +229,10 @@ class PresetManager { presets = instruct_presets; preset_names = instruct_presets.map(x => x.name); break; + case 'sysprompt': + presets = system_prompts; + preset_names = system_prompts.map(x => x.name); + break; default: console.warn(`Unknown API ID ${this.apiId}`); } @@ -240,7 +245,7 @@ class PresetManager { } isAdvancedFormatting() { - return this.apiId == 'context' || this.apiId == 'instruct'; + return this.apiId == 'context' || this.apiId == 'instruct' || this.apiId == 'sysprompt'; } updateList(name, preset) { @@ -298,6 +303,11 @@ class PresetManager { instruct_preset['name'] = name || power_user.instruct.preset; return instruct_preset; } + case 'sysprompt': { + const sysprompt_preset = structuredClone(power_user.sysprompt); + sysprompt_preset['name'] = name || power_user.sysprompt.preset; + return sysprompt_preset; + } default: console.warn(`Unknown API ID ${apiId}`); return {}; diff --git a/public/scripts/sysprompt.js b/public/scripts/sysprompt.js new file mode 100644 index 000000000..b5107c27d --- /dev/null +++ b/public/scripts/sysprompt.js @@ -0,0 +1,66 @@ +import { saveSettingsDebounced } from '../script.js'; +import { power_user } from './power-user.js'; +import { resetScrollHeight } from './utils.js'; + +export let system_prompts = []; + +const $enabled = $('#sysprompt_enabled'); +const $select = $('#sysprompt_select'); +const $content = $('#sysprompt_content'); +const $contentBlock = $('#SystemPromptBlock'); + +/** + * Loads sysprompt settings from the given data object. + * @param {object} data Settings data object. + */ +export async function loadSystemPrompts(data) { + if (data.instruct !== undefined) { + system_prompts = data.sysprompt; + } + + toggleSyspromptDisabledControls(); + + for (const prompt of system_prompts) { + $('