using symbols instead

f1a053c3b83609ae10dabd326110261d01312d10

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

3 files changed, +11 -3Showing whitespace changes
public/script.js+3 -2
@@ -174,7 +174,7 @@ import {
174174 saveBase64AsFile,
175175 uuidv4,
176176} from './scripts/utils.js';
177177import { debounce_timeout, IGNORE_SYMBOL } from './scripts/constants.js';
178178
179179import { doDailyExtensionUpdatesCheck, extension_settings, initExtensions, loadExtensionSettings, runGenerationInterceptors, saveMetadataDebounced } from './scripts/extensions.js';
180180import { COMMENT_NAME_DEFAULT, executeSlashCommandsOnChatInput, getSlashCommandsHelp, initDefaultSlashCommands, isExecutingCommandsFromChatInput, pauseScriptExecution, processChatSlashCommands, stopScriptExecution } from './scripts/slash-commands.js';
@@ -5295,6 +5295,7 @@ export function getBiasStrings(textareaText, type) {
52955295 * @param {boolean} isInstruct Whether instruct mode is enabled.
52965296 * @param {boolean|number} forceOutputSequence Whether to force the first/last output sequence for instruct mode.
52975297 */
5298+
52985299function formatMessageHistoryItem(chatItem, isInstruct, forceOutputSequence) {
52995300 const isNarratorType = chatItem?.extra?.type === system_message_types.NARRATOR;
53005301 const characterName = chatItem?.name ? chatItem.name : name2;
@@ -5303,7 +5304,7 @@ function formatMessageHistoryItem(chatItem, isInstruct, forceOutputSequence) {
53035304
53045305 // If this flag is set, completely ignore the message.
53055306 // This can be used to hide messages without affecting the number of messages in the chat.
53065307 if (chatItem.extra?.ignore[IGNORE_SYMBOL]) {
53075308 return '';
53085309 }
53095310
public/scripts/constants.js+6 -0
@@ -14,3 +14,9 @@ export const debounce_timeout = {
1414 /** [5 sec] For delayed tasks, like auto-saving or completing batch operations that need a significant pause. */
1515 extended: 5000,
1616};
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');
public/scripts/openai.js+2 -1
@@ -75,6 +75,7 @@ import { Popup, POPUP_RESULT } from './popup.js';
7575import { t } from './i18n.js';
7676import { ToolManager } from './tool-calling.js';
7777import { accountStorage } from './util/AccountStorage.js';
78+import {IGNORE_SYMBOL} from "./constants.js";
7879
7980export {
8081 openai_messages_count,
@@ -528,7 +529,7 @@ function setOpenAIMessages(chat) {
528529 let content = chat[j]['mes'];
529530
530531 // If this flag is set, completely ignore the message
531532 if (chat[j].extra?.ignore[IGNORE_SYMBOL]) {
532533 j++;
533534 continue;
534535 }