summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/ChatgptX.py
diff options
context:
space:
mode:
authorCommenter123321 <36051603+Commenter123321@users.noreply.github.com>2023-10-10 14:15:12 +0200
committerCommenter123321 <36051603+Commenter123321@users.noreply.github.com>2023-10-10 14:15:12 +0200
commit0e4297494dd46533738f786e4ac675541586177a (patch)
tree6c2999e14ed831f7f37cc60991571cd040772918 /g4f/Provider/ChatgptX.py
parentadd cool testing for gpt-3.5 and and gpt-4 (diff)
parentUpdate Aivvm.py (diff)
downloadgpt4free-0e4297494dd46533738f786e4ac675541586177a.tar
gpt4free-0e4297494dd46533738f786e4ac675541586177a.tar.gz
gpt4free-0e4297494dd46533738f786e4ac675541586177a.tar.bz2
gpt4free-0e4297494dd46533738f786e4ac675541586177a.tar.lz
gpt4free-0e4297494dd46533738f786e4ac675541586177a.tar.xz
gpt4free-0e4297494dd46533738f786e4ac675541586177a.tar.zst
gpt4free-0e4297494dd46533738f786e4ac675541586177a.zip
Diffstat (limited to 'g4f/Provider/ChatgptX.py')
-rw-r--r--g4f/Provider/ChatgptX.py7
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: "):