Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Commit

Permalink
Change proxy usage
Browse files Browse the repository at this point in the history
  • Loading branch information
terry3041 committed Dec 7, 2022
1 parent b3fbf79 commit 78bf50d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ from pyChatGPT import ChatGPT

session_token = 'abc123' # `__Secure-next-auth.session-token` cookie from https://chat.openai.com/chat
api = ChatGPT(session_token)
api2 = ChatGPT(session_token, conversation_id='conversation_id') # specify a conversation id
api3 = ChatGPT(session_token, proxy='http://proxy.example.com:8080') # specify proxy

resp = api.send_message('Hello, world!')
print(resp['message'])

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "pyChatGPT"
version = "0.0.8"
version = "0.0.9"
authors = [
{ name="terry3041", email="[email protected]" },
]
Expand Down
4 changes: 2 additions & 2 deletions src/pyChatGPT/pyChatGPT.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ChatGPT:
'''

def __init__(
self, session_token: str, conversation_id: str = None, proxies: dict = {}
self, session_token: str, conversation_id: str = None, proxy: str = None
) -> None:
'''
Initialize the ChatGPT class\n
Expand All @@ -21,7 +21,7 @@ def __init__(
self.session_token = session_token
self.conversation_id = conversation_id
self.parent_id = str(uuid.uuid4())
self.proxies = proxies
self.proxies = {'http': proxy, 'https': proxy} if proxy else {}
self.headers = {
'Cookie': f'__Secure-next-auth.session-token={self.session_token}',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36 Edg/107.0.1418.62',
Expand Down

0 comments on commit 78bf50d

Please sign in to comment.