From 90715e702bbebcf2c3cfd39628c931bbadda28b0 Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Tue, 9 Apr 2024 19:19:33 +0200 Subject: Add project files --- g4f/Provider/Bing.py | 3 +++ g4f/gui/client/index.html | 4 ++-- g4f/gui/client/static/js/chat.v1.js | 10 ++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) (limited to 'g4f') diff --git a/g4f/Provider/Bing.py b/g4f/Provider/Bing.py index aa1b37b0..1e462084 100644 --- a/g4f/Provider/Bing.py +++ b/g4f/Provider/Bing.py @@ -46,6 +46,7 @@ class Bing(AsyncGeneratorProvider, ProviderModelMixin): messages: Messages, proxy: str = None, timeout: int = 900, + api_key: str = None, cookies: Cookies = None, connector: BaseConnector = None, tone: str = None, @@ -68,6 +69,8 @@ class Bing(AsyncGeneratorProvider, ProviderModelMixin): :return: An asynchronous result object. """ prompt = messages[-1]["content"] + if api_key is not None: + cookies["_U"] = api_key if context is None: context = create_context(messages[:-1]) if len(messages) > 1 else None if tone is None: diff --git a/g4f/gui/client/index.html b/g4f/gui/client/index.html index b3cadd19..d6ad5241 100644 --- a/g4f/gui/client/index.html +++ b/g4f/gui/client/index.html @@ -125,8 +125,8 @@
- - + +
diff --git a/g4f/gui/client/static/js/chat.v1.js b/g4f/gui/client/static/js/chat.v1.js index 0aa601e8..02437bf7 100644 --- a/g4f/gui/client/static/js/chat.v1.js +++ b/g4f/gui/client/static/js/chat.v1.js @@ -95,10 +95,14 @@ const register_message_buttons = async () => { if (!("click" in el.dataset)) { el.dataset.click = "true"; el.addEventListener("click", async () => { - if ("active" in el.classList || window.doSpeech || stopped) { + if ("active" in el.classList || window.doSpeech) { stopped = true; return; } + if (stopped) { + stopped = false; + return; + } el.classList.add("blink") el.classList.add("active") const message_el = el.parentElement.parentElement.parentElement; @@ -106,7 +110,6 @@ const register_message_buttons = async () => { let speechText = await get_message(window.conversation_id, message_el.dataset.index); speechText = speechText.replaceAll(/\[(.+)\]\(.+\)/gm, "($1)"); - speechText = speechText.replaceAll(/\(http.+\)/gm, ""); speechText = speechText.replaceAll("`", "").replaceAll("#", "") speechText = speechText.replaceAll( /[\s\S]+/gm, @@ -116,6 +119,7 @@ const register_message_buttons = async () => { const lines = speechText.trim().split(/\n|\.|;/); let ended = true; window.onSpeechResponse = (url) => { + el.classList.remove("blink") if (url) { var sound = document.createElement('audio'); sound.controls = 'controls'; @@ -136,7 +140,6 @@ const register_message_buttons = async () => { content_el.appendChild(container); } if (lines.length < 1 || stopped) { - el.classList.remove("blink"); el.classList.remove("active"); return; } @@ -148,7 +151,6 @@ const register_message_buttons = async () => { } } if (!line) { - el.classList.remove("blink") el.classList.remove("active") } } -- cgit v1.2.3