mirror of
https://github.com/xtekky/gpt4free.git
synced 2025-12-15 14:51:19 -08:00
```
feat: add __call__ in field_serializer and update body wait logic
- In g4f/client/stubs.py, add a __call__ method to the field_serializer class that returns the first positional argument.
- In g4f/requests/__init__.py, replace the wait_for call with a while loop that repeatedly evaluates "document.querySelector('body:not(.no-js)')" and sleeps until the element is found.
```
This commit is contained in:
parent
3ab36ebc64
commit
17976b93a7
2 changed files with 4 additions and 1 deletions
|
|
@ -22,6 +22,8 @@ except ImportError:
|
|||
class field_serializer():
|
||||
def __init__(self, field_name):
|
||||
self.field_name = field_name
|
||||
def __call__(self, *args, **kwargs):
|
||||
return args[0]
|
||||
|
||||
class BaseModel(BaseModel):
|
||||
@classmethod
|
||||
|
|
|
|||
|
|
@ -104,7 +104,8 @@ async def get_args_from_nodriver(
|
|||
await browser.cookies.set_all(get_cookie_params_from_dict(cookies, url=url, domain=domain))
|
||||
page = await browser.get(url)
|
||||
user_agent = await page.evaluate("window.navigator.userAgent", return_by_value=True)
|
||||
await page.wait_for("body:not(.no-js)", timeout=timeout)
|
||||
while not await page.evaluate("document.querySelector('body:not(.no-js)')"):
|
||||
await asyncio.sleep(1)
|
||||
if wait_for is not None:
|
||||
await page.wait_for(wait_for, timeout=timeout)
|
||||
if callback is not None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue