diff options
author | Tekky <98614666+xtekky@users.noreply.github.com> | 2024-01-12 12:51:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-12 12:51:25 +0100 |
commit | 4b5fffc26599b7933c9813f2f7d860adac4e1014 (patch) | |
tree | 3e3a7bc5183ff08fb5a176efeb61264c87c49ece /g4f/gui/client/js/chat.v1.js | |
parent | ~ | g4f v-0.2.0.1 (diff) | |
parent | Merge branch 'main' into pypi (diff) | |
download | gpt4free-4b5fffc26599b7933c9813f2f7d860adac4e1014.tar gpt4free-4b5fffc26599b7933c9813f2f7d860adac4e1014.tar.gz gpt4free-4b5fffc26599b7933c9813f2f7d860adac4e1014.tar.bz2 gpt4free-4b5fffc26599b7933c9813f2f7d860adac4e1014.tar.lz gpt4free-4b5fffc26599b7933c9813f2f7d860adac4e1014.tar.xz gpt4free-4b5fffc26599b7933c9813f2f7d860adac4e1014.tar.zst gpt4free-4b5fffc26599b7933c9813f2f7d860adac4e1014.zip |
Diffstat (limited to 'g4f/gui/client/js/chat.v1.js')
-rw-r--r-- | g4f/gui/client/js/chat.v1.js | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/g4f/gui/client/js/chat.v1.js b/g4f/gui/client/js/chat.v1.js index 9d49d24e..fffe9fe9 100644 --- a/g4f/gui/client/js/chat.v1.js +++ b/g4f/gui/client/js/chat.v1.js @@ -73,8 +73,8 @@ const ask_gpt = async () => { // Remove generated images from history for (i in messages) { - messages[i]["content"] = messages[i]["content"].replace( - /<!-- generated images start -->[\s\S]+<!-- generated images end -->/m, + messages[i]["content"] = messages[i]["content"].replaceAll( + /<!-- generated images start -->[\s\S]+<!-- generated images end -->/gm, "" ) delete messages[i]["provider"]; @@ -318,7 +318,7 @@ const get_conversation = async (conversation_id) => { const get_messages = async (conversation_id) => { let conversation = await get_conversation(conversation_id); - return conversation.items; + return conversation?.items || []; }; const add_conversation = async (conversation_id, content) => { @@ -463,9 +463,8 @@ const register_settings_localstorage = async () => { }; const load_settings_localstorage = async () => { - settings_ids = ["switch", "model", "jailbreak", "patch", "provider"]; - settings_elements = settings_ids.map((id) => document.getElementById(id)); - settings_elements.map((element) => { + for (id of ["switch", "model", "jailbreak", "patch", "provider"]) { + element = document.getElementById(id); if (localStorage.getItem(element.id)) { switch (element.type) { case "checkbox": @@ -478,8 +477,8 @@ const load_settings_localstorage = async () => { console.warn("Unresolved element type"); } } - }); -}; + } +} const say_hello = async () => { tokens = [`Hello`, `!`, ` How`,` can`, ` I`,` assist`,` you`,` today`,`?`] |