summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/needs_auth/Bard.py
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2024-01-27 16:09:21 +0100
committerGitHub <noreply@github.com>2024-01-27 16:09:21 +0100
commit0d83bdeef91001c7c00d69f79fccad5a78b4b94b (patch)
tree362ebeb245cc4e123914635b03f890a314a7a40d /g4f/Provider/needs_auth/Bard.py
parentMerge pull request #1512 from KennyPhan123/patch-1 (diff)
parentFix PerplexityLabs Provider, Improve bypass_cloudflare helper (diff)
downloadgpt4free-0d83bdeef91001c7c00d69f79fccad5a78b4b94b.tar
gpt4free-0d83bdeef91001c7c00d69f79fccad5a78b4b94b.tar.gz
gpt4free-0d83bdeef91001c7c00d69f79fccad5a78b4b94b.tar.bz2
gpt4free-0d83bdeef91001c7c00d69f79fccad5a78b4b94b.tar.lz
gpt4free-0d83bdeef91001c7c00d69f79fccad5a78b4b94b.tar.xz
gpt4free-0d83bdeef91001c7c00d69f79fccad5a78b4b94b.tar.zst
gpt4free-0d83bdeef91001c7c00d69f79fccad5a78b4b94b.zip
Diffstat (limited to '')
-rw-r--r--g4f/Provider/needs_auth/Bard.py12
1 files changed, 3 insertions, 9 deletions
diff --git a/g4f/Provider/needs_auth/Bard.py b/g4f/Provider/needs_auth/Bard.py
index 09ed1c3c..73c62edc 100644
--- a/g4f/Provider/needs_auth/Bard.py
+++ b/g4f/Provider/needs_auth/Bard.py
@@ -7,14 +7,14 @@ try:
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
- from selenium.webdriver.common.keys import Keys
except ImportError:
pass
from ...typing import CreateResult, Messages
from ..base_provider import AbstractProvider
from ..helper import format_prompt
-from ...webdriver import WebDriver, WebDriverSession
+from ...webdriver import WebDriver, WebDriverSession, element_send_text
+
class Bard(AbstractProvider):
url = "https://bard.google.com"
@@ -68,13 +68,7 @@ XMLHttpRequest.prototype.open = function(method, url) {
"""
driver.execute_script(script)
- 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)
+ element_send_text(driver.find_element(By.CSS_SELECTOR, "div.ql-editor.textarea"), prompt)
while True:
chunk = driver.execute_script("return window._message;")