diff options
author | Heiner Lohaus <heiner@lohaus.eu> | 2023-10-09 10:22:17 +0200 |
---|---|---|
committer | Heiner Lohaus <heiner@lohaus.eu> | 2023-10-09 10:22:17 +0200 |
commit | e46b5fe043ffcdb87ddb97db14a7e699dd8a2690 (patch) | |
tree | f162aa3ea3c746dd297c1c07c4c1d9237090a5a0 /g4f/Provider/ChatgptX.py | |
parent | Merge branch 'main' of https://github.com/xtekky/gpt4free (diff) | |
download | gpt4free-e46b5fe043ffcdb87ddb97db14a7e699dd8a2690.tar gpt4free-e46b5fe043ffcdb87ddb97db14a7e699dd8a2690.tar.gz gpt4free-e46b5fe043ffcdb87ddb97db14a7e699dd8a2690.tar.bz2 gpt4free-e46b5fe043ffcdb87ddb97db14a7e699dd8a2690.tar.lz gpt4free-e46b5fe043ffcdb87ddb97db14a7e699dd8a2690.tar.xz gpt4free-e46b5fe043ffcdb87ddb97db14a7e699dd8a2690.tar.zst gpt4free-e46b5fe043ffcdb87ddb97db14a7e699dd8a2690.zip |
Diffstat (limited to 'g4f/Provider/ChatgptX.py')
-rw-r--r-- | g4f/Provider/ChatgptX.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/g4f/Provider/ChatgptX.py b/g4f/Provider/ChatgptX.py index 2944fb26..8052f65b 100644 --- a/g4f/Provider/ChatgptX.py +++ b/g4f/Provider/ChatgptX.py @@ -19,6 +19,7 @@ class ChatgptX(AsyncGeneratorProvider): cls, model: str, messages: Messages, + proxy: str = None, **kwargs ) -> AsyncResult: headers = { @@ -32,7 +33,7 @@ class ChatgptX(AsyncGeneratorProvider): 'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36', } async with ClientSession(headers=headers) as session: - async with session.get(f"{cls.url}/") as response: + async with session.get(f"{cls.url}/", proxy=proxy) as response: response = await response.text() result = re.search(r'<meta name="csrf-token" content="(.*?)"', response) if result: @@ -62,7 +63,7 @@ class ChatgptX(AsyncGeneratorProvider): 'x-csrf-token': csrf_token, 'x-requested-with': 'XMLHttpRequest' } - async with session.post(cls.url + '/sendchat', data=data, headers=headers) as response: + async with session.post(cls.url + '/sendchat', data=data, headers=headers, proxy=proxy) as response: response.raise_for_status() chat = await response.json() if "response" not in chat or not chat["response"]: @@ -82,7 +83,7 @@ class ChatgptX(AsyncGeneratorProvider): "conversions_id": chat["conversions_id"], "ass_conversions_id": chat["ass_conversions_id"], } - async with session.get(f'{cls.url}/chats_stream', params=data, headers=headers) as response: + async with session.get(f'{cls.url}/chats_stream', params=data, headers=headers, proxy=proxy) as response: response.raise_for_status() async for line in response.content: if line.startswith(b"data: "): |