Exportable temporary assistant chats
| @@ -724,6 +724,7 @@ async function getSystemMessages() { | ||
| 724 | 724 | is_user: false, |
| 725 | 725 | is_system: true, |
| 726 | 726 | mes: await renderTemplateAsync('assistantNote'), |
| 727 | + uses_system_ui: true, | |
| 727 | 728 | extra: { |
| 728 | 729 | isSmallSys: true, |
| 729 | 730 | }, |
| @@ -11,6 +11,7 @@ import { | ||
| 11 | 11 | getCurrentChatId, |
| 12 | 12 | getRequestHeaders, |
| 13 | 13 | hideSwipeButtons, |
| 14 | + name1, | |
| 14 | 15 | name2, |
| 15 | 16 | reloadCurrentChat, |
| 16 | 17 | saveChatDebounced, |
| @@ -21,6 +22,7 @@ import { | ||
| 21 | 22 | chat_metadata, |
| 22 | 23 | neutralCharacterName, |
| 23 | 24 | updateChatMetadata, |
| 25 | + system_message_types, | |
| 24 | 26 | } from '../script.js'; |
| 25 | 27 | import { selected_group } from './group-chats.js'; |
| 26 | 28 | import { power_user } from './power-user.js'; |
| @@ -34,6 +36,7 @@ import { | ||
| 34 | 36 | humanFileSize, |
| 35 | 37 | saveBase64AsFile, |
| 36 | 38 | extractTextFromOffice, |
| 39 | + download, | |
| 37 | 40 | } from './utils.js'; |
| 38 | 41 | import { extension_settings, renderExtensionTemplateAsync, saveMetadataDebounced } from './extensions.js'; |
| 39 | 42 | import { POPUP_RESULT, POPUP_TYPE, Popup, callGenericPopup } from './popup.js'; |
| @@ -41,6 +44,7 @@ import { ScraperManager } from './scrapers.js'; | ||
| 41 | 44 | import { DragAndDropHandler } from './dragdrop.js'; |
| 42 | 45 | import { renderTemplateAsync } from './templates.js'; |
| 43 | 46 | import { t } from './i18n.js'; |
| 47 | +import { humanizedDateTime } from './RossAscends-mods.js'; | |
| 44 | 48 | |
| 45 | 49 | /** |
| 46 | 50 | * @typedef {Object} FileAttachment |
| @@ -1437,6 +1441,19 @@ jQuery(function () { | ||
| 1437 | 1441 | await viewMessageFile(messageId); |
| 1438 | 1442 | }); |
| 1439 | 1443 | |
| 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 | + | |
| 1440 | 1457 | // Do not change. #attachFile is added by extension. |
| 1441 | 1458 | $(document).on('click', '#attachFile', function () { |
| 1442 | 1459 | $('#file_form_input').trigger('click'); |
| @@ -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> | |
| 3 | 9 | </div> |
| @@ -5764,3 +5764,17 @@ body:not(.movingUI) .drawer-content.maximized { | ||
| 5764 | 5764 | .alternate_greetings_list { |
| 5765 | 5765 | overflow-y: scroll; |
| 5766 | 5766 | } |
| 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 | +} | |