summaryrefslogtreecommitdiffstats
path: root/g4f/Provider
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2023-11-16 19:24:15 +0100
committerGitHub <noreply@github.com>2023-11-16 19:24:15 +0100
commit79c9051743433fe1953c8b196c1c0480aab07392 (patch)
tree61d9d71928b2313994e18c9cb5e154bf2e101405 /g4f/Provider
parentUpdate Phind.py (diff)
downloadgpt4free-79c9051743433fe1953c8b196c1c0480aab07392.tar
gpt4free-79c9051743433fe1953c8b196c1c0480aab07392.tar.gz
gpt4free-79c9051743433fe1953c8b196c1c0480aab07392.tar.bz2
gpt4free-79c9051743433fe1953c8b196c1c0480aab07392.tar.lz
gpt4free-79c9051743433fe1953c8b196c1c0480aab07392.tar.xz
gpt4free-79c9051743433fe1953c8b196c1c0480aab07392.tar.zst
gpt4free-79c9051743433fe1953c8b196c1c0480aab07392.zip
Diffstat (limited to 'g4f/Provider')
-rw-r--r--g4f/Provider/Phind.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/g4f/Provider/Phind.py b/g4f/Provider/Phind.py
index 7fc935af..2612a92d 100644
--- a/g4f/Provider/Phind.py
+++ b/g4f/Provider/Phind.py
@@ -41,39 +41,46 @@ class Phind(BaseProvider):
prompt = quote(format_prompt(messages))
driver.get(f"{cls.url}/search?q={prompt}&source=searchbox")
+ # Need to change settinge
if model.startswith("gpt-4") or creative_mode:
wait = WebDriverWait(driver, timeout)
- # Open dropdown
+ # Open settings dropdown
wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "button.text-dark.dropdown-toggle")))
driver.find_element(By.CSS_SELECTOR, "button.text-dark.dropdown-toggle").click()
- # Enable GPT-4
+ # Wait for dropdown toggle
wait.until(EC.visibility_of_element_located((By.XPATH, "//button[text()='GPT-4']")))
+ # Enable GPT-4
if model.startswith("gpt-4"):
driver.find_element(By.XPATH, "//button[text()='GPT-4']").click()
# Enable creative mode
if creative_mode or creative_mode == None:
driver.find_element(By.ID, "Creative Mode").click()
- # Submit question
+ # Submit changes
driver.find_element(By.CSS_SELECTOR, ".search-bar-input-group button[type='submit']").click()
+ # Wait for page reload
wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, ".search-container")))
try:
- # Fetch hook
+ # Add fetch hook
script = """
window._fetch = window.fetch;
window.fetch = (url, options) => {
+ // Call parent fetch method
const result = window._fetch(url, options);
if (url != "/api/infer/answer") return result;
+ // Load response reader
result.then((response) => {
if (!response.body.locked) {
window.reader = response.body.getReader();
}
});
+ // Return dummy response
return new Promise((resolve, reject) => {
resolve(new Response(new ReadableStream()))
});
}
"""
+ # Read response from reader
driver.execute_script(script)
script = """
if(window.reader) {