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

XFEstudio/gpt4free

Update CopilotSession.py

68788290
H Lohaus <hlohaus@users.noreply.github.com>
提交于

代码差异

1 个文件 +17 -2
Modified g4f/Provider/CopilotSession.py +17 -2
@@ -19,7 +19,6 @@ from ..providers.response import *
19 19 from ..requests import get_nodriver_session
20 20 from ..image import is_accepted_format
21 21 from .helper import get_last_user_message
22 from .Copilot import click_trunstile
23 22 from .. import debug
24 23
25 24 class Conversation(JsonConversation):
@@ -205,4 +204,20 @@ class CopilotSession(AsyncAuthedProvider, ProviderModelMixin):
205 204 if not done:
206 205 raise MissingAuthError(f"Invalid response: {last_msg}")
207 206 if sources:
208 yield Sources(sources.values())
207 yield Sources(sources.values())
208
209 if has_nodriver:
210 async def click_trunstile(page: nodriver.Tab, element='document.getElementById("cf-turnstile")'):
211 for _ in range(3):
212 size = None
213 for idx in range(15):
214 size = await page.js_dumps(f'{element}?.getBoundingClientRect()||{{}}')
215 debug.log(f"Found size: {size.get('x'), size.get('y')}")
216 if "x" not in size:
217 break
218 await page.flash_point(size.get("x") + idx * 3, size.get("y") + idx * 3)
219 await page.mouse_click(size.get("x") + idx * 3, size.get("y") + idx * 3)
220 await asyncio.sleep(2)
221 if "x" not in size:
222 break
223 debug.log("Finished clicking trunstile.")