summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/MyShell.py
diff options
context:
space:
mode:
authorHeiner Lohaus <hlohaus@users.noreply.github.com>2023-11-17 03:19:27 +0100
committerHeiner Lohaus <hlohaus@users.noreply.github.com>2023-11-17 03:19:27 +0100
commit92908b4347ad8a8b231feeaf70cc163bbd85eb29 (patch)
treed5208f496974325a606d2bcf4297be5b6ed6c9b4 /g4f/Provider/MyShell.py
parentUpdate Liaobots.py (diff)
downloadgpt4free-92908b4347ad8a8b231feeaf70cc163bbd85eb29.tar
gpt4free-92908b4347ad8a8b231feeaf70cc163bbd85eb29.tar.gz
gpt4free-92908b4347ad8a8b231feeaf70cc163bbd85eb29.tar.bz2
gpt4free-92908b4347ad8a8b231feeaf70cc163bbd85eb29.tar.lz
gpt4free-92908b4347ad8a8b231feeaf70cc163bbd85eb29.tar.xz
gpt4free-92908b4347ad8a8b231feeaf70cc163bbd85eb29.tar.zst
gpt4free-92908b4347ad8a8b231feeaf70cc163bbd85eb29.zip
Diffstat (limited to 'g4f/Provider/MyShell.py')
-rw-r--r--g4f/Provider/MyShell.py8
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 != "":