mirror of
https://github.com/xtekky/gpt4free.git
synced 2024-09-12 00:29:27 -04:00
Update MyShell.py
This commit is contained in:
parent
5c5235671e
commit
aa12716974
@ -65,6 +65,7 @@ window.reader = response.body.getReader();
|
|||||||
driver.execute_script(script.replace("{body}", json.dumps(data)))
|
driver.execute_script(script.replace("{body}", json.dumps(data)))
|
||||||
script = """
|
script = """
|
||||||
chunk = await window.reader.read();
|
chunk = await window.reader.read();
|
||||||
|
if (chunk['done']) return null;
|
||||||
text = await (new Response(chunk['value']).text());
|
text = await (new Response(chunk['value']).text());
|
||||||
content = '';
|
content = '';
|
||||||
text.split('\\n').forEach((line, index) => {
|
text.split('\\n').forEach((line, index) => {
|
||||||
@ -79,8 +80,12 @@ text.split('\\n').forEach((line, index) => {
|
|||||||
});
|
});
|
||||||
return content;
|
return content;
|
||||||
"""
|
"""
|
||||||
while chunk := driver.execute_script(script):
|
while True:
|
||||||
yield chunk
|
chunk = driver.execute_script(script):
|
||||||
|
if chunk:
|
||||||
|
yield chunk
|
||||||
|
elif chunk != "":
|
||||||
|
break
|
||||||
finally:
|
finally:
|
||||||
driver.close()
|
driver.close()
|
||||||
if not browser:
|
if not browser:
|
||||||
|
Loading…
Reference in New Issue
Block a user