summaryrefslogtreecommitdiffstats
path: root/g4f/gui/client
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2024-02-25 10:03:27 +0100
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2024-02-25 10:03:27 +0100
commit84b3a19c9de9168f9eaf769f63e19d30c66f3ddd (patch)
treeb8bc629fcf39a4a21ef437feafdcc22dd943044c /g4f/gui/client
parentCustom api_base for GeminiPro (diff)
downloadgpt4free-84b3a19c9de9168f9eaf769f63e19d30c66f3ddd.tar
gpt4free-84b3a19c9de9168f9eaf769f63e19d30c66f3ddd.tar.gz
gpt4free-84b3a19c9de9168f9eaf769f63e19d30c66f3ddd.tar.bz2
gpt4free-84b3a19c9de9168f9eaf769f63e19d30c66f3ddd.tar.lz
gpt4free-84b3a19c9de9168f9eaf769f63e19d30c66f3ddd.tar.xz
gpt4free-84b3a19c9de9168f9eaf769f63e19d30c66f3ddd.tar.zst
gpt4free-84b3a19c9de9168f9eaf769f63e19d30c66f3ddd.zip
Diffstat (limited to 'g4f/gui/client')
-rw-r--r--g4f/gui/client/js/chat.v1.js16
1 files changed, 10 insertions, 6 deletions
diff --git a/g4f/gui/client/js/chat.v1.js b/g4f/gui/client/js/chat.v1.js
index 9585ca98..e5b2d653 100644
--- a/g4f/gui/client/js/chat.v1.js
+++ b/g4f/gui/client/js/chat.v1.js
@@ -268,6 +268,11 @@ const ask_gpt = async () => {
}
}
if (!error) {
+ // Remove cursor
+ html = markdown_render(text);
+ content_inner.innerHTML = html;
+ highlight(content_inner);
+
if (imageInput) imageInput.value = "";
if (cameraInput) cameraInput.value = "";
if (fileInput) fileInput.value = "";
@@ -275,20 +280,19 @@ const ask_gpt = async () => {
} catch (e) {
console.error(e);
- if (e.name != `AbortError`) {
- text = `oops ! something went wrong, please try again / reload. [stacktrace in console]`;
+ if (e.name != "AbortError") {
+ error = true;
+ text = "oops ! something went wrong, please try again / reload. [stacktrace in console]";
content_inner.innerHTML = text;
} else {
content_inner.innerHTML += ` [aborted]`;
text += ` [aborted]`
}
}
- let cursorDiv = document.getElementById(`cursor`);
- if (cursorDiv) cursorDiv.parentNode.removeChild(cursorDiv);
- if (text) {
+ if (!error) {
await add_message(window.conversation_id, "assistant", text, provider);
+ await load_conversation(window.conversation_id);
}
- await load_conversation(window.conversation_id);
message_box.scrollTop = message_box.scrollHeight;
await remove_cancel_button();
await register_remove_message();