mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2025-01-27 12:33:17 +01:00
Add a "refresh" button below the last message, add a missing file
This commit is contained in:
parent
a5d64b586d
commit
1b9121e5b8
29
css/main.css
29
css/main.css
@ -1236,11 +1236,10 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.copy-button {
|
||||
.footer-button {
|
||||
position: absolute;
|
||||
bottom: -23px;
|
||||
left: 0;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
border: none;
|
||||
border-radius: 3px;
|
||||
cursor: pointer;
|
||||
@ -1250,25 +1249,35 @@ div.svelte-362y77>*, div.svelte-362y77>.form>* {
|
||||
transition: opacity 0.2s;
|
||||
}
|
||||
|
||||
.message:hover .copy-button,
|
||||
.user-message:hover .copy-button,
|
||||
.assistant-message:hover .copy-button {
|
||||
.footer-button#copy-button {
|
||||
bottom: -23px;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.footer-button#refresh-button {
|
||||
bottom: -23px;
|
||||
left: 25px;
|
||||
}
|
||||
|
||||
.message:hover .footer-button,
|
||||
.user-message:hover .footer-button,
|
||||
.assistant-message:hover .footer-button {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.copy-button svg {
|
||||
.footer-button svg {
|
||||
stroke: rgb(156 163 175);
|
||||
transition: stroke 0.2s;
|
||||
}
|
||||
|
||||
.copy-button:hover svg {
|
||||
.footer-button:hover svg {
|
||||
stroke: rgb(107 114 128);
|
||||
}
|
||||
|
||||
.dark .copy-button svg {
|
||||
.dark .footer-button svg {
|
||||
stroke: rgb(156 163 175);
|
||||
}
|
||||
|
||||
.dark .copy-button:hover svg {
|
||||
.dark .footer-button:hover svg {
|
||||
stroke: rgb(209 213 219);
|
||||
}
|
||||
|
23
js/global_scope_js.js
Normal file
23
js/global_scope_js.js
Normal file
@ -0,0 +1,23 @@
|
||||
function copyToClipboard(element) {
|
||||
if (!element) return;
|
||||
|
||||
const messageElement = element.closest(".message, .user-message, .assistant-message");
|
||||
if (!messageElement) return;
|
||||
|
||||
const rawText = messageElement.getAttribute("data-raw");
|
||||
if (!rawText) return;
|
||||
|
||||
navigator.clipboard.writeText(rawText).then(function() {
|
||||
const originalSvg = element.innerHTML;
|
||||
element.innerHTML = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"text-green-500 dark:text-green-400\"><path d=\"M5 12l5 5l10 -10\"></path></svg>";
|
||||
setTimeout(() => {
|
||||
element.innerHTML = originalSvg;
|
||||
}, 1000);
|
||||
}).catch(function(err) {
|
||||
console.error("Failed to copy text: ", err);
|
||||
});
|
||||
}
|
||||
|
||||
function regenerateClick() {
|
||||
document.getElementById("Regenerate").click();
|
||||
}
|
@ -293,7 +293,9 @@ def get_image_cache(path):
|
||||
|
||||
|
||||
copy_svg = '''<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="tabler-icon tabler-icon-copy"><path d="M8 8m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z"></path><path d="M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"></path></svg>'''
|
||||
copy_button = f'<button class="copy-button" onclick="copyToClipboard(this)">{copy_svg}</button>'
|
||||
refresh_svg = '''<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="tabler-icon tabler-icon-repeat"><path d="M4 12v-3a3 3 0 0 1 3 -3h13m-3 -3l3 3l-3 3"></path><path d="M20 12v3a3 3 0 0 1 -3 3h-13m3 3l-3 -3l3 -3"></path></svg>'''
|
||||
copy_button = f'<button class="footer-button" id="copy-button" onclick="copyToClipboard(this)">{copy_svg}</button>'
|
||||
refresh_button = f'<button class="footer-button" id="refresh-button" onclick="regenerateClick()">{refresh_svg}</button>'
|
||||
|
||||
def generate_instruct_html(history):
|
||||
output = f'<style>{instruct_css}</style><div class="chat" id="chat"><div class="messages">'
|
||||
@ -320,6 +322,7 @@ def generate_instruct_html(history):
|
||||
f'<div class="text">'
|
||||
f'<div class="message-body">{converted_visible[1]}</div>'
|
||||
f'{copy_button}'
|
||||
f'{refresh_button if i == len(history["visible"]) - 1 else ""}'
|
||||
f'</div>'
|
||||
f'</div>'
|
||||
)
|
||||
@ -368,6 +371,7 @@ def generate_cai_chat_html(history, name1, name2, style, character, reset_cache=
|
||||
f'<div class="username">{name2}</div>'
|
||||
f'<div class="message-body">{converted_visible[1]}</div>'
|
||||
f'{copy_button}'
|
||||
f'{refresh_button if i == len(history["visible"]) - 1 else ""}'
|
||||
f'</div>'
|
||||
f'</div>'
|
||||
)
|
||||
@ -401,6 +405,7 @@ def generate_chat_html(history, name1, name2, reset_cache=False):
|
||||
f'<div class="text-bot">'
|
||||
f'<div class="message-body">{converted_visible[1]}</div>'
|
||||
f'{copy_button}'
|
||||
f'{refresh_button if i == len(history["visible"]) - 1 else ""}'
|
||||
f'</div>'
|
||||
f'</div>'
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user