diff --git a/public/index.html b/public/index.html index e1b055692..1286e7f4c 100644 --- a/public/index.html +++ b/public/index.html @@ -6232,6 +6232,7 @@
Reasoning +
diff --git a/public/scripts/chats.js b/public/scripts/chats.js index 94ad882bb..e30b090ed 100644 --- a/public/scripts/chats.js +++ b/public/scripts/chats.js @@ -37,6 +37,7 @@ import { saveBase64AsFile, extractTextFromOffice, download, + copyText, } from './utils.js'; import { extension_settings, renderExtensionTemplateAsync, saveMetadataDebounced } from './extensions.js'; import { POPUP_RESULT, POPUP_TYPE, Popup, callGenericPopup } from './popup.js'; @@ -1567,6 +1568,25 @@ jQuery(function () { $(document).on('click', '.mes_img_enlarge', enlargeMessageImage); $(document).on('click', '.mes_img_delete', deleteMessageImage); + $(document).on('click', '.mes_reasoning_copy', (e) => { + e.stopPropagation(); + e.preventDefault(); + }); + + $(document).on('pointerup', '.mes_reasoning_copy', async function () { + const mesBlock = $(this).closest('.mes'); + const mesId = mesBlock.attr('mesid'); + const message = chat[mesId]; + const reasoning = message?.extra?.reasoning; + + if (!reasoning) { + return; + } + + await copyText(reasoning); + toastr.info(t`Copied!`, '', { timeOut: 2000 }); + }); + $('#file_form_input').on('change', async () => { const fileInput = document.getElementById('file_form_input'); if (!(fileInput instanceof HTMLInputElement)) return; diff --git a/public/style.css b/public/style.css index 52c7c55fd..580117d8a 100644 --- a/public/style.css +++ b/public/style.css @@ -345,6 +345,17 @@ input[type='checkbox']:focus-visible { .mes_reasoning_summary { cursor: pointer; + position: relative; +} + +.mes_reasoning_details:not([open]) .mes_reasoning_copy { + display: none; +} + +.mes_reasoning_copy { + position: absolute; + right: 0; + top: 0; } .mes_reasoning_summary > span {