From bee75be8e38d25c4568c641412a49b576d425b24 Mon Sep 17 00:00:00 2001 From: H Lohaus Date: Wed, 10 Jan 2024 10:34:56 +0100 Subject: Add create images to Bing (#1426) Add create images from Bing Add FreeChatgpt Provider Fix Bard Provider --- g4f/Provider/needs_auth/Bard.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'g4f/Provider/needs_auth') diff --git a/g4f/Provider/needs_auth/Bard.py b/g4f/Provider/needs_auth/Bard.py index cf1000c4..aea67874 100644 --- a/g4f/Provider/needs_auth/Bard.py +++ b/g4f/Provider/needs_auth/Bard.py @@ -64,11 +64,14 @@ XMLHttpRequest.prototype.open = function(method, url) { """ driver.execute_script(script) - # Submit prompt - driver.find_element(By.CSS_SELECTOR, "div.ql-editor.textarea").send_keys(prompt) - driver.find_element(By.CSS_SELECTOR, "div.ql-editor.textarea").send_keys(Keys.ENTER) - - # Yield response + textarea = driver.find_element(By.CSS_SELECTOR, "div.ql-editor.textarea") + lines = prompt.splitlines() + for idx, line in enumerate(lines): + textarea.send_keys(line) + if (len(lines) - 1 != idx): + textarea.send_keys(Keys.SHIFT + "\n") + textarea.send_keys(Keys.ENTER) + while True: chunk = driver.execute_script("return window._message;") if chunk: -- cgit v1.2.3