acheong08 / ChatGPT

Reverse engineered ChatGPT API
GNU General Public License v2.0
28.01k stars 4.48k forks source link

Use V1 and V3 to access GPT-4. #1369

Closed hongyi-zhao closed 1 year ago

hongyi-zhao commented 1 year ago

I bought GPT-4 as shown below:

image

I set the usename and passwd in config.json as follows:

{ "email": "my-email",
  "password": "my-passwd"
}

Then I try to log in but failed as follows:

werner@X10DAi:~$ revChatGPT 1

        ChatGPT - A command-line interface to OpenAI's ChatGPT (https://chat.openai.com/chat)
        Repo: github.com/acheong08/ChatGPT
        Version: 5.0.0

Type '!help' to show a full list of commands
Press Esc followed by Enter or Alt+Enter to send a message.
Insufficient login details provided!
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/werner/Public/repo/github.com/acheong08/ChatGPT.git/src/revChatGPT/__main__.py", line 65, in <module>
    main()
  File "/home/werner/Public/repo/github.com/acheong08/ChatGPT.git/src/revChatGPT/__main__.py", line 49, in main
    V1.main(V1.configure())
  File "/home/werner/Public/repo/github.com/acheong08/ChatGPT.git/src/revChatGPT/V1.py", line 66, in wrapper
    out = func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^
  File "/home/werner/Public/repo/github.com/acheong08/ChatGPT.git/src/revChatGPT/V1.py", line 1196, in main
    chatbot = Chatbot(
              ^^^^^^^^
  File "/home/werner/Public/repo/github.com/acheong08/ChatGPT.git/src/revChatGPT/V1.py", line 66, in wrapper
    out = func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^
  File "/home/werner/Public/repo/github.com/acheong08/ChatGPT.git/src/revChatGPT/V1.py", line 177, in __init__
    self.__check_credentials()
  File "/home/werner/Public/repo/github.com/acheong08/ChatGPT.git/src/revChatGPT/V1.py", line 66, in wrapper
    out = func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^
  File "/home/werner/Public/repo/github.com/acheong08/ChatGPT.git/src/revChatGPT/V1.py", line 198, in __check_credentials
    self.login()
  File "/home/werner/Public/repo/github.com/acheong08/ChatGPT.git/src/revChatGPT/V1.py", line 66, in wrapper
    out = func(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^
  File "/home/werner/Public/repo/github.com/acheong08/ChatGPT.git/src/revChatGPT/V1.py", line 332, in login
    raise error
revChatGPT.typings.AuthenticationError: Insufficient login details provided!
Please check if your key is correct, maybe it may not be valid
Please check that the input is correct, or you can resolve this issue by filing an issue
Project URL: https://github.com/acheong08/ChatGPT

What should I do then?

Regards, Zhao

github-actions[bot] commented 1 year ago

Automated: 👋 Thanks for reporting this issue. @acheong08 will review it shortly. In the meantime, please check to see if there are any similar issues already closed.

fmunim commented 1 year ago

Getting this

Traceback (most recent call last):
  File "/home/xxx/xxx/src/aclient.py", line 146, in send_start_prompt
    response = f"{response}{await responses.unofficial_handle_response(prompt, self)}"
  File "/home/xxx/xxx/src/responses.py", line 8, in unofficial_handle_response
    async for response in client.chatbot.ask(message):
  File "/home/xxx/xxx/env/lib/python3.10/site-packages/revChatGPT/V1.py", line 988, in ask
    async for msg in self.post_messages(
  File "/home/xxx/xxx/env/lib/python3.10/site-packages/revChatGPT/V1.py", line 941, in post_messages
    async for msg in self.__send_request(
  File "/home/xxx/xxx/env/lib/python3.10/site-packages/revChatGPT/V1.py", line 825, in __send_request
    await self.__check_response(response)
  File "/home/xxx/xxx/env/lib/python3.10/site-packages/revChatGPT/V1.py", line 1163, in __check_response
    raise error from ex
revChatGPT.typings.Error: OpenAI: {"detail":{"message":"Could not parse your authentication token. Please try signing in again.","type":"invalid_request_error","param":null,"code":"invalid_jwt"}} (code: 401)
hongyi-zhao commented 1 year ago

But, the access_token works for V1.

hongyi-zhao commented 1 year ago

V3 also fails to access GPT-4:

$ python3 -m revChatGPT --V3 --api_key sk-xxx --truncate_limit $(( 32 * 1024 )) --proxy socks5h://127.0.0.1:18890 --model gpt-4-32k

    ChatGPT - Official ChatGPT API
    Repo: github.com/acheong08/ChatGPT
    Version: 5.0.0

Type '!help' to show a full list of commands
Press Esc followed by Enter or Alt+Enter to send a message.

Traceback (most recent call last):
  File "/home/werner/Public/repo/github.com/acheong08/ChatGPT.git/src/revChatGPT/__main__.py", line 52, in main
    V3.main()
  File "/home/werner/Public/repo/github.com/acheong08/ChatGPT.git/src/revChatGPT/V3.py", line 609, in main
    chatbot = ChatbotCLI(
              ^^^^^^^^^^^
  File "/home/werner/Public/repo/github.com/acheong08/ChatGPT.git/src/revChatGPT/V3.py", line 97, in __init__
    if self.get_token_count("default") > self.max_tokens:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/werner/Public/repo/github.com/acheong08/ChatGPT.git/src/revChatGPT/V3.py", line 142, in get_token_count
    encoding = tiktoken.encoding_for_model(self.engine)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/werner/.pyenv/versions/datasci/lib/python3.11/site-packages/tiktoken/model.py", line 68, in encoding_for_model
    raise KeyError(
KeyError: 'Could not automatically map gpt-4-32k to a tokeniser. Please use `tiktok.get_encoding` to explicitly get the tokeniser you expect.'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/werner/Public/repo/github.com/acheong08/ChatGPT.git/src/revChatGPT/__main__.py", line 65, in <module>
    main()
  File "/home/werner/Public/repo/github.com/acheong08/ChatGPT.git/src/revChatGPT/__main__.py", line 55, in main
    raise error from exc
revChatGPT.typings.CLIError: Command line program unknown error
Please check that the input is correct, or you can resolve this issue by filing an issue
Project URL: https://github.com/acheong08/ChatGPT
acheong08 commented 1 year ago

KeyError: 'Could not automatically map gpt-4-32k to a tokeniser. Please use tiktok.get_encoding to explicitly get the tokeniser you expect.'

This model does not exist yet

acheong08 commented 1 year ago

And upgrade tiktoken

hongyi-zhao commented 1 year ago

Tried but still fail:

werner@X10DAi:~$ revChatGPT 3

    ChatGPT - Official ChatGPT API
    Repo: github.com/acheong08/ChatGPT
    Version: 5.0.0

Type '!help' to show a full list of commands
Press Esc followed by Enter or Alt+Enter to send a message.

User: 
Hello.

ChatGPT: 
Traceback (most recent call last):
  File "/home/werner/.pyenv/versions/datasci/lib/python3.11/site-packages/revChatGPT/__main__.py", line 52, in main
    V3.main()
  File "/home/werner/.pyenv/versions/datasci/lib/python3.11/site-packages/revChatGPT/V3.py", line 695, in main
    for query in chatbot.ask_stream(prompt):
  File "/home/werner/.pyenv/versions/datasci/lib/python3.11/site-packages/revChatGPT/V3.py", line 203, in ask_stream
    raise t.APIConnectionError(
revChatGPT.typings.APIConnectionError: 404 Not Found {
    "error": {
        "message": "The model: `gpt-4` does not exist",
        "type": "invalid_request_error",
        "param": null,
        "code": "model_not_found"
    }
}

Please check if there is a problem with your network connection
Please check that the input is correct, or you can resolve this issue by filing an issue
Project URL: https://github.com/acheong08/ChatGPT

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/werner/.pyenv/versions/datasci/lib/python3.11/site-packages/revChatGPT/__main__.py", line 65, in <module>
    main()
  File "/home/werner/.pyenv/versions/datasci/lib/python3.11/site-packages/revChatGPT/__main__.py", line 55, in main
    raise error from exc
revChatGPT.typings.CLIError: Command line program unknown error
Please check that the input is correct, or you can resolve this issue by filing an issue
Project URL: https://github.com/acheong08/ChatGPT