Exportable temporary assistant chats

6aaeb754efbec318f179c695202b6471934d7589

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

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