diff options
author | H Lohaus <hlohaus@users.noreply.github.com> | 2023-11-17 03:21:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-17 03:21:50 +0100 |
commit | f57fa3a43f4981c17a4e52f662304e51adee0d08 (patch) | |
tree | e139fe863cb1551b2713d09ce7d69be2f34e435e /g4f/Provider/MyShell.py | |
parent | ~ | g4f `v-0.1.8.4` (diff) | |
parent | Add Poe Provider, Update AItianhuSpace Porvider (diff) | |
download | gpt4free-f57fa3a43f4981c17a4e52f662304e51adee0d08.tar gpt4free-f57fa3a43f4981c17a4e52f662304e51adee0d08.tar.gz gpt4free-f57fa3a43f4981c17a4e52f662304e51adee0d08.tar.bz2 gpt4free-f57fa3a43f4981c17a4e52f662304e51adee0d08.tar.lz gpt4free-f57fa3a43f4981c17a4e52f662304e51adee0d08.tar.xz gpt4free-f57fa3a43f4981c17a4e52f662304e51adee0d08.tar.zst gpt4free-f57fa3a43f4981c17a4e52f662304e51adee0d08.zip |
Diffstat (limited to 'g4f/Provider/MyShell.py')
-rw-r--r-- | g4f/Provider/MyShell.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/g4f/Provider/MyShell.py b/g4f/Provider/MyShell.py index 70fd3509..0efeb0e8 100644 --- a/g4f/Provider/MyShell.py +++ b/g4f/Provider/MyShell.py @@ -38,11 +38,11 @@ class MyShell(BaseProvider): driver.get(cls.url) try: - # Wait for page load + # Wait for page load and cloudflare validation WebDriverWait(driver, timeout).until( EC.presence_of_element_located((By.CSS_SELECTOR, "body:not(.no-js)")) ) - # Send message + # Send request with message script = """ response = await fetch("https://api.myshell.ai/v1/bot/chat/send_message", { "headers": { @@ -66,7 +66,7 @@ window.reader = response.body.getReader(); script = """ chunk = await window.reader.read(); if (chunk['done']) return null; -text = (new TextDecoder ()).decode(chunk['value']); +text = (new TextDecoder()).decode(chunk['value']); content = ''; text.split('\\n').forEach((line, index) => { if (line.startsWith('data: ')) { @@ -81,7 +81,7 @@ text.split('\\n').forEach((line, index) => { return content; """ while True: - chunk = driver.execute_script(script): + chunk = driver.execute_script(script) if chunk: yield chunk elif chunk != "": |