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_user: false,
is_system: true, is_system: true,
mes: await renderTemplateAsync('assistantNote'), mes: await renderTemplateAsync('assistantNote'),
uses_system_ui: true,
extra: { extra: {
isSmallSys: true, isSmallSys: true,
}, },

View File

@@ -11,6 +11,7 @@ import {
getCurrentChatId, getCurrentChatId,
getRequestHeaders, getRequestHeaders,
hideSwipeButtons, hideSwipeButtons,
name1,
name2, name2,
reloadCurrentChat, reloadCurrentChat,
saveChatDebounced, saveChatDebounced,
@@ -21,6 +22,7 @@ import {
chat_metadata, chat_metadata,
neutralCharacterName, neutralCharacterName,
updateChatMetadata, updateChatMetadata,
system_message_types,
} from '../script.js'; } from '../script.js';
import { selected_group } from './group-chats.js'; import { selected_group } from './group-chats.js';
import { power_user } from './power-user.js'; import { power_user } from './power-user.js';
@@ -34,6 +36,7 @@ import {
humanFileSize, humanFileSize,
saveBase64AsFile, saveBase64AsFile,
extractTextFromOffice, extractTextFromOffice,
download,
} from './utils.js'; } from './utils.js';
import { extension_settings, renderExtensionTemplateAsync, saveMetadataDebounced } from './extensions.js'; import { extension_settings, renderExtensionTemplateAsync, saveMetadataDebounced } from './extensions.js';
import { POPUP_RESULT, POPUP_TYPE, Popup, callGenericPopup } from './popup.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 { DragAndDropHandler } from './dragdrop.js';
import { renderTemplateAsync } from './templates.js'; import { renderTemplateAsync } from './templates.js';
import { t } from './i18n.js'; import { t } from './i18n.js';
import { humanizedDateTime } from './RossAscends-mods.js';
/** /**
* @typedef {Object} FileAttachment * @typedef {Object} FileAttachment
@@ -1437,6 +1441,19 @@ jQuery(function () {
await viewMessageFile(messageId); 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. // Do not change. #attachFile is added by extension.
$(document).on('click', '#attachFile', function () { $(document).on('click', '#attachFile', function () {
$('#file_form_input').trigger('click'); $('#file_form_input').trigger('click');

View File

@@ -1,3 +1,9 @@
<div> <div data-type="assistant_note">
<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>
<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> </div>

View File

@@ -5764,3 +5764,17 @@ body:not(.movingUI) .drawer-content.maximized {
.alternate_greetings_list { .alternate_greetings_list {
overflow-y: scroll; 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;
}