Closed 3mora2 closed 9 months ago
It is working perfectly fine for me. Perhaps the issue lies with the 'curl_cffi' library. Try reinstalling it using the following method:
pip uninstall curl_cffi
pip install curl_cffi==0.5.9
thanks, it work now
Please help! I get the same above error. OS: Ubuntu Python: 3.11 curl_cffi: curl_cffi-0.5.9 My code is
def revChatGPT(prompt, id=''):
from revChatGPT import AsyncChatGPT
session_token = "__Secure-next-auth.session-token here"
if id == '': conversation_id = None # conversation ID here
else: conversation_id = id
if sys.version_info >= (3, 8) and sys.platform.lower().startswith("win"):
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
async def main():
ans = ''
async with AsyncChatGPT(session_token=session_token) as chatgpt:
if conversation_id:
conversation = chatgpt.get_conversation(conversation_id)
else:
conversation = chatgpt.create_new_conversation()
async for message in conversation.chat(prompt):
# print(message["content"], flush=True, end="")
ans = ans + message["content"]
return ans
ans = asyncio.run(main())
return {'RESULT': True, 'ID': '', 'DATA': ans}
print(revChatGPT('hi'))
Did you try reinstalling the curl_cffi
LIB?
pip uninstall curl_cffi
pip install curl_cffi==0.5.9
And you should use SyncChatGPT
instead of AsyncChatGPT
if you are unfamiliar with async programming in Python.
Did you try reinstalling the
curl_cffi
LIB?pip uninstall curl_cffi pip install curl_cffi==0.5.9
And you should use
SyncChatGPT
instead ofAsyncChatGPT
if you are unfamiliar with async programming in Python.
I install curl_cffi==0.5.9
python3 -m pip show curl-cffi
Name: curl-cffi
Version: 0.5.9
Summary: libcurl ffi bindings for Python, with impersonation support
Home-page:
Author:
Author-email: Yifei Kong <kong@yifei.me>
License: MIT License
And use SyncChatGPT
instead of AsyncChatGPT
with the code:
def revChatGPT(prompt, id=''):
from re_gpt import SyncChatGPT
session_token = "__Secure-next-auth.session-token here" # I replace this with my __Secure-next-auth.session-token
if id == '': conversation_id = None # conversation ID here
else: conversation_id = id
with SyncChatGPT(session_token=session_token) as chatgpt:
if conversation_id:
conversation = chatgpt.get_conversation(conversation_id)
else:
conversation = chatgpt.create_new_conversation()
for message in conversation.chat(prompt):
print(message["content"], flush=True, end="")
when call revChatGPT('hi') it returns:
Traceback (most recent call last):
File "/usr/lib/python3.11/code.py", line 90, in runcode
exec(code, self.locals)
File "<console>", line 1, in <module>
File "..../libs.py", line 468, in revChatGPT
with SyncChatGPT(session_token=session_token) as chatgpt:
File "..../sync_chatgpt.py", line 292, in __enter__
self.auth_token = self.fetch_auth_token()
^^^^^^^^^^^^^^^^^^^^^^^
File "...../sync_chatgpt.py", line 368, in fetch_auth_token
response_json = response.json()
^^^^^^^^^^^^^^^
File "....../curl_cffi/requests/models.py", line 64, in json
return loads(self.content, **kw)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
I tried to put accessToken to fetch_auth_token() and it return html source page.
Try updating curl_cffi
to the latest version and try again. If the issue persists, follow these steps:
git clone https://github.com/Zai-Kun/reverse-engineered-chatgpt
cd reverse-engineered-chatgpt
sampleconfig.ini
file to config.ini
: mv sampleconfig.ini config.ini
config.ini
file and replace your __Secure-next-auth.session-token here
with your actual session tokencomplex_example.py
file from the examples folder to your current dir: mv examples/complex_example.py main.py
re_gpt/sync_chatgpt.py
file, and put this print statement at line 368
: print(response.text)
main.py
file: python3 main.py
If the issue persists, send the output of the print statement for debugging.
EDIT: And again, it works perfectly fine for me.
Try updating
curl_cffi
to the latest version and try again. If the issue persists, follow these steps:
- Clone the repo using git:
git clone https://github.com/Zai-Kun/reverse-engineered-chatgpt
- CD into the cloned repo:
cd reverse-engineered-chatgpt
- Rename the
sampleconfig.ini
file toconfig.ini
:mv sampleconfig.ini config.ini
- Edit the
config.ini
file and replace your__Secure-next-auth.session-token here
with your actual session token- Move the
complex_example.py
file from the examples folder to your current dir:mv examples/complex_example.py main.py
- Now, open up the
re_gpt/sync_chatgpt.py
file, and put this print statement at line368
:print(response.text)
- Run the
main.py
file:python3 main.py
If the issue persists, send the output of the print statement for debugging.
EDIT: And again, it works perfectly fine for me.
Thanks for your help. Now, I can run the example.
Thanks @Zai-Kun , now I can make it works. Do you plan make login function with email, password ?
Do you plan make login function with email, password ?
Hmm, I might do it, I'm not sure.
@Zai-Kun login function with credentials would be useful
get error
Checking your browser before accessing "chat.openai.com".
as html whenawait self.update_auth_token(self.session_token)
return html