using symbols instead

f1a053c3b83609ae10dabd326110261d01312d10

qvink <qvink@users.noreply.github.com>

3 files changed, +11 -3Ignore whitespace
public/script.js+3 -2
@@ -174,7 +174,7 @@ import {
174 saveBase64AsFile,174 saveBase64AsFile,
175 uuidv4,175 uuidv4,
176} from './scripts/utils.js';176} from './scripts/utils.js';
177import { debounce_timeout } from './scripts/constants.js';177import { debounce_timeout, IGNORE_SYMBOL } from './scripts/constants.js';
178178
179import { doDailyExtensionUpdatesCheck, extension_settings, initExtensions, loadExtensionSettings, runGenerationInterceptors, saveMetadataDebounced } from './scripts/extensions.js';179import { doDailyExtensionUpdatesCheck, extension_settings, initExtensions, loadExtensionSettings, runGenerationInterceptors, saveMetadataDebounced } from './scripts/extensions.js';
180import { COMMENT_NAME_DEFAULT, executeSlashCommandsOnChatInput, getSlashCommandsHelp, initDefaultSlashCommands, isExecutingCommandsFromChatInput, pauseScriptExecution, processChatSlashCommands, stopScriptExecution } from './scripts/slash-commands.js';180import { COMMENT_NAME_DEFAULT, executeSlashCommandsOnChatInput, getSlashCommandsHelp, initDefaultSlashCommands, isExecutingCommandsFromChatInput, pauseScriptExecution, processChatSlashCommands, stopScriptExecution } from './scripts/slash-commands.js';
@@ -5295,6 +5295,7 @@ export function getBiasStrings(textareaText, type) {
5295 * @param {boolean} isInstruct Whether instruct mode is enabled.5295 * @param {boolean} isInstruct Whether instruct mode is enabled.
5296 * @param {boolean|number} forceOutputSequence Whether to force the first/last output sequence for instruct mode.5296 * @param {boolean|number} forceOutputSequence Whether to force the first/last output sequence for instruct mode.
5297 */5297 */
5298
5298function formatMessageHistoryItem(chatItem, isInstruct, forceOutputSequence) {5299function formatMessageHistoryItem(chatItem, isInstruct, forceOutputSequence) {
5299 const isNarratorType = chatItem?.extra?.type === system_message_types.NARRATOR;5300 const isNarratorType = chatItem?.extra?.type === system_message_types.NARRATOR;
5300 const characterName = chatItem?.name ? chatItem.name : name2;5301 const characterName = chatItem?.name ? chatItem.name : name2;
@@ -5303,7 +5304,7 @@ function formatMessageHistoryItem(chatItem, isInstruct, forceOutputSequence) {
53035304
5304 // If this flag is set, completely ignore the message.5305 // If this flag is set, completely ignore the message.
5305 // This can be used to hide messages without affecting the number of messages in the chat.5306 // This can be used to hide messages without affecting the number of messages in the chat.
5306 if (chatItem.extra?.ignore) {5307 if (chatItem.extra?.[IGNORE_SYMBOL]) {
5307 return '';5308 return '';
5308 }5309 }
53095310
public/scripts/constants.js+6 -0
@@ -14,3 +14,9 @@ export const debounce_timeout = {
14 /** [5 sec] For delayed tasks, like auto-saving or completing batch operations that need a significant pause. */14 /** [5 sec] For delayed tasks, like auto-saving or completing batch operations that need a significant pause. */
15 extended: 5000,15 extended: 5000,
16};16};
17
18/*
19Used as an ephemeral key in message extra metadata.
20When set, the message will be excluded from context.
21 */
22export const IGNORE_SYMBOL = Symbol.for('ignore');
public/scripts/openai.js+2 -1
@@ -75,6 +75,7 @@ import { Popup, POPUP_RESULT } from './popup.js';
75import { t } from './i18n.js';75import { t } from './i18n.js';
76import { ToolManager } from './tool-calling.js';76import { ToolManager } from './tool-calling.js';
77import { accountStorage } from './util/AccountStorage.js';77import { accountStorage } from './util/AccountStorage.js';
78import {IGNORE_SYMBOL} from "./constants.js";
7879
79export {80export {
80 openai_messages_count,81 openai_messages_count,
@@ -528,7 +529,7 @@ function setOpenAIMessages(chat) {
528 let content = chat[j]['mes'];529 let content = chat[j]['mes'];
529530
530 // If this flag is set, completely ignore the message531 // If this flag is set, completely ignore the message
531 if (chat[j].extra?.ignore) {532 if (chat[j].extra?.[IGNORE_SYMBOL]) {
532 j++;533 j++;
533 continue;534 continue;
534 }535 }