XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/gpt4free

``` 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. ```

17976b93
hlohaus <983577+hlohaus@users.noreply.github.com>
提交于

代码差异

2 个文件 +4 -1
Modified g4f/client/stubs.py +2 -0
@@ -22,6 +22,8 @@ except ImportError:
22 22 class field_serializer():
23 23 def __init__(self, field_name):
24 24 self.field_name = field_name
25 def __call__(self, *args, **kwargs):
26 return args[0]
25 27
26 28 class BaseModel(BaseModel):
27 29 @classmethod
Modified g4f/requests/__init__.py +2 -1
@@ -104,7 +104,8 @@ async def get_args_from_nodriver(
104 104 await browser.cookies.set_all(get_cookie_params_from_dict(cookies, url=url, domain=domain))
105 105 page = await browser.get(url)
106 106 user_agent = await page.evaluate("window.navigator.userAgent", return_by_value=True)
107 await page.wait_for("body:not(.no-js)", timeout=timeout)
107 while not await page.evaluate("document.querySelector('body:not(.no-js)')"):
108 await asyncio.sleep(1)
108 109 if wait_for is not None:
109 110 await page.wait_for(wait_for, timeout=timeout)
110 111 if callback is not None: