From a7c856592213c8a8c7a6ef3b30cccf2ede6a9636 Mon Sep 17 00:00:00 2001 From: Heiner Lohaus Date: Fri, 12 Jan 2024 02:14:35 +0100 Subject: Add publish-to-pypi workflow Improve gui frontend Fix web search in bing --- g4f/Provider/Bing.py | 6 +++++- g4f/gui/client/css/style.css | 1 + g4f/gui/client/html/index.html | 2 +- g4f/gui/client/js/chat.v1.js | 15 +++++++-------- 4 files changed, 14 insertions(+), 10 deletions(-) (limited to 'g4f') diff --git a/g4f/Provider/Bing.py b/g4f/Provider/Bing.py index 18a6040b..b0949397 100644 --- a/g4f/Provider/Bing.py +++ b/g4f/Provider/Bing.py @@ -33,7 +33,7 @@ class Bing(AsyncGeneratorProvider): proxy: str = None, timeout: int = 900, cookies: dict = None, - tone: str = Tones.creative, + tone: str = Tones.balanced, image: str = None, web_search: bool = False, **kwargs @@ -212,7 +212,11 @@ def create_message( 'requestId': request_id, 'messageId': request_id, }}, + "verbosity": "verbose", "scenario": "SERP", + "plugins":[ + {"id":"c310c353-b9f0-4d76-ab0d-1dd5e979cf68", "category": 1} + ] if web_search else [], 'tone': tone, 'spokenTextMode': 'None', 'conversationId': conversation.conversationId, diff --git a/g4f/gui/client/css/style.css b/g4f/gui/client/css/style.css index e619b409..3e2d6d6f 100644 --- a/g4f/gui/client/css/style.css +++ b/g4f/gui/client/css/style.css @@ -485,6 +485,7 @@ select { padding: 8px 16px; appearance: none; + width: 250px; } .input-box { diff --git a/g4f/gui/client/html/index.html b/g4f/gui/client/html/index.html index b47f2a37..bc41bd45 100644 --- a/g4f/gui/client/html/index.html +++ b/g4f/gui/client/html/index.html @@ -168,7 +168,7 @@
- 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( - /[\s\S]+/m, + messages[i]["content"] = messages[i]["content"].replaceAll( + /[\s\S]+/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`,`?`] -- cgit v1.2.3