From 5b65101a2a8b38f1ca69cecc448a025d833d2e10 Mon Sep 17 00:00:00 2001 From: hlohaus <983577+hlohaus@users.noreply.github.com> Date: Fri, 8 Aug 2025 01:46:15 +0200 Subject: [PATCH] feat: add delays and input actions for captcha and auth flows - Added `await asyncio.sleep(1)` inside captcha verification loop in `EasyChat.py` to introduce delay between checks - Modified `Grok.py` to send "Hello" input to a selected textarea element during auth flow - Added delay after sending keys to textarea in `Grok.py` using `await asyncio.sleep(1)` - Added logic to select and click a submit button if present in `Grok.py` during header check loop - All changes are within the `EasyChat` and `Grok` class definitions respectively --- g4f/Provider/EasyChat.py | 1 + g4f/Provider/needs_auth/Grok.py | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/g4f/Provider/EasyChat.py b/g4f/Provider/EasyChat.py index f85c7c9e..cac01e0a 100644 --- a/g4f/Provider/EasyChat.py +++ b/g4f/Provider/EasyChat.py @@ -65,6 +65,7 @@ class EasyChat(OpenaiTemplate, AuthFileMixin): if not modal: break debug.log("EasyChaat: Waiting for captcha verification...") + await asyncio.sleep(1) if cls.captchaToken: debug.log("EasyChat: Captcha token found, proceeding.") break diff --git a/g4f/Provider/needs_auth/Grok.py b/g4f/Provider/needs_auth/Grok.py index e80c3aa2..2c19f2be 100644 --- a/g4f/Provider/needs_auth/Grok.py +++ b/g4f/Provider/needs_auth/Grok.py @@ -62,6 +62,12 @@ class Grok(AsyncAuthedProvider, ProviderModelMixin): while True: if has_headers: break + textarea = await page.select("textarea", 180) + await textarea.send_keys("Hello") + await asyncio.sleep(1) + button = await page.select("button[type='submit']") + if button: + await button.click() await asyncio.sleep(1) auth_result.cookies = {} for c in await page.send(nodriver.cdp.network.get_cookies([cls.url])):