Exportable temporary assistant chats

6aaeb754efbec318f179c695202b6471934d7589

Cohee <18619528+Cohee1207@users.noreply.github.com>

4 files changed, +40 -2Ignore whitespace
public/script.js+1 -0
@@ -724,6 +724,7 @@ async function getSystemMessages() {
724724 is_user: false,
725725 is_system: true,
726726 mes: await renderTemplateAsync('assistantNote'),
727+ uses_system_ui: true,
727728 extra: {
728729 isSmallSys: true,
729730 },
public/scripts/chats.js+17 -0
@@ -11,6 +11,7 @@ import {
1111 getCurrentChatId,
1212 getRequestHeaders,
1313 hideSwipeButtons,
14+ name1,
1415 name2,
1516 reloadCurrentChat,
1617 saveChatDebounced,
@@ -21,6 +22,7 @@ import {
2122 chat_metadata,
2223 neutralCharacterName,
2324 updateChatMetadata,
25+ system_message_types,
2426} from '../script.js';
2527import { selected_group } from './group-chats.js';
2628import { power_user } from './power-user.js';
@@ -34,6 +36,7 @@ import {
3436 humanFileSize,
3537 saveBase64AsFile,
3638 extractTextFromOffice,
39+ download,
3740} from './utils.js';
3841import { extension_settings, renderExtensionTemplateAsync, saveMetadataDebounced } from './extensions.js';
3942import { POPUP_RESULT, POPUP_TYPE, Popup, callGenericPopup } from './popup.js';
@@ -41,6 +44,7 @@ import { ScraperManager } from './scrapers.js';
4144import { DragAndDropHandler } from './dragdrop.js';
4245import { renderTemplateAsync } from './templates.js';
4346import { t } from './i18n.js';
47+import { humanizedDateTime } from './RossAscends-mods.js';
4448
4549/**
4650 * @typedef {Object} FileAttachment
@@ -1437,6 +1441,19 @@ jQuery(function () {
14371441 await viewMessageFile(messageId);
14381442 });
14391443
1444+ $(document).on('click', '.assistant_note_export', async function () {
1445+ const chatToSave = [
1446+ {
1447+ user_name: name1,
1448+ character_name: name2,
1449+ chat_metadata: chat_metadata,
1450+ },
1451+ ...chat.filter(x => x?.extra?.type !== system_message_types.ASSISTANT_NOTE),
1452+ ];
1453+
1454+ download(JSON.stringify(chatToSave, null, 4), `Assistant - ${humanizedDateTime()}.json`, 'application/json');
1455+ });
1456+
14401457 // Do not change. #attachFile is added by extension.
14411458 $(document).on('click', '#attachFile', function () {
14421459 $('#file_form_input').trigger('click');
public/scripts/templates/assistantNote.html+8 -2
@@ -1,3 +1,9 @@
1-<div>
1+<div data-type="assistant_note">
2- <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>
2+ <div>
3+ <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>
4+ <span>Click the button to save it as a file.</span>
5+ </div>
6+ <div class="assistant_note_export menu_button menu_button_icon" title="Export as JSONL">
7+ <i class="fa-solid fa-file-export"></i>
8+ </div>
39</div>
public/style.css+14 -0
@@ -5764,3 +5764,17 @@ body:not(.movingUI) .drawer-content.maximized {
57645764.alternate_greetings_list {
57655765 overflow-y: scroll;
57665766}
5767+
5768+.mes_text div[data-type="assistant_note"]:has(.assistant_note_export) {
5769+ display: flex;
5770+ flex-direction: row;
5771+ flex-wrap: nowrap;
5772+ justify-content: space-between;
5773+ align-items: center;
5774+ gap: 10px;
5775+ padding: 0 2px;
5776+}
5777+
5778+.mes_text div[data-type="assistant_note"]:has(.assistant_note_export)>div:not(.assistant_note_export) {
5779+ flex: 1;
5780+}