From ffb4b0d162cc29b1caa4539d854de37206804225 Mon Sep 17 00:00:00 2001 From: H Lohaus Date: Wed, 20 Nov 2024 19:58:16 +0100 Subject: Improve download of generated images, serve images in the api (#2391) * Improve download of generated images, serve images in the api Add support for conversation handling in the api * Add orginal prompt to image response * Add download images option in gui, fix loading model list in Airforce * Add download images option in gui, fix loading model list in Airforce --- g4f/gui/client/static/js/chat.v1.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'g4f/gui/client/static/js/chat.v1.js') diff --git a/g4f/gui/client/static/js/chat.v1.js b/g4f/gui/client/static/js/chat.v1.js index a3e94ee2..0136f9c4 100644 --- a/g4f/gui/client/static/js/chat.v1.js +++ b/g4f/gui/client/static/js/chat.v1.js @@ -428,10 +428,14 @@ async function add_message_chunk(message, message_id) { p.innerText = message.log; log_storage.appendChild(p); } - window.scrollTo(0, 0); - if (message_box.scrollTop >= message_box.scrollHeight - message_box.clientHeight - 100) { - message_box.scrollTo({ top: message_box.scrollHeight, behavior: "auto" }); + let scroll_down = ()=>{ + if (message_box.scrollTop >= message_box.scrollHeight - message_box.clientHeight - 100) { + window.scrollTo(0, 0); + message_box.scrollTo({ top: message_box.scrollHeight, behavior: "auto" }); + } } + setTimeout(scroll_down, 200); + setTimeout(scroll_down, 1000); } cameraInput?.addEventListener("click", (e) => { @@ -492,6 +496,7 @@ const ask_gpt = async (message_index = -1, message_id) => { const file = input && input.files.length > 0 ? input.files[0] : null; const provider = providerSelect.options[providerSelect.selectedIndex].value; const auto_continue = document.getElementById("auto_continue")?.checked; + const download_images = document.getElementById("download_images")?.checked; let api_key = get_api_key_by_provider(provider); await api("conversation", { id: message_id, @@ -501,13 +506,13 @@ const ask_gpt = async (message_index = -1, message_id) => { provider: provider, messages: messages, auto_continue: auto_continue, + download_images: download_images, api_key: api_key, }, file, message_id); if (!error_storage[message_id]) { html = markdown_render(message_storage[message_id]); content_map.inner.innerHTML = html; highlight(content_map.inner); - if (imageInput) imageInput.value = ""; if (cameraInput) cameraInput.value = ""; if (fileInput) fileInput.value = ""; @@ -1239,8 +1244,7 @@ async function load_version() { if (versions["version"] != versions["latest_version"]) { let release_url = 'https://github.com/xtekky/gpt4free/releases/tag/' + versions["latest_version"]; let title = `New version: ${versions["latest_version"]}`; - text += `${versions["version"]} `; - text += `` + text += `${versions["version"]} 🆕`; } else { text += versions["version"]; } -- cgit v1.2.3