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

XFEstudio/gpt4free

fix: Update image references and enhance cookie acceptance handling in Yupp and LMArena providers

7a4bf072
hlohaus <983577+hlohaus@users.noreply.github.com>
提交于

代码差异

3 个文件 +21 -15
Modified etc/tool/template.html +6 -6
@@ -15,20 +15,20 @@
15 15 <meta property="og:description" content="GPT4Free documentation for GPT4Free Documentation Hub. Free AI endpoints, examples, and comprehensive guides." />
16 16 <meta property="og:url" content="https://g4f.dev/docs/" />
17 17 <meta property="og:site_name" content="GPT4Free Documentation" />
18 <meta property="og:image" content="https://g4f.dev/dist/img/apple-touch-icon.png" />
18 <meta property="og:image" content="https://g4f.dev/dist/img/g4f-512x512.png" />
19 19
20 20 <!-- Twitter Card -->
21 21 <meta name="twitter:card" content="summary_large_image" />
22 22 <meta name="twitter:title" content="GPT4Free Documentation Hub | GPT4Free Documentation" />
23 23 <meta name="twitter:description" content="Free AI endpoints and comprehensive documentation for GPT4Free Documentation Hub." />
24 <meta name="twitter:image" content="https://g4f.dev/dist/img/apple-touch-icon.png" />
24 <meta name="twitter:image" content="https://g4f.dev/dist/img/g4f-512x512.png" />
25 25
26 26 <!-- Canonical -->
27 27 <link rel="canonical" href="https://g4f.dev/docs/" />
28 28
29 <link rel="apple-touch-icon" sizes="180x180" href="/dist/img/apple-touch-icon.png" />
30 <link rel="icon" type="image/png" sizes="32x32" href="/dist/img/favicon-32x32.png" />
31 <link rel="icon" type="image/png" sizes="16x16" href="/dist/img/favicon-16x16.png" />
29 <link rel="apple-touch-icon" sizes="180x180" href="/dist/img/g4f-180x180.png" />
30 <link rel="icon" type="image/png" sizes="32x32" href="/dist/img/g4f-32x32.png" />
31 <link rel="icon" type="image/png" sizes="16x16" href="/dist/img/g4f-16x16.png" />
32 32 <link rel="manifest" href="/dist/img/site.webmanifest" />
33 33
34 34 <!-- GitHub Primer CSS & styles -->
@@ -382,7 +382,7 @@
382 382 "url": "https://g4f.dev",
383 383 "logo": {
384 384 "@type": "ImageObject",
385 "url": "https://g4f.dev/dist/img/apple-touch-icon.png"
385 "url": "https://g4f.dev/dist/img/g4f-512x512.png"
386 386 }
387 387 },
388 388 "publisher": {
Modified g4f/Provider/Yupp.py +2 -2
@@ -980,7 +980,7 @@ class Yupp(AsyncGeneratorProvider, ProviderModelMixin):
980 980 provider_info = cls.get_dict()
981 981 provider_info["model"] = model_id
982 982 for i, selection in enumerate(data.get("modelSelections", [])):
983 if selection.get("selectionSource") == "USER_SELECTED":
983 if selection.get("selectionSource") == "USER_SELECTED" or i == 0:
984 984 target_stream_id = extract_ref_id(
985 985 select_stream[i].get("next")
986 986 )
@@ -990,7 +990,7 @@ class Yupp(AsyncGeneratorProvider, ProviderModelMixin):
990 990 )
991 991 provider_info["modelUrl"] = selection.get("externalUrl")
992 992 log_debug(f"Found target stream ID: {target_stream_id}")
993 else:
993 if selection.get("selectionSource") != "USER_SELECTED":
994 994 variant_stream_id = extract_ref_id(
995 995 select_stream[i].get("next")
996 996 )
Modified g4f/Provider/needs_auth/LMArena.py +13 -7
@@ -166,13 +166,19 @@ class LMArena(AsyncGeneratorProvider, ProviderModelMixin, AuthFileMixin):
166 166 grecaptcha = []
167 167
168 168 async def callback(page: nodriver.Tab):
169 button = await page.find("Accept Cookies")
169 try:
170 button = await page.find("Accept Cookies")
171 except TimeoutError:
172 button = None
170 173 if button:
171 174 await button.click()
172 175 else:
173 176 debug.log("No 'Accept Cookies' button found, skipping.")
174 177 await asyncio.sleep(1)
175 textarea = await page.select('textarea[name="message"]')
178 try:
179 textarea = await page.select('textarea[name="message"]')
180 except TimeoutError:
181 textarea = None
176 182 if textarea:
177 183 await textarea.send_keys("Hello")
178 184 # await asyncio.sleep(1)
@@ -191,12 +197,12 @@ class LMArena(AsyncGeneratorProvider, ProviderModelMixin, AuthFileMixin):
191 197 element = None
192 198 if element:
193 199 await click_trunstile(page, 'document.querySelector(\'[style="display: grid;"]\')')
194 if not await page.evaluate('document.cookie.indexOf("arena-auth-prod-v1") >= 0'):
195 debug.log("No authentication cookie found, trying to authenticate.")
196 await page.select('#cf-turnstile', 300)
197 debug.log("Found Element: 'cf-turnstile'")
200 while not await page.evaluate('document.cookie.indexOf("arena-auth-prod-v1") >= 0'):
201 debug.log("No authentication cookie found, waiting for authenticate.")
202 #await page.select('#cf-turnstile', 300)
203 #debug.log("Found Element: 'cf-turnstile'")
198 204 await asyncio.sleep(3)
199 await click_trunstile(page)
205 #await click_trunstile(page)
200 206 while not await page.evaluate('document.cookie.indexOf("arena-auth-prod-v1") >= 0'):
201 207 await asyncio.sleep(1)
202 208 while not await page.evaluate('!!document.querySelector(\'textarea\')'):