summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/PerplexityLabs.py
diff options
context:
space:
mode:
authorH Lohaus <hlohaus@users.noreply.github.com>2024-01-24 01:05:29 +0100
committerGitHub <noreply@github.com>2024-01-24 01:05:29 +0100
commit71d71b6512df12d6295c1f8323eb056edd89c57f (patch)
treedb88f2c8237b51519401e077df059b71f41e6404 /g4f/Provider/PerplexityLabs.py
parentMerge pull request #1509 from hlohaus/sort (diff)
parentAdd get_connector helper (diff)
downloadgpt4free-71d71b6512df12d6295c1f8323eb056edd89c57f.tar
gpt4free-71d71b6512df12d6295c1f8323eb056edd89c57f.tar.gz
gpt4free-71d71b6512df12d6295c1f8323eb056edd89c57f.tar.bz2
gpt4free-71d71b6512df12d6295c1f8323eb056edd89c57f.tar.lz
gpt4free-71d71b6512df12d6295c1f8323eb056edd89c57f.tar.xz
gpt4free-71d71b6512df12d6295c1f8323eb056edd89c57f.tar.zst
gpt4free-71d71b6512df12d6295c1f8323eb056edd89c57f.zip
Diffstat (limited to '')
-rw-r--r--g4f/Provider/PerplexityLabs.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/g4f/Provider/PerplexityLabs.py b/g4f/Provider/PerplexityLabs.py
index 90258da5..5002b39f 100644
--- a/g4f/Provider/PerplexityLabs.py
+++ b/g4f/Provider/PerplexityLabs.py
@@ -2,10 +2,11 @@ from __future__ import annotations
import random
import json
-from aiohttp import ClientSession
+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/"
@@ -32,6 +33,7 @@ class PerplexityLabs(AsyncGeneratorProvider, ProviderModelMixin):
model: str,
messages: Messages,
proxy: str = None,
+ connector: BaseConnector = None,
**kwargs
) -> AsyncResult:
headers = {
@@ -47,7 +49,7 @@ class PerplexityLabs(AsyncGeneratorProvider, ProviderModelMixin):
"Sec-Fetch-Site": "same-site",
"TE": "trailers",
}
- async with ClientSession(headers=headers) 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}",