mirror of
https://github.com/xtekky/gpt4free.git
synced 2025-12-05 18:20:35 -08:00
Improve input handling in Grok.py
Refactor input selection and submission logic for better error handling and clarity.
This commit is contained in:
parent
18fda760cb
commit
05c108d3f6
1 changed files with 20 additions and 6 deletions
|
|
@ -92,12 +92,26 @@ class Grok(AsyncAuthedProvider, ProviderModelMixin):
|
||||||
while True:
|
while True:
|
||||||
if has_headers:
|
if has_headers:
|
||||||
break
|
break
|
||||||
textarea = await page.select("textarea", 180)
|
input_element = None
|
||||||
await textarea.send_keys("Hello")
|
try:
|
||||||
await asyncio.sleep(1)
|
input_element = await page.select("div.ProseMirror", 2)
|
||||||
button = await page.select("button[type='submit']")
|
except Exception:
|
||||||
if button:
|
pass
|
||||||
await button.click()
|
if not input_element:
|
||||||
|
try:
|
||||||
|
input_element = await page.select("textarea", 180)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
if input_element:
|
||||||
|
try:
|
||||||
|
await input_element.click()
|
||||||
|
await input_element.send_keys("Hello")
|
||||||
|
await asyncio.sleep(0.5)
|
||||||
|
submit_btn = await page.select("button[type='submit']", 2)
|
||||||
|
if submit_btn:
|
||||||
|
await submit_btn.click()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
auth_result.cookies = {}
|
auth_result.cookies = {}
|
||||||
for c in await page.send(nodriver.cdp.network.get_cookies([cls.url])):
|
for c in await page.send(nodriver.cdp.network.get_cookies([cls.url])):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue