Exportable temporary assistant chats

This commit is contained in:
Cohee
2025-01-24 00:12:00 +02:00
parent a503f58d0c
commit 6aaeb754ef
4 changed files with 40 additions and 2 deletions

View File

@@ -11,6 +11,7 @@ import {
getCurrentChatId,
getRequestHeaders,
hideSwipeButtons,
name1,
name2,
reloadCurrentChat,
saveChatDebounced,
@@ -21,6 +22,7 @@ import {
chat_metadata,
neutralCharacterName,
updateChatMetadata,
system_message_types,
} from '../script.js';
import { selected_group } from './group-chats.js';
import { power_user } from './power-user.js';
@@ -34,6 +36,7 @@ import {
humanFileSize,
saveBase64AsFile,
extractTextFromOffice,
download,
} from './utils.js';
import { extension_settings, renderExtensionTemplateAsync, saveMetadataDebounced } from './extensions.js';
import { POPUP_RESULT, POPUP_TYPE, Popup, callGenericPopup } from './popup.js';
@@ -41,6 +44,7 @@ import { ScraperManager } from './scrapers.js';
import { DragAndDropHandler } from './dragdrop.js';
import { renderTemplateAsync } from './templates.js';
import { t } from './i18n.js';
import { humanizedDateTime } from './RossAscends-mods.js';
/**
* @typedef {Object} FileAttachment
@@ -1437,6 +1441,19 @@ jQuery(function () {
await viewMessageFile(messageId);
});
$(document).on('click', '.assistant_note_export', async function () {
const chatToSave = [
{
user_name: name1,
character_name: name2,
chat_metadata: chat_metadata,
},
...chat.filter(x => x?.extra?.type !== system_message_types.ASSISTANT_NOTE),
];
download(JSON.stringify(chatToSave, null, 4), `Assistant - ${humanizedDateTime()}.json`, 'application/json');
});
// Do not change. #attachFile is added by extension.
$(document).on('click', '#attachFile', function () {
$('#file_form_input').trigger('click');