diff options
author | H Lohaus <hlohaus@users.noreply.github.com> | 2023-11-16 19:02:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-16 19:02:53 +0100 |
commit | e0541c513f389cdb1cae97c8d583db529609f96e (patch) | |
tree | dbd1579b23db178c040271a2c61fc4f6ce53a452 /g4f/Provider | |
parent | Update MyShell.py (diff) | |
download | gpt4free-e0541c513f389cdb1cae97c8d583db529609f96e.tar gpt4free-e0541c513f389cdb1cae97c8d583db529609f96e.tar.gz gpt4free-e0541c513f389cdb1cae97c8d583db529609f96e.tar.bz2 gpt4free-e0541c513f389cdb1cae97c8d583db529609f96e.tar.lz gpt4free-e0541c513f389cdb1cae97c8d583db529609f96e.tar.xz gpt4free-e0541c513f389cdb1cae97c8d583db529609f96e.tar.zst gpt4free-e0541c513f389cdb1cae97c8d583db529609f96e.zip |
Diffstat (limited to '')
-rw-r--r-- | g4f/Provider/Phind.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/g4f/Provider/Phind.py b/g4f/Provider/Phind.py index 1499fcb2..7fc935af 100644 --- a/g4f/Provider/Phind.py +++ b/g4f/Provider/Phind.py @@ -26,10 +26,6 @@ class Phind(BaseProvider): hidden_display: bool = True, **kwargs ) -> CreateResult: - from selenium.webdriver.common.by import By - from selenium.webdriver.support.ui import WebDriverWait - from selenium.webdriver.support import expected_conditions as EC - if browser: driver = browser else: @@ -38,6 +34,10 @@ class Phind(BaseProvider): else: driver = get_browser("", False, proxy) + from selenium.webdriver.common.by import By + from selenium.webdriver.support.ui import WebDriverWait + from selenium.webdriver.support import expected_conditions as EC + prompt = quote(format_prompt(messages)) driver.get(f"{cls.url}/search?q={prompt}&source=searchbox") @@ -58,6 +58,7 @@ class Phind(BaseProvider): wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, ".search-container"))) try: + # Fetch hook script = """ window._fetch = window.fetch; window.fetch = (url, options) => { @@ -78,7 +79,7 @@ window.fetch = (url, options) => { if(window.reader) { chunk = await window.reader.read(); if (chunk['done']) return null; - text = await (new Response(chunk['value']).text()); + text = (new TextDecoder()).decode(chunk['value']); content = ''; text.split('\\r\\n').forEach((line, index) => { if (line.startsWith('data: ')) { |