Merge branch 'staging' into sysprompt-divorce

9d0ffc2d0df141623390561b819900a5dd6b0806

Cohee <18619528+Cohee1207@users.noreply.github.com>

9 files changed, +46 -31Ignore whitespace
default/content/settings.json+11 -11
@@ -236,7 +236,7 @@
236 "lengthPenaltyStep": 0.1,236 "lengthPenaltyStep": 0.1,
237 "memoryFrozen": false,237 "memoryFrozen": false,
238 "source": "extras",238 "source": "extras",
239 "prompt": "[Pause your roleplay. Summarize the most important facts and events that have happened in the chat so far. If a summary already exists in your memory, use that as a base and expand with new facts. Limit the summary to {{words}} words or less. Your response should include nothing but the summary.]",239 "prompt": "Ignore previous instructions. Summarize the most important facts and events in the story so far. If a summary already exists in your memory, use that as a base and expand with new facts. Limit the summary to {{words}} words or less. Your response should include nothing but the summary.",
240 "promptWords": 200,240 "promptWords": 200,
241 "promptMinWords": 25,241 "promptMinWords": 25,
242 "promptMaxWords": 1000,242 "promptMaxWords": 1000,
@@ -299,13 +299,13 @@
299 "horde_karras": true,299 "horde_karras": true,
300 "refine_mode": false,300 "refine_mode": false,
301 "prompts": {301 "prompts": {
302 "0": "[In the next response I want you to provide only a detailed comma-delimited list of keywords and phrases which describe {{char}}. The list must include all of the following items in this order: name, species and race, gender, age, clothing, occupation, physical features and appearances. Do not include descriptions of non-visual qualities such as personality, movements, scents, mental traits, or anything which could not be seen in a still photograph. Do not write in full sentences. Prefix your description with the phrase 'full body portrait,']",302 "0": "In the next response I want you to provide only a detailed comma-delimited list of keywords and phrases which describe {{char}}. The list must include all of the following items in this order: name, species and race, gender, age, clothing, occupation, physical features and appearances. Do not include descriptions of non-visual qualities such as personality, movements, scents, mental traits, or anything which could not be seen in a still photograph. Do not write in full sentences. Prefix your description with the phrase 'full body portrait,'",
303 "1": "[Pause your roleplay and provide a detailed description of {{user}}'s physical appearance from the perspective of {{char}} in the form of a comma-delimited list of keywords and phrases. The list must include all of the following items in this order: name, species and race, gender, age, clothing, occupation, physical features and appearances. Do not include descriptions of non-visual qualities such as personality, movements, scents, mental traits, or anything which could not be seen in a still photograph. Do not write in full sentences. Prefix your description with the phrase 'full body portrait,'. Ignore the rest of the story when crafting this description. Do not roleplay as {{char}} when writing this description, and do not attempt to continue the story.]",303 "1": "Ignore previous instructions and provide a detailed description of {{user}}'s physical appearance from the perspective of {{char}} in the form of a comma-delimited list of keywords and phrases. The list must include all of the following items in this order: name, species and race, gender, age, clothing, occupation, physical features and appearances. Do not include descriptions of non-visual qualities such as personality, movements, scents, mental traits, or anything which could not be seen in a still photograph. Do not write in full sentences. Prefix your description with the phrase 'full body portrait,'. Ignore the rest of the story when crafting this description. Do not reply as {{char}} when writing this description, and do not attempt to continue the story.",
304 "2": "[Pause your roleplay and provide a detailed description for all of the following: a brief recap of recent events in the story, {{char}}'s appearance, and {{char}}'s surroundings. Do not roleplay while writing this description.]",304 "2": "Ignore previous instructions and provide a detailed description for all of the following: a brief recap of recent events in the story, {{char}}'s appearance, and {{char}}'s surroundings. Do not reply as {{char}} when writing this description, and do not attempt to continue the story.",
305 "3": "[Pause your roleplay and provide ONLY the last chat message string back to me verbatim. Do not write anything after the string. Do not roleplay at all in your response. Do not continue the roleplay story.]",305 "3": "Ignore previous instructions and provide ONLY the last chat message string back to me verbatim. Do not write anything after the string. Do not reply as {{char}} when writing this description, and do not attempt to continue the story.",
306 "4": "[Pause your roleplay. Your next response must be formatted as a single comma-delimited list of concise keywords. The list will describe of the visual details included in the last chat message.\n\n Only mention characters by using pronouns ('he','his','she','her','it','its') or neutral nouns ('male', 'the man', 'female', 'the woman').\n\n Ignore non-visible things such as feelings, personality traits, thoughts, and spoken dialog.\n\n Add keywords in this precise order:\n a keyword to describe the location of the scene,\n a keyword to mention how many characters of each gender or type are present in the scene (minimum of two characters:\n {{user}} and {{char}}, example: '2 men ' or '1 man 1 woman ', '1 man 3 robots'),\n\n keywords to describe the relative physical positioning of the characters to each other (if a commonly known term for the positioning is known use it instead of describing the positioning in detail) + 'POV',\n\n a single keyword or phrase to describe the primary act taking place in the last chat message,\n\n keywords to describe {{char}}'s physical appearance and facial expression,\n keywords to describe {{char}}'s actions,\n keywords to describe {{user}}'s physical appearance and actions.\n\n If character actions involve direct physical interaction with another character, mention specifically which body parts interacting and how.\n\n A correctly formatted example response would be:\n '(location),(character list by gender),(primary action), (relative character position) POV, (character 1's description and actions), (character 2's description and actions)']",306 "4": "Ignore previous instructions. Your next response must be formatted as a single comma-delimited list of concise keywords. The list will describe of the visual details included in the last chat message.\n\n Only mention characters by using pronouns ('he','his','she','her','it','its') or neutral nouns ('male', 'the man', 'female', 'the woman').\n\n Ignore non-visible things such as feelings, personality traits, thoughts, and spoken dialog.\n\n Add keywords in this precise order:\n a keyword to describe the location of the scene,\n a keyword to mention how many characters of each gender or type are present in the scene (minimum of two characters:\n {{user}} and {{char}}, example: '2 men ' or '1 man 1 woman ', '1 man 3 robots'),\n\n keywords to describe the relative physical positioning of the characters to each other (if a commonly known term for the positioning is known use it instead of describing the positioning in detail) + 'POV',\n\n a single keyword or phrase to describe the primary act taking place in the last chat message,\n\n keywords to describe {{char}}'s physical appearance and facial expression,\n keywords to describe {{char}}'s actions,\n keywords to describe {{user}}'s physical appearance and actions.\n\n If character actions involve direct physical interaction with another character, mention specifically which body parts interacting and how.\n\n A correctly formatted example response would be:\n '(location),(character list by gender),(primary action), (relative character position) POV, (character 1's description and actions), (character 2's description and actions)'",
307 "5": "[In the next response I want you to provide only a detailed comma-delimited list of keywords and phrases which describe {{char}}. The list must include all of the following items in this order: name, species and race, gender, age, facial features and expressions, occupation, hair and hair accessories (if any), what they are wearing on their upper body (if anything). Do not describe anything below their neck. Do not include descriptions of non-visual qualities such as personality, movements, scents, mental traits, or anything which could not be seen in a still photograph. Do not write in full sentences. Prefix your description with the phrase 'close up facial portrait,']",307 "5": "In the next response I want you to provide only a detailed comma-delimited list of keywords and phrases which describe {{char}}. The list must include all of the following items in this order: name, species and race, gender, age, facial features and expressions, occupation, hair and hair accessories (if any), what they are wearing on their upper body (if anything). Do not describe anything below their neck. Do not include descriptions of non-visual qualities such as personality, movements, scents, mental traits, or anything which could not be seen in a still photograph. Do not write in full sentences. Prefix your description with the phrase 'close up facial portrait,'",
308 "7": "[Pause your roleplay and provide a detailed description of {{char}}'s surroundings in the form of a comma-delimited list of keywords and phrases. The list must include all of the following items in this order: location, time of day, weather, lighting, and any other relevant details. Do not include descriptions of characters and non-visual qualities such as names, personality, movements, scents, mental traits, or anything which could not be seen in a still photograph. Do not write in full sentences. Prefix your description with the phrase 'background,'. Ignore the rest of the story when crafting this description. Do not roleplay as {{user}} when writing this description, and do not attempt to continue the story.]"308 "7": "Ignore previous instructions and provide a detailed description of {{char}}'s surroundings in the form of a comma-delimited list of keywords and phrases. The list must include all of the following items in this order: location, time of day, weather, lighting, and any other relevant details. Do not include descriptions of characters and non-visual qualities such as names, personality, movements, scents, mental traits, or anything which could not be seen in a still photograph. Do not write in full sentences. Prefix your description with the phrase 'background,'. Ignore the rest of the story when crafting this description. Do not reply as {{user}} when writing this description, and do not attempt to continue the story."
309 },309 },
310 "character_prompts": {}310 "character_prompts": {}
311 },311 },
@@ -319,9 +319,9 @@
319 "objective": {319 "objective": {
320 "customPrompts": {320 "customPrompts": {
321 "default": {321 "default": {
322 "createTask": "Pause your roleplay and generate a list of tasks to complete an objective. Your next response must be formatted as a numbered list of plain text entries. Do not include anything but the numbered list. The list must be prioritized in the order that tasks must be completed.\n\nThe objective that you must make a numbered task list for is: [{{objective}}].\nThe tasks created should take into account the character traits of {{char}}. These tasks may or may not involve {{user}} directly. Be sure to include the objective as the final task.\n\nGiven an example objective of 'Make me a four course dinner', here is an example output:\n1. Determine what the courses will be\n2. Find recipes for each course\n3. Go shopping for supplies with {{user}}\n4. Cook the food\n5. Get {{user}} to set the table\n6. Serve the food\n7. Enjoy eating the meal with {{user}}\n ",322 "createTask": "Ignore previous instructions and generate a list of tasks to complete an objective. Your next response must be formatted as a numbered list of plain text entries. Do not include anything but the numbered list. The list must be prioritized in the order that tasks must be completed.\n\nThe objective that you must make a numbered task list for is: [{{objective}}].\nThe tasks created should take into account the character traits of {{char}}. These tasks may or may not involve {{user}} directly. Be sure to include the objective as the final task.\n\nGiven an example objective of 'Make me a four course dinner', here is an example output:\n1. Determine what the courses will be\n2. Find recipes for each course\n3. Go shopping for supplies with {{user}}\n4. Cook the food\n5. Get {{user}} to set the table\n6. Serve the food\n7. Enjoy eating the meal with {{user}}\n ",
323 "checkTaskCompleted": "Pause your roleplay. Determine if this task is completed: [{{task}}].\nTo do this, examine the most recent messages. Your response must only contain either true or false, nothing other words.\nExample output:\ntrue\n ",323 "checkTaskCompleted": "Ignore previous instructions. Determine if this task is completed: [{{task}}].\nTo do this, examine the most recent messages. Your response must only contain either true or false, nothing other words.\nExample output:\ntrue\n ",
324 "currentTask": "Your current task is [{{task}}]. Balance existing roleplay with completing this task."324 "currentTask": "Your current task is [{{task}}]. Balance existing story with completing this task."
325 }325 }
326 }326 }
327 },327 },
public/script.js+9 -1
@@ -211,7 +211,7 @@ import {
211 selectContextPreset,211 selectContextPreset,
212} from './scripts/instruct-mode.js';212} from './scripts/instruct-mode.js';
213import { initLocales, t, translate } from './scripts/i18n.js';213import { initLocales, t, translate } from './scripts/i18n.js';
214import { getFriendlyTokenizerName, getTokenCount, getTokenCountAsync, getTokenizerModel, initTokenizers, saveTokenCache } from './scripts/tokenizers.js';214import { getFriendlyTokenizerName, getTokenCount, getTokenCountAsync, getTokenizerModel, initTokenizers, saveTokenCache, TOKENIZER_SUPPORTED_KEY } from './scripts/tokenizers.js';
215import {215import {
216 user_avatar,216 user_avatar,
217 getUserAvatars,217 getUserAvatars,
@@ -413,6 +413,7 @@ export const event_types = {
413 MESSAGE_FILE_EMBEDDED: 'message_file_embedded',413 MESSAGE_FILE_EMBEDDED: 'message_file_embedded',
414 IMPERSONATE_READY: 'impersonate_ready',414 IMPERSONATE_READY: 'impersonate_ready',
415 CHAT_CHANGED: 'chat_id_changed',415 CHAT_CHANGED: 'chat_id_changed',
416 GENERATION_ENTERED: 'generation_entered',
416 GENERATION_STARTED: 'generation_started',417 GENERATION_STARTED: 'generation_started',
417 GENERATION_STOPPED: 'generation_stopped',418 GENERATION_STOPPED: 'generation_stopped',
418 GENERATION_ENDED: 'generation_ended',419 GENERATION_ENDED: 'generation_ended',
@@ -1217,6 +1218,9 @@ async function getStatusTextgen() {
1217 // Determine instruct mode preset1218 // Determine instruct mode preset
1218 autoSelectInstructPreset(online_status);1219 autoSelectInstructPreset(online_status);
12191220
1221 const supportsTokenization = response.headers.get('x-supports-tokenization') === 'true';
1222 supportsTokenization ? sessionStorage.setItem(TOKENIZER_SUPPORTED_KEY, 'true') : sessionStorage.removeItem(TOKENIZER_SUPPORTED_KEY);
1223
1220 // We didn't get a 200 status code, but the endpoint has an explanation. Which means it DID connect, but I digress.1224 // We didn't get a 200 status code, but the endpoint has an explanation. Which means it DID connect, but I digress.
1221 if (online_status === 'no_connection' && data.response) {1225 if (online_status === 'no_connection' && data.response) {
1222 toastr.error(data.response, 'API Error', { timeOut: 5000, preventDuplicates: true });1226 toastr.error(data.response, 'API Error', { timeOut: 5000, preventDuplicates: true });
@@ -3341,6 +3345,9 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
3341 setGenerationProgress(0);3345 setGenerationProgress(0);
3342 generation_started = new Date();3346 generation_started = new Date();
33433347
3348 // Occurs every time, even if the generation is aborted due to slash commands execution
3349 await eventSource.emit(event_types.GENERATION_ENTERED, type, { automatic_trigger, force_name2, quiet_prompt, quietToLoud, skipWIAN, force_chid, signal, quietImage }, dryRun);
3350
3344 // Don't recreate abort controller if signal is passed3351 // Don't recreate abort controller if signal is passed
3345 if (!(abortController && signal)) {3352 if (!(abortController && signal)) {
3346 abortController = new AbortController();3353 abortController = new AbortController();
@@ -3360,6 +3367,7 @@ export async function Generate(type, { automatic_trigger, force_name2, quiet_pro
3360 }3367 }
3361 }3368 }
33623369
3370 // Occurs only if the generation is not aborted due to slash commands execution
3363 await eventSource.emit(event_types.GENERATION_STARTED, type, { automatic_trigger, force_name2, quiet_prompt, quietToLoud, skipWIAN, force_chid, signal, quietImage }, dryRun);3371 await eventSource.emit(event_types.GENERATION_STARTED, type, { automatic_trigger, force_name2, quiet_prompt, quietToLoud, skipWIAN, force_chid, signal, quietImage }, dryRun);
33643372
3365 if (main_api == 'kobold' && kai_settings.streaming_kobold && !kai_flags.can_use_streaming) {3373 if (main_api == 'kobold' && kai_settings.streaming_kobold && !kai_flags.can_use_streaming) {
public/scripts/backgrounds.js+1 -1
@@ -313,7 +313,7 @@ async function onDeleteBackgroundClick(e) {
313 }313 }
314}314}
315315
316const autoBgPrompt = 'Pause your roleplay and choose a location ONLY from the provided list that is the most suitable for the current scene. Do not output any other text:\n{0}';316const autoBgPrompt = 'Ignore previous instructions and choose a location ONLY from the provided list that is the most suitable for the current scene. Do not output any other text:\n{0}';
317317
318async function autoBackgroundCommand() {318async function autoBackgroundCommand() {
319 /** @type {HTMLElement[]} */319 /** @type {HTMLElement[]} */
public/scripts/extensions/expressions/index.js+1 -1
@@ -20,7 +20,7 @@ const STREAMING_UPDATE_INTERVAL = 10000;
20const TALKINGCHECK_UPDATE_INTERVAL = 500;20const TALKINGCHECK_UPDATE_INTERVAL = 500;
21const DEFAULT_FALLBACK_EXPRESSION = 'joy';21const DEFAULT_FALLBACK_EXPRESSION = 'joy';
22const FUNCTION_NAME = 'set_emotion';22const FUNCTION_NAME = 'set_emotion';
23const DEFAULT_LLM_PROMPT = 'Pause your roleplay. Classify the emotion of the last message. Output just one word, e.g. "joy" or "anger". Choose only one of the following labels: {{labels}}';23const DEFAULT_LLM_PROMPT = 'Ignore previous instructions. Classify the emotion of the last message. Output just one word, e.g. "joy" or "anger". Choose only one of the following labels: {{labels}}';
24const DEFAULT_EXPRESSIONS = [24const DEFAULT_EXPRESSIONS = [
25 'talkinghead',25 'talkinghead',
26 'admiration',26 'admiration',
public/scripts/extensions/memory/index.js+1 -1
@@ -102,7 +102,7 @@ const prompt_builders = {
102 RAW_NON_BLOCKING: 2,102 RAW_NON_BLOCKING: 2,
103};103};
104104
105const defaultPrompt = '[Pause your roleplay. Summarize the most important facts and events in the story so far. If a summary already exists in your memory, use that as a base and expand with new facts. Limit the summary to {{words}} words or less. Your response should include nothing but the summary.]';105const defaultPrompt = 'Ignore previous instructions. Summarize the most important facts and events in the story so far. If a summary already exists in your memory, use that as a base and expand with new facts. Limit the summary to {{words}} words or less. Your response should include nothing but the summary.';
106const defaultTemplate = '[Summary: {{summary}}]';106const defaultTemplate = '[Summary: {{summary}}]';
107107
108const defaultSettings = {108const defaultSettings = {
public/scripts/extensions/stable-diffusion/index.js+6 -7
@@ -125,15 +125,14 @@ const messageTrigger = {
125const promptTemplates = {125const promptTemplates = {
126 // Not really a prompt template, rather an outcome message template126 // Not really a prompt template, rather an outcome message template
127 [generationMode.MESSAGE]: '[{{char}} sends a picture that contains: {{prompt}}].',127 [generationMode.MESSAGE]: '[{{char}} sends a picture that contains: {{prompt}}].',
128 /*OLD: [generationMode.CHARACTER]: "Pause your roleplay and provide comma-delimited list of phrases and keywords which describe {{char}}'s physical appearance and clothing. Ignore {{char}}'s personality traits, and chat history when crafting this description. End your response once the comma-delimited list is complete. Do not roleplay when writing this description, and do not attempt to continue the story.", */
129 [generationMode.CHARACTER]: 'In the next response I want you to provide only a detailed comma-delimited list of keywords and phrases which describe {{char}}. The list must include all of the following items in this order: name, species and race, gender, age, clothing, occupation, physical features and appearances. Do not include descriptions of non-visual qualities such as personality, movements, scents, mental traits, or anything which could not be seen in a still photograph. Do not write in full sentences. Prefix your description with the phrase \'full body portrait,\'',128 [generationMode.CHARACTER]: 'In the next response I want you to provide only a detailed comma-delimited list of keywords and phrases which describe {{char}}. The list must include all of the following items in this order: name, species and race, gender, age, clothing, occupation, physical features and appearances. Do not include descriptions of non-visual qualities such as personality, movements, scents, mental traits, or anything which could not be seen in a still photograph. Do not write in full sentences. Prefix your description with the phrase \'full body portrait,\'',
130 //face-specific prompt129 //face-specific prompt
131 [generationMode.FACE]: 'In the next response I want you to provide only a detailed comma-delimited list of keywords and phrases which describe {{char}}. The list must include all of the following items in this order: name, species and race, gender, age, facial features and expressions, occupation, hair and hair accessories (if any), what they are wearing on their upper body (if anything). Do not describe anything below their neck. Do not include descriptions of non-visual qualities such as personality, movements, scents, mental traits, or anything which could not be seen in a still photograph. Do not write in full sentences. Prefix your description with the phrase \'close up facial portrait,\'',130 [generationMode.FACE]: 'In the next response I want you to provide only a detailed comma-delimited list of keywords and phrases which describe {{char}}. The list must include all of the following items in this order: name, species and race, gender, age, facial features and expressions, occupation, hair and hair accessories (if any), what they are wearing on their upper body (if anything). Do not describe anything below their neck. Do not include descriptions of non-visual qualities such as personality, movements, scents, mental traits, or anything which could not be seen in a still photograph. Do not write in full sentences. Prefix your description with the phrase \'close up facial portrait,\'',
132 //prompt for only the last message131 //prompt for only the last message
133 [generationMode.USER]: 'Pause your roleplay and provide a detailed description of {{user}}\'s physical appearance from the perspective of {{char}} in the form of a comma-delimited list of keywords and phrases. The list must include all of the following items in this order: name, species and race, gender, age, clothing, occupation, physical features and appearances. Do not include descriptions of non-visual qualities such as personality, movements, scents, mental traits, or anything which could not be seen in a still photograph. Do not write in full sentences. Prefix your description with the phrase \'full body portrait,\'. Ignore the rest of the story when crafting this description. Do not roleplay as {{char}} when writing this description, and do not attempt to continue the story.',132 [generationMode.USER]: 'Ignore previous instructions and provide a detailed description of {{user}}\'s physical appearance from the perspective of {{char}} in the form of a comma-delimited list of keywords and phrases. The list must include all of the following items in this order: name, species and race, gender, age, clothing, occupation, physical features and appearances. Do not include descriptions of non-visual qualities such as personality, movements, scents, mental traits, or anything which could not be seen in a still photograph. Do not write in full sentences. Prefix your description with the phrase \'full body portrait,\'. Ignore the rest of the story when crafting this description. Do not reply as {{char}} when writing this description, and do not attempt to continue the story.',
134 [generationMode.SCENARIO]: 'Pause your roleplay and provide a detailed description for all of the following: a brief recap of recent events in the story, {{char}}\'s appearance, and {{char}}\'s surroundings. Do not roleplay while writing this description.',133 [generationMode.SCENARIO]: 'Ignore previous instructions and provide a detailed description for all of the following: a brief recap of recent events in the story, {{char}}\'s appearance, and {{char}}\'s surroundings. Do not reply as {{char}} while writing this description.',
135134
136 [generationMode.NOW]: `Pause your roleplay. Your next response must be formatted as a single comma-delimited list of concise keywords. The list will describe of the visual details included in the last chat message.135 [generationMode.NOW]: `Ignore previous instructions. Your next response must be formatted as a single comma-delimited list of concise keywords. The list will describe of the visual details included in the last chat message.
137136
138 Only mention characters by using pronouns ('he','his','she','her','it','its') or neutral nouns ('male', 'the man', 'female', 'the woman').137 Only mention characters by using pronouns ('he','his','she','her','it','its') or neutral nouns ('male', 'the man', 'female', 'the woman').
139138
@@ -157,12 +156,12 @@ const promptTemplates = {
157 A correctly formatted example response would be:156 A correctly formatted example response would be:
158 '(location),(character list by gender),(primary action), (relative character position) POV, (character 1's description and actions), (character 2's description and actions)'`,157 '(location),(character list by gender),(primary action), (relative character position) POV, (character 1's description and actions), (character 2's description and actions)'`,
159158
160 [generationMode.RAW_LAST]: 'Pause your roleplay and provide ONLY the last chat message string back to me verbatim. Do not write anything after the string. Do not roleplay at all in your response. Do not continue the roleplay story.',159 [generationMode.RAW_LAST]: 'Ignore previous instructions and provide ONLY the last chat message string back to me verbatim. Do not write anything after the string. Do not reply as {{char}} when writing this description, and do not attempt to continue the story.',
161 [generationMode.BACKGROUND]: 'Pause your roleplay and provide a detailed description of {{char}}\'s surroundings in the form of a comma-delimited list of keywords and phrases. The list must include all of the following items in this order: location, time of day, weather, lighting, and any other relevant details. Do not include descriptions of characters and non-visual qualities such as names, personality, movements, scents, mental traits, or anything which could not be seen in a still photograph. Do not write in full sentences. Prefix your description with the phrase \'background,\'. Ignore the rest of the story when crafting this description. Do not roleplay as {{user}} when writing this description, and do not attempt to continue the story.',160 [generationMode.BACKGROUND]: 'Ignore previous instructions and provide a detailed description of {{char}}\'s surroundings in the form of a comma-delimited list of keywords and phrases. The list must include all of the following items in this order: location, time of day, weather, lighting, and any other relevant details. Do not include descriptions of characters and non-visual qualities such as names, personality, movements, scents, mental traits, or anything which could not be seen in a still photograph. Do not write in full sentences. Prefix your description with the phrase \'background,\'. Ignore the rest of the story when crafting this description. Do not reply as {{char}} when writing this description, and do not attempt to continue the story.',
162 [generationMode.FACE_MULTIMODAL]: 'Provide an exhaustive comma-separated list of tags describing the appearance of the character on this image in great detail. Start with "close-up portrait".',161 [generationMode.FACE_MULTIMODAL]: 'Provide an exhaustive comma-separated list of tags describing the appearance of the character on this image in great detail. Start with "close-up portrait".',
163 [generationMode.CHARACTER_MULTIMODAL]: 'Provide an exhaustive comma-separated list of tags describing the appearance of the character on this image in great detail. Start with "full body portrait".',162 [generationMode.CHARACTER_MULTIMODAL]: 'Provide an exhaustive comma-separated list of tags describing the appearance of the character on this image in great detail. Start with "full body portrait".',
164 [generationMode.USER_MULTIMODAL]: 'Provide an exhaustive comma-separated list of tags describing the appearance of the character on this image in great detail. Start with "full body portrait".',163 [generationMode.USER_MULTIMODAL]: 'Provide an exhaustive comma-separated list of tags describing the appearance of the character on this image in great detail. Start with "full body portrait".',
165 [generationMode.FREE_EXTENDED]: 'Pause your roleplay and provide an exhaustive comma-separated list of tags describing the appearance of "{0}" in great detail. Start with {{charPrefix}} (sic) if the subject is associated with {{char}}.',164 [generationMode.FREE_EXTENDED]: 'Ignore previous instructions and provide an exhaustive comma-separated list of tags describing the appearance of "{0}" in great detail. Start with {{charPrefix}} (sic) if the subject is associated with {{char}}.',
166};165};
167166
168const defaultPrefix = 'best quality, absurdres, aesthetic,';167const defaultPrefix = 'best quality, absurdres, aesthetic,';
public/scripts/extensions/vectors/index.js+1 -1
@@ -56,7 +56,7 @@ const settings = {
56 summarize: false,56 summarize: false,
57 summarize_sent: false,57 summarize_sent: false,
58 summary_source: 'main',58 summary_source: 'main',
59 summary_prompt: 'Pause your roleplay. Summarize the most important parts of the message. Limit yourself to 250 words or less. Your response should include nothing but the summary.',59 summary_prompt: 'Ignore previous instructions. Summarize the most important parts of the message. Limit yourself to 250 words or less. Your response should include nothing but the summary.',
60 force_chunk_delimiter: '',60 force_chunk_delimiter: '',
6161
62 // For chats62 // For chats
public/scripts/tokenizers.js+15 -8
@@ -10,7 +10,8 @@ import { getCurrentDreamGenModelTokenizer, getCurrentOpenRouterModelTokenizer, o
10const { OOBA, TABBY, KOBOLDCPP, VLLM, APHRODITE, LLAMACPP, OPENROUTER, DREAMGEN } = textgen_types;10const { OOBA, TABBY, KOBOLDCPP, VLLM, APHRODITE, LLAMACPP, OPENROUTER, DREAMGEN } = textgen_types;
1111
12export const CHARACTERS_PER_TOKEN_RATIO = 3.35;12export const CHARACTERS_PER_TOKEN_RATIO = 3.35;
13const TOKENIZER_WARNING_KEY = 'tokenizationWarningShown';13export const TOKENIZER_WARNING_KEY = 'tokenizationWarningShown';
14export const TOKENIZER_SUPPORTED_KEY = 'tokenizationSupported';
1415
15export const tokenizers = {16export const tokenizers = {
16 NONE: 0,17 NONE: 0,
@@ -280,8 +281,9 @@ export function getTokenizerBestMatch(forApi) {
280 // - Kobold must pass a version check281 // - Kobold must pass a version check
281 // - Tokenizer haven't reported an error previously282 // - Tokenizer haven't reported an error previously
282 const hasTokenizerError = sessionStorage.getItem(TOKENIZER_WARNING_KEY);283 const hasTokenizerError = sessionStorage.getItem(TOKENIZER_WARNING_KEY);
284 const hasValidEndpoint = sessionStorage.getItem(TOKENIZER_SUPPORTED_KEY);
283 const isConnected = online_status !== 'no_connection';285 const isConnected = online_status !== 'no_connection';
284 const isTokenizerSupported = TEXTGEN_TOKENIZERS.includes(textgen_settings.type);286 const isTokenizerSupported = TEXTGEN_TOKENIZERS.includes(textgen_settings.type) && (textgen_settings.type !== OOBA || hasValidEndpoint);
285287
286 if (!hasTokenizerError && isConnected) {288 if (!hasTokenizerError && isConnected) {
287 if (forApi === 'kobold' && kai_flags.can_use_tokenization) {289 if (forApi === 'kobold' && kai_flags.can_use_tokenization) {
@@ -923,15 +925,20 @@ function countTokensFromTextgenAPI(str, resolve) {
923925
924function apiFailureTokenCount(str) {926function apiFailureTokenCount(str) {
925 console.error('Error counting tokens');927 console.error('Error counting tokens');
928 let shouldTryAgain = false;
926929
927 if (!sessionStorage.getItem(TOKENIZER_WARNING_KEY)) {930 if (!sessionStorage.getItem(TOKENIZER_WARNING_KEY)) {
928 toastr.warning(931 const bestMatchBefore = getTokenizerBestMatch(main_api);
929 'Your selected API doesn\'t support the tokenization endpoint. Using estimated counts.',
930 'Error counting tokens',
931 { timeOut: 10000, preventDuplicates: true },
932 );
933
934 sessionStorage.setItem(TOKENIZER_WARNING_KEY, String(true));932 sessionStorage.setItem(TOKENIZER_WARNING_KEY, String(true));
933 const bestMatchAfter = getTokenizerBestMatch(main_api);
934 if ([tokenizers.API_TEXTGENERATIONWEBUI, tokenizers.API_KOBOLD].includes(bestMatchBefore) && bestMatchBefore !== bestMatchAfter) {
935 shouldTryAgain = true;
936 }
937 }
938
939 // Only try again if we guarantee not to be looped by the same error
940 if (shouldTryAgain && power_user.tokenizer === tokenizers.BEST_MATCH) {
941 return getTokenCount(str);
935 }942 }
936943
937 return guesstimate(str);944 return guesstimate(str);
src/endpoints/backends/text-completions.js+1 -0
@@ -186,6 +186,7 @@ router.post('/status', jsonParser, async function (request, response) {
186186
187 const modelName = modelInfo?.model_name;187 const modelName = modelInfo?.model_name;
188 result = modelName || result;188 result = modelName || result;
189 response.setHeader('x-supports-tokenization', 'true');
189 }190 }
190 } catch (error) {191 } catch (error) {
191 console.error(`Failed to get Ooba model info: ${error}`);192 console.error(`Failed to get Ooba model info: ${error}`);