summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2023-11-16 19:28:59 +0100
committerGitHub <noreply@github.com>2023-11-16 19:28:59 +0100
commit29df5a21a8827de41f63217d5e3eb102fb80310e (patch)
treefbb5133d67daba767e62293c4da19fe8b8ab09fe
parentUpdate Phind.py (diff)
downloadgpt4free-29df5a21a8827de41f63217d5e3eb102fb80310e.tar
gpt4free-29df5a21a8827de41f63217d5e3eb102fb80310e.tar.gz
gpt4free-29df5a21a8827de41f63217d5e3eb102fb80310e.tar.bz2
gpt4free-29df5a21a8827de41f63217d5e3eb102fb80310e.tar.lz
gpt4free-29df5a21a8827de41f63217d5e3eb102fb80310e.tar.xz
gpt4free-29df5a21a8827de41f63217d5e3eb102fb80310e.tar.zst
gpt4free-29df5a21a8827de41f63217d5e3eb102fb80310e.zip
Diffstat (limited to '')
-rw-r--r--g4f/Provider/needs_auth/Bard.py19
1 files changed, 7 insertions, 12 deletions
diff --git a/g4f/Provider/needs_auth/Bard.py b/g4f/Provider/needs_auth/Bard.py
index 47c89e20..6cb40c90 100644
--- a/g4f/Provider/needs_auth/Bard.py
+++ b/g4f/Provider/needs_auth/Bard.py
@@ -1,15 +1,10 @@
from __future__ import annotations
import time
-try:
- from selenium.webdriver.remote.webdriver import WebDriver
-except ImportError:
- class WebDriver():
- pass
from ...typing import CreateResult, Messages
from ..base_provider import BaseProvider
-from ..helper import format_prompt, get_browser
+from ..helper import WebDriver, format_prompt, get_browser
class Bard(BaseProvider):
url = "https://bard.google.com"
@@ -24,14 +19,14 @@ class Bard(BaseProvider):
stream: bool,
proxy: str = None,
browser: WebDriver = None,
- display: bool = True,
+ hidden_display: bool = True,
**kwargs
) -> CreateResult:
prompt = format_prompt(messages)
if browser:
driver = browser
else:
- if display:
+ if hidden_display:
driver, display = get_browser(None, True, proxy)
else:
driver = get_browser(None, False, proxy)
@@ -49,7 +44,7 @@ class Bard(BaseProvider):
if not browser:
driver.quit()
# New browser should be visible
- if display:
+ if hidden_display:
display.stop()
driver = get_browser(None, False, proxy)
driver.get(f"{cls.url}/chat")
@@ -74,11 +69,11 @@ XMLHttpRequest.prototype.open = function(method, url) {
"""
driver.execute_script(script)
- # Send prompt
+ # Input and submit prompt
driver.find_element(By.CSS_SELECTOR, "div.ql-editor.ql-blank.textarea").send_keys(prompt)
driver.find_element(By.CSS_SELECTOR, "button.send-button").click()
- # Read response
+ # Yield response
script = "return window._message;"
while True:
chunk = driver.execute_script(script)
@@ -92,5 +87,5 @@ XMLHttpRequest.prototype.open = function(method, url) {
if not browser:
time.sleep(0.1)
driver.quit()
- if display:
+ if hidden_display:
display.stop() \ No newline at end of file