| 1107 | 1107 | returns: ARGUMENT_TYPE.STRING, |
| 1108 | 1108 | })); |
| 1109 | 1109 | |
| 1110 | + const summaryMacroHandler = () => { |
| 1111 | + // Checking content of the UI summary box first |
| 1112 | + const uiSummary = $('#memory_contents').val().toString(); |
| 1113 | + if (uiSummary.trim().length > 0) { |
| 1114 | + return uiSummary; |
| 1115 | + } |
| 1116 | + // Fallback to scanning the chat for the latest summary if the UI summary box is empty |
| 1117 | + return getLatestMemoryFromChat(getContext().chat); |
| 1118 | + }; |
| 1110 | 1119 | if (power_user.experimental_macro_engine) { |
| 1111 | 1120 | macros.register('summary', { |
| 1112 | 1121 | category: MacroCategory.CHAT, |
| 1113 | 1122 | description: 'Returns the latest memory/summary from the current chat.', |
| 1114 | 1123 | handler: () => getLatestMemoryFromChat(getContextsummaryMacroHandler().chat), |
| 1115 | 1124 | }); |
| 1116 | 1125 | } else { |
| 1117 | 1126 | // TODO: Remove this when the experimental macro engine is replacing the old macro engine |
| 1118 | 1127 | MacrosParser.registerMacro('summary', |
| 1119 | 1128 | () => getLatestMemoryFromChat(getContextsummaryMacroHandler().chat), |
| 1120 | 1129 | 'Returns the latest memory/summary from the current chat.'); |
| 1121 | 1130 | } |
| 1122 | 1131 | }); |