diff options
author | Tekky <98614666+xtekky@users.noreply.github.com> | 2023-10-02 12:20:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-02 12:20:18 +0200 |
commit | c0632c27411b5cc8a643e0bffd71537f4224473c (patch) | |
tree | d8a07c23a8172e26004560e4d6b08982f637e71c /g4f/Provider/PerplexityAi.py | |
parent | ~ | v-0.1.4.2 `pip install -U g4f` (diff) | |
parent | Fix: There is no current event loop in thread (diff) | |
download | gpt4free-c0632c27411b5cc8a643e0bffd71537f4224473c.tar gpt4free-c0632c27411b5cc8a643e0bffd71537f4224473c.tar.gz gpt4free-c0632c27411b5cc8a643e0bffd71537f4224473c.tar.bz2 gpt4free-c0632c27411b5cc8a643e0bffd71537f4224473c.tar.lz gpt4free-c0632c27411b5cc8a643e0bffd71537f4224473c.tar.xz gpt4free-c0632c27411b5cc8a643e0bffd71537f4224473c.tar.zst gpt4free-c0632c27411b5cc8a643e0bffd71537f4224473c.zip |
Diffstat (limited to '')
-rw-r--r-- | g4f/Provider/PerplexityAi.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/g4f/Provider/PerplexityAi.py b/g4f/Provider/PerplexityAi.py index fc0fd48c..c7e58ad3 100644 --- a/g4f/Provider/PerplexityAi.py +++ b/g4f/Provider/PerplexityAi.py @@ -5,12 +5,12 @@ import time import base64 from curl_cffi.requests import AsyncSession -from .base_provider import AsyncProvider, format_prompt +from .base_provider import AsyncProvider, format_prompt, get_cookies class PerplexityAi(AsyncProvider): url = "https://www.perplexity.ai" - working = True + working = False supports_gpt_35_turbo = True _sources = [] @@ -23,18 +23,32 @@ class PerplexityAi(AsyncProvider): **kwargs ) -> str: url = cls.url + "/socket.io/?EIO=4&transport=polling" - async with AsyncSession(proxies={"https": proxy}, impersonate="chrome107") as session: + headers = { + "Referer": f"{cls.url}/" + } + async with AsyncSession(headers=headers, proxies={"https": proxy}, impersonate="chrome107") as session: url_session = "https://www.perplexity.ai/api/auth/session" response = await session.get(url_session) + response.raise_for_status() + + url_session = "https://www.perplexity.ai/api/auth/session" + response = await session.get(url_session) + response.raise_for_status() response = await session.get(url, params={"t": timestamp()}) response.raise_for_status() sid = json.loads(response.text[1:])["sid"] + response = await session.get(url, params={"t": timestamp(), "sid": sid}) + response.raise_for_status() + data = '40{"jwt":"anonymous-ask-user"}' response = await session.post(url, params={"t": timestamp(), "sid": sid}, data=data) response.raise_for_status() + response = await session.get(url, params={"t": timestamp(), "sid": sid}) + response.raise_for_status() + data = "424" + json.dumps([ "perplexity_ask", format_prompt(messages), |