From 00951eb79114adf74ad1a3f1ce596e9e0fa932bf Mon Sep 17 00:00:00 2001 From: H Lohaus Date: Wed, 10 Apr 2024 08:14:50 +0200 Subject: Add OpenRouter and DeepInfraImage Provider (#1814) --- g4f/gui/client/static/css/style.css | 10 +++++++--- g4f/gui/client/static/js/chat.v1.js | 32 ++++++++++++++++++-------------- 2 files changed, 25 insertions(+), 17 deletions(-) (limited to 'g4f/gui/client/static') diff --git a/g4f/gui/client/static/css/style.css b/g4f/gui/client/static/css/style.css index 32fff3db..8e967806 100644 --- a/g4f/gui/client/static/css/style.css +++ b/g4f/gui/client/static/css/style.css @@ -109,7 +109,7 @@ body { } .conversations { - max-width: 280px; + max-width: 300px; padding: var(--section-gap); overflow: auto; flex-shrink: 0; @@ -207,9 +207,9 @@ body { gap: 4px; } -.conversations .convo .fa-trash { +.conversations .convo .fa-ellipsis-vertical { position: absolute; - right: 8px; + right: 14px; } .conversations .convo .choise { @@ -1075,6 +1075,10 @@ a:-webkit-any-link { resize: vertical; } +.settings textarea { + height: 51px; +} + .settings { width: 100%; display: flex; diff --git a/g4f/gui/client/static/js/chat.v1.js b/g4f/gui/client/static/js/chat.v1.js index 5036a93b..628d0682 100644 --- a/g4f/gui/client/static/js/chat.v1.js +++ b/g4f/gui/client/static/js/chat.v1.js @@ -42,7 +42,7 @@ appStorage = window.localStorage || { const markdown = window.markdownit(); const markdown_render = (content) => { return markdown.render(content - .replaceAll(/[\s\S]+/gm, "") + .replaceAll(/|/gm, "") .replaceAll(//gm, "") ) .replaceAll(" { container.classList.add("audio"); container.appendChild(sound); content_el.appendChild(container); + if (ended && !stopped) { + sound.play(); + } } if (lines.length < 1 || stopped) { el.classList.remove("active"); @@ -608,12 +608,11 @@ async function get_messages(conversation_id) { } async function add_conversation(conversation_id, content) { - if (content.length > 17) { - title = content.substring(0, 17) + '...' + if (content.length > 18) { + title = content.substring(0, 18) + '...' } else { - title = content + ' '.repeat(19 - content.length) + title = content + ' '.repeat(20 - content.length) } - if (appStorage.getItem(`conversation:${conversation_id}`) == null) { await save_conversation(conversation_id, { id: conversation_id, @@ -623,7 +622,6 @@ async function add_conversation(conversation_id, content) { items: [], }); } - history.pushState({}, null, `/chat/${conversation_id}`); } @@ -695,27 +693,31 @@ const load_conversations = async () => { await clear_conversations(); - for (conversation of conversations) { + conversations.sort((a, b) => (b.updated||0)-(a.updated||0)); + + let html = ""; + conversations.forEach((conversation) => { let updated = ""; if (conversation.updated) { const date = new Date(conversation.updated); updated = date.toLocaleString('en-GB', {dateStyle: 'short', timeStyle: 'short', monthStyle: 'short'}); updated = updated.replace("/" + date.getFullYear(), "") } - box_conversations.innerHTML += ` + html += `
${updated} ${conversation.title}
- +
`; - } + }); + box_conversations.innerHTML = html; }; document.getElementById("cancelButton").addEventListener("click", async () => { @@ -804,6 +806,7 @@ const register_settings_storage = async () => { appStorage.setItem(element.id, element.selectedIndex); break; case "text": + case "number": appStorage.setItem(element.id, element.value); break; default: @@ -828,6 +831,7 @@ const load_settings_storage = async () => { element.selectedIndex = parseInt(value); break; case "text": + case "number": case "textarea": element.value = value; break; -- cgit v1.2.3