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

@ -724,6 +724,7 @@ async function getSystemMessages() {
is_user: false,
is_system: true,
mes: await renderTemplateAsync('assistantNote'),
uses_system_ui: true,
extra: {
isSmallSys: true,
},

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');

View File

@ -1,3 +1,9 @@
<div>
<b data-i18n="Note:">Note:</b> <span data-i18n="this chat is temporary and will be deleted as soon as you leave it.">this chat is temporary and will be deleted as soon as you leave it.</span>
<div data-type="assistant_note">
<div>
<b data-i18n="Note:">Note:</b> <span data-i18n="this chat is temporary and will be deleted as soon as you leave it.">this chat is temporary and will be deleted as soon as you leave it.</span>
<span>Click the button to save it as a file.</span>
</div>
<div class="assistant_note_export menu_button menu_button_icon" title="Export as JSONL">
<i class="fa-solid fa-file-export"></i>
</div>
</div>

View File

@ -5764,3 +5764,17 @@ body:not(.movingUI) .drawer-content.maximized {
.alternate_greetings_list {
overflow-y: scroll;
}
.mes_text div[data-type="assistant_note"]:has(.assistant_note_export) {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: space-between;
align-items: center;
gap: 10px;
padding: 0 2px;
}
.mes_text div[data-type="assistant_note"]:has(.assistant_note_export)>div:not(.assistant_note_export) {
flex: 1;
}