diff options
author | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2023-11-18 04:38:31 +0100 |
---|---|---|
committer | Heiner Lohaus <hlohaus@users.noreply.github.com> | 2023-11-18 04:38:31 +0100 |
commit | cadc507fad2fee59b23d1d8e73c472c077f468fc (patch) | |
tree | 42b1c0c0ccf5e3aa7a843a3766d4d19b6a7ade8e /g4f/Provider/AItianhuSpace.py | |
parent | Improve providers (diff) | |
download | gpt4free-cadc507fad2fee59b23d1d8e73c472c077f468fc.tar gpt4free-cadc507fad2fee59b23d1d8e73c472c077f468fc.tar.gz gpt4free-cadc507fad2fee59b23d1d8e73c472c077f468fc.tar.bz2 gpt4free-cadc507fad2fee59b23d1d8e73c472c077f468fc.tar.lz gpt4free-cadc507fad2fee59b23d1d8e73c472c077f468fc.tar.xz gpt4free-cadc507fad2fee59b23d1d8e73c472c077f468fc.tar.zst gpt4free-cadc507fad2fee59b23d1d8e73c472c077f468fc.zip |
Diffstat (limited to '')
-rw-r--r-- | g4f/Provider/AItianhuSpace.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/g4f/Provider/AItianhuSpace.py b/g4f/Provider/AItianhuSpace.py index 0a2f6fe0..312cb3b3 100644 --- a/g4f/Provider/AItianhuSpace.py +++ b/g4f/Provider/AItianhuSpace.py @@ -5,7 +5,7 @@ import random from ..typing import CreateResult, Messages from .base_provider import BaseProvider -from .helper import WebDriver, format_prompt, get_browser +from .helper import WebDriver, format_prompt, get_browser, get_random_string from .. import debug class AItianhuSpace(BaseProvider): @@ -31,8 +31,7 @@ class AItianhuSpace(BaseProvider): if not model: model = "gpt-3.5-turbo" if not domain: - chars = 'abcdefghijklmnopqrstuvwxyz0123456789' - rand = ''.join(random.choice(chars) for _ in range(6)) + rand = get_random_string(6) domain = random.choice(cls._domains) domain = f"{rand}.{domain}" if debug.logging: @@ -65,10 +64,11 @@ document.getElementById('sheet').addEventListener('click', () => {{ driver.switch_to.window(window_handle) break + # Wait for page load wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "textarea.n-input__textarea-el"))) try: - # Add hook in XMLHttpRequest + # Register hook in XMLHttpRequest script = """ const _http_request_open = XMLHttpRequest.prototype.open; window._last_message = window._message = ""; @@ -90,11 +90,11 @@ XMLHttpRequest.prototype.open = function(method, url) { """ driver.execute_script(script) - # Input and submit prompt + # Submit prompt driver.find_element(By.CSS_SELECTOR, "textarea.n-input__textarea-el").send_keys(prompt) driver.find_element(By.CSS_SELECTOR, "button.n-button.n-button--primary-type.n-button--medium-type").click() - # Yield response + # Read response while True: chunk = driver.execute_script(""" if (window._message && window._message != window._last_message) { |