diff options
author | abc <98614666+xtekky@users.noreply.github.com> | 2023-10-16 01:47:10 +0200 |
---|---|---|
committer | abc <98614666+xtekky@users.noreply.github.com> | 2023-10-16 01:47:10 +0200 |
commit | 4a3b663ccd44735d77c372b5f629a728f0b90591 (patch) | |
tree | f76dba66613f4e074862d57621ea888cd3e741f7 /g4f/Provider/ChatgptFree.py | |
parent | ~ | new `test_providers.py` (diff) | |
download | gpt4free-4a3b663ccd44735d77c372b5f629a728f0b90591.tar gpt4free-4a3b663ccd44735d77c372b5f629a728f0b90591.tar.gz gpt4free-4a3b663ccd44735d77c372b5f629a728f0b90591.tar.bz2 gpt4free-4a3b663ccd44735d77c372b5f629a728f0b90591.tar.lz gpt4free-4a3b663ccd44735d77c372b5f629a728f0b90591.tar.xz gpt4free-4a3b663ccd44735d77c372b5f629a728f0b90591.tar.zst gpt4free-4a3b663ccd44735d77c372b5f629a728f0b90591.zip |
Diffstat (limited to 'g4f/Provider/ChatgptFree.py')
-rw-r--r-- | g4f/Provider/ChatgptFree.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/g4f/Provider/ChatgptFree.py b/g4f/Provider/ChatgptFree.py index 7dee1e64..ecba2878 100644 --- a/g4f/Provider/ChatgptFree.py +++ b/g4f/Provider/ChatgptFree.py @@ -1,3 +1,5 @@ +#cloudflare block + from __future__ import annotations import re @@ -5,13 +7,13 @@ from aiohttp import ClientSession from ..typing import Messages from .base_provider import AsyncProvider -from .helper import format_prompt +from .helper import format_prompt, get_cookies class ChatgptFree(AsyncProvider): url = "https://chatgptfree.ai" supports_gpt_35_turbo = True - working = True + working = False _post_id = None _nonce = None @@ -23,6 +25,8 @@ class ChatgptFree(AsyncProvider): proxy: str = None, **kwargs ) -> str: + cookies = get_cookies('chatgptfree.ai') + headers = { "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/118.0", "Accept": "*/*", @@ -41,7 +45,8 @@ class ChatgptFree(AsyncProvider): } async with ClientSession(headers=headers) as session: if not cls._nonce: - async with session.get(f"{cls.url}/", proxy=proxy) as response: + async with session.get(f"{cls.url}/", + proxy=proxy, cookies=cookies) as response: response.raise_for_status() response = await response.text() result = re.search(r'data-post-id="([0-9]+)"', response) |