mirror of
https://github.com/xtekky/gpt4free.git
synced 2025-12-15 14:51:19 -08:00
Add get_connector helper
This commit is contained in:
parent
8864b70ee4
commit
69ef224f92
8 changed files with 29 additions and 41 deletions
|
|
@ -6,6 +6,7 @@ from aiohttp import ClientSession, BaseConnector
|
|||
|
||||
from ..typing import AsyncResult, Messages
|
||||
from .base_provider import AsyncGeneratorProvider, ProviderModelMixin
|
||||
from .helper import get_connector
|
||||
|
||||
API_URL = "https://labs-api.perplexity.ai/socket.io/"
|
||||
WS_URL = "wss://labs-api.perplexity.ai/socket.io/"
|
||||
|
|
@ -48,13 +49,7 @@ class PerplexityLabs(AsyncGeneratorProvider, ProviderModelMixin):
|
|||
"Sec-Fetch-Site": "same-site",
|
||||
"TE": "trailers",
|
||||
}
|
||||
if proxy and not connector:
|
||||
try:
|
||||
from aiohttp_socks import ProxyConnector
|
||||
connector = ProxyConnector.from_url(proxy)
|
||||
except ImportError:
|
||||
raise RuntimeError('Install "aiohttp_socks" package for proxy support')
|
||||
async with ClientSession(headers=headers, connector=connector) as session:
|
||||
async with ClientSession(headers=headers, connector=get_connector(connector, proxy)) as session:
|
||||
t = format(random.getrandbits(32), '08x')
|
||||
async with session.get(
|
||||
f"{API_URL}?EIO=4&transport=polling&t={t}",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue