diff options
author | t.me/xtekky <98614666+xtekky@users.noreply.github.com> | 2023-04-16 18:43:26 +0200 |
---|---|---|
committer | t.me/xtekky <98614666+xtekky@users.noreply.github.com> | 2023-04-16 18:43:26 +0200 |
commit | 0fed30596a0e2fb162f5b813cf61ff57382c2ba1 (patch) | |
tree | 5b29da33b07f8321b0879d703e7f8fc3e90ad7c8 /experimental/chat.openai.com.py | |
parent | ora.sh gpt-4 (diff) | |
download | gpt4free-0fed30596a0e2fb162f5b813cf61ff57382c2ba1.tar gpt4free-0fed30596a0e2fb162f5b813cf61ff57382c2ba1.tar.gz gpt4free-0fed30596a0e2fb162f5b813cf61ff57382c2ba1.tar.bz2 gpt4free-0fed30596a0e2fb162f5b813cf61ff57382c2ba1.tar.lz gpt4free-0fed30596a0e2fb162f5b813cf61ff57382c2ba1.tar.xz gpt4free-0fed30596a0e2fb162f5b813cf61ff57382c2ba1.tar.zst gpt4free-0fed30596a0e2fb162f5b813cf61ff57382c2ba1.zip |
Diffstat (limited to 'experimental/chat.openai.com.py')
-rw-r--r-- | experimental/chat.openai.com.py | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/experimental/chat.openai.com.py b/experimental/chat.openai.com.py deleted file mode 100644 index b24184c6..00000000 --- a/experimental/chat.openai.com.py +++ /dev/null @@ -1,72 +0,0 @@ -# experimental, needs chat.openai.com to be loaded with cf_clearance on browser ( can be closed after ) - -from tls_client import Session -from uuid import uuid4 - -from browser_cookie3 import chrome - -def session_auth(client): - headers = { - 'authority': 'chat.openai.com', - 'accept': '*/*', - 'accept-language': 'en,fr-FR;q=0.9,fr;q=0.8,es-ES;q=0.7,es;q=0.6,en-US;q=0.5,am;q=0.4,de;q=0.3', - 'cache-control': 'no-cache', - 'pragma': 'no-cache', - 'referer': 'https://chat.openai.com/chat', - 'sec-ch-ua': '"Chromium";v="112", "Google Chrome";v="112", "Not:A-Brand";v="99"', - 'sec-ch-ua-mobile': '?0', - 'sec-ch-ua-platform': '"macOS"', - 'sec-fetch-dest': 'empty', - 'sec-fetch-mode': 'cors', - 'sec-fetch-site': 'same-origin', - 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36', - } - - return client.get('https://chat.openai.com/api/auth/session', headers=headers).json() - -client = Session(client_identifier='chrome110') - -for cookie in chrome(domain_name='chat.openai.com'): - client.cookies[cookie.name] = cookie.value - -client.headers = { - 'authority': 'chat.openai.com', - 'accept': 'text/event-stream', - 'accept-language': 'en,fr-FR;q=0.9,fr;q=0.8,es-ES;q=0.7,es;q=0.6,en-US;q=0.5,am;q=0.4,de;q=0.3', - 'authorization': 'Bearer ' + session_auth(client)['accessToken'], - 'cache-control': 'no-cache', - 'content-type': 'application/json', - 'origin': 'https://chat.openai.com', - 'pragma': 'no-cache', - 'referer': 'https://chat.openai.com/chat', - 'sec-ch-ua': '"Chromium";v="112", "Google Chrome";v="112", "Not:A-Brand";v="99"', - 'sec-ch-ua-mobile': '?0', - 'sec-ch-ua-platform': '"macOS"', - 'sec-fetch-dest': 'empty', - 'sec-fetch-mode': 'cors', - 'sec-fetch-site': 'same-origin', - 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36', -} - -response = client.post('https://chat.openai.com/backend-api/conversation', json = { - 'action': 'next', - 'messages': [ - { - 'id': str(uuid4()), - 'author': { - 'role': 'user', - }, - 'content': { - 'content_type': 'text', - 'parts': [ - 'hello world', - ], - }, - }, - ], - 'parent_message_id': '9b4682f7-977c-4c8a-b5e6-9713e73dfe01', - 'model': 'text-davinci-002-render-sha', - 'timezone_offset_min': -120, -}) - -print(response.text)
\ No newline at end of file |