using symbols instead
| @@ -174,7 +174,7 @@ import { | |||
| 174 | saveBase64AsFile, | 174 | saveBase64AsFile, |
| 175 | uuidv4, | 175 | uuidv4, |
| 176 | } from './scripts/utils.js'; | 176 | } from './scripts/utils.js'; |
| 177 | import { debounce_timeout } from './scripts/constants.js'; | 177 | import { debounce_timeout, IGNORE_SYMBOL } from './scripts/constants.js'; |
| 178 | 178 | ||
| 179 | import { doDailyExtensionUpdatesCheck, extension_settings, initExtensions, loadExtensionSettings, runGenerationInterceptors, saveMetadataDebounced } from './scripts/extensions.js'; | 179 | import { doDailyExtensionUpdatesCheck, extension_settings, initExtensions, loadExtensionSettings, runGenerationInterceptors, saveMetadataDebounced } from './scripts/extensions.js'; |
| 180 | import { COMMENT_NAME_DEFAULT, executeSlashCommandsOnChatInput, getSlashCommandsHelp, initDefaultSlashCommands, isExecutingCommandsFromChatInput, pauseScriptExecution, processChatSlashCommands, stopScriptExecution } from './scripts/slash-commands.js'; | 180 | import { 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 | |||
| 5298 | function formatMessageHistoryItem(chatItem, isInstruct, forceOutputSequence) { | 5299 | function 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) { | |||
| 5303 | 5304 | ||
| 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 | } |
| 5309 | 5310 | ||
| @@ -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 | /* | ||
| 19 | Used as an ephemeral key in message extra metadata. | ||
| 20 | When set, the message will be excluded from context. | ||
| 21 | */ | ||
| 22 | export const IGNORE_SYMBOL = Symbol.for('ignore'); | ||
| @@ -75,6 +75,7 @@ import { Popup, POPUP_RESULT } from './popup.js'; | |||
| 75 | import { t } from './i18n.js'; | 75 | import { t } from './i18n.js'; |
| 76 | import { ToolManager } from './tool-calling.js'; | 76 | import { ToolManager } from './tool-calling.js'; |
| 77 | import { accountStorage } from './util/AccountStorage.js'; | 77 | import { accountStorage } from './util/AccountStorage.js'; |
| 78 | import {IGNORE_SYMBOL} from "./constants.js"; | ||
| 78 | 79 | ||
| 79 | export { | 80 | export { |
| 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']; |
| 529 | 530 | ||
| 530 | // If this flag is set, completely ignore the message | 531 | // 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 | } |