acheong08 / ChatGPT

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

('Response is not in the correct format', 'Incorrect API key provided: Bearer. You can find your API key at https://beta.openai.com.') #72

Closed mazzzystar closed 1 year ago

mazzzystar commented 1 year ago
Logging in...

You:
Hi

Chatbot:
Something went wrong!
list index out of range
pip3 install revChatGPT --upgrade
Requirement already satisfied: revChatGPT in /opt/homebrew/lib/python3.9/site-packages (0.0.26.1)
acheong08 commented 1 year ago

Do python3 -m revChatGPT --text. If that works, it means there is an error with streaming

mazzzystar commented 1 year ago
Logging in...

You:
Hi

Chatbot:
/Users/Library/Python/3.9/lib/python/site-packages/bs4/__init__.py:435: MarkupResemblesLocatorWarning: The input looks more like a filename than markup. You may want to open this file and pass the filehandle into Beautiful Soup.
  warnings.warn(
Something went wrong!
('Response is not in the correct format', 'Incorrect API key provided: Bearer. You can find your API key at https://beta.openai.com.')

It needs API Key, I thought it could be done with only email & password

acheong08 commented 1 year ago

It shouldn't. This could mean wrong email/password

mazzzystar commented 1 year ago

I've confirmed of using this email+password to re-login OpenAI right now, and it's correct.

acheong08 commented 1 year ago

What version? pip3 show revChatGPT?

mazzzystar commented 1 year ago
>>> pip3 show revChatGPT
Name: revChatGPT
Version: 0.0.26.1
Summary: ChatGPT is a reverse engineering of OpenAI's ChatGPT API
Home-page: https://github.com/acheong08/ChatGPT
Author: Antonio Cheong
Author-email: acheong@student.dalat.org
License: GNU General Public License v2.0
Location: /opt/homebrew/lib/python3.9/site-packages
Requires: bs4, lxml, requests, tls-client
Required-by:
acheong08 commented 1 year ago

While running it, try !config and see if the tokens show up

mazzzystar commented 1 year ago
You:
!config

{
    "email": "xxx",
    "password": "xxx,
    "Authorization": "",
    "session_token": null
}
acheong08 commented 1 year ago

It's not logging in properly. Could be due to captcha. I am unsure.

acheong08 commented 1 year ago

Try !refresh and see if any errors show

mazzzystar commented 1 year ago
Logging in...

You:
!refresh

Error refreshing session
{}
Session refreshed.

I've also tried of removing all OpenAI's cookie on Chrome, still not working.

acheong08 commented 1 year ago

Error refreshing session

Hmm. Can you clone the repository and try adding some debug code? For example, print out the full responses of session refresh

acheong08 commented 1 year ago

I can't replicate

mazzzystar commented 1 year ago

OK, I'll try and put on more information.

yumusb commented 1 year ago

<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>Microsoft

The request is blocked.

xxxxxx

Maybe block by waf, or other bot manager ?

mazzzystar commented 1 year ago

BTW, It's confusing that your config.json.example shows

{
    "Authorization": "<API_KEY>",
    "session_token": "<SESSION_TOKEN>"
}

But the Setup was using

{
    "email": "<YOUR_EMAIL>",
    "password": "<YOUR_PASSWORD>"
}
acheong08 commented 1 year ago

@yumusb Update please. pip3 install revChatGPT --upgrade

acheong08 commented 1 year ago

BTW, It's confusing that your config.json.example shows

{
    "Authorization": "<API_KEY>",
    "session_token": "<SESSION_TOKEN>"
}

But the Setup was using

{
    "email": "<YOUR_EMAIL>",
    "password": "<YOUR_PASSWORD>"
}

I forgot to update the example

acheong08 commented 1 year ago

btw I found the error. Fixing now

acheong08 commented 1 year ago

Fixed. Please test @mazzzystar pip3 install --upgrade revChatGPT

zjrwtx commented 1 year ago

well ,it seems that !config doesnt work in my CLI

image

acheong08 commented 1 year ago

@zjrwtx It seems you haven't updated. pip3 install --upgrade revChatGPT

!config doesn't require API

alberduris commented 1 year ago

It works for me on the CLI but I get the same error when using the Python script

from revChatGPT.revChatGPT import Chatbot

config = {
    "email": "xxx",
    "password": "xxx"#,
    #"session_token": "<SESSION_TOKEN>", # Deprecated. Use only if you encounter captcha with email/password
    #"proxy": "<HTTP/HTTPS_PROXY>"
}

chatbot = Chatbot(config, conversation_id=None)

prompt = "Javascript library for cropping images programatically"

chatbot.get_chat_response(prompt, output="text")

Output:

/home/alber/Desktop/ChatGPTApp/chatgpt_venv/lib/python3.10/site-packages/bs4/__init__.py:435: MarkupResemblesLocatorWarning: The input looks more like a filename than markup. You may want to open this file and pass the filehandle into Beautiful Soup.
  warnings.warn(
Traceback (most recent call last):
  File "/home/alber/Desktop/ChatGPTApp/chatgpt_venv/lib/python3.10/site-packages/revChatGPT/revChatGPT.py", line 74, in get_chat_text
    response = response.text.splitlines()[-4]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/alber/Desktop/ChatGPTApp/test.py", line 14, in <module>
    chatbot.get_chat_response(prompt, output="text")
  File "/home/alber/Desktop/ChatGPTApp/chatgpt_venv/lib/python3.10/site-packages/revChatGPT/revChatGPT.py", line 109, in get_chat_response
    return self.get_chat_text(data)
  File "/home/alber/Desktop/ChatGPTApp/chatgpt_venv/lib/python3.10/site-packages/revChatGPT/revChatGPT.py", line 87, in get_chat_text
    raise ValueError("Response is not in the correct format", error_desp)
ValueError: ('Response is not in the correct format', 'Incorrect API key provided: Bearer. You can find your API key at https://beta.openai.com.')

I am using the latest release of revChatGPT

pip3 show revChatGPT

Name: revChatGPT
Version: 0.0.27
Summary: ChatGPT is a reverse engineering of OpenAI's ChatGPT API
Home-page: https://github.com/acheong08/ChatGPT
Author: Antonio Cheong
Author-email: acheong@student.dalat.org
License: GNU General Public License v2.0
Location: /home/alber/Desktop/ChatGPTApp/chatgpt_venv/lib/python3.10/site-packages
Requires: bs4, lxml, requests, tls-client
Required-by: 
mazzzystar commented 1 year ago

I've upgraded to 0.0.27, however, it still doesn't work.

python3 -m revChatGPT --text

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

Type '!help' to show commands
Press enter twice to submit your question.

Error refreshing session
{}

You:
Hi

Chatbot:
Something went wrong!
('Response is not in the correct format', 'Incorrect API key provided: <API_KEY>. You can find your API key at https://beta.openai.com.')
acheong08 commented 1 year ago

It's not logging in. This is the normal output:

 $ python3 -m revChatGPT

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

Type '!help' to show commands
Press enter twice to submit your question.

Logging in...

You:

If it isn't I'm guessing there's something wrong with your config. Do !config and show the censored output

mazzzystar commented 1 year ago

Thanks for the quick reply.

python3 -m revChatGPT --text

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

Type '!help' to show commands
Press enter twice to submit your question.

Logging in...
Error refreshing session:
'OpenAIAuth' object has no attribute 'session_token'

You:
Hi

Chatbot:
/Users/Library/Python/3.9/lib/python/site-packages/bs4/__init__.py:435: MarkupResemblesLocatorWarning: The input looks more like a filename than markup. You may want to open this file and pass the filehandle into Beautiful Soup.
  warnings.warn(
Something went wrong!
('Response is not in the correct format', 'Incorrect API key provided: Bearer. You can find your API key at https://beta.openai.com.')

You:
acheong08 commented 1 year ago

@mazzzystar

Token issue. Looking into it

acheong08 commented 1 year ago

@alberduris bad documentation sorry

from revChatGPT.revChatGPT import Chatbot

config = {
    "email": "xxx",
    "password": "xxx"
}

chatbot = Chatbot(config, conversation_id=None)

chatbot.refresh_session()

prompt = "Javascript library for cropping images programatically"

print(chatbot.get_chat_response(prompt, output="text")['message'])
acheong08 commented 1 year ago

@mazzzystar Please show censored output of !config.

mazzzystar commented 1 year ago
Logging in...
Error refreshing session:
'OpenAIAuth' object has no attribute 'session_token'

You:
!config

{
    "email": "xxx",
    "password": "xxx",
    "Authorization": null
}
acheong08 commented 1 year ago

Probably incorrect email/password. That is the only reason session_token would not exist

mazzzystar commented 1 year ago

However, just now I logged out OpenAI, and use the email/password below to login, it succeeded.

!config

{
    "email": "xxx",
    "password": "xxx",
    "Authorization": null
}
acheong08 commented 1 year ago

Replicated with wrong email and password

 $ python3 -m revChatGPT --text

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

Type '!help' to show commands
Press enter twice to submit your question.

Logging in...
Error refreshing session: 
'OpenAIAuth' object has no attribute 'session_token'

You:

Adding better error output

mazzzystar commented 1 year ago

Can you figure out this issue when I run python3 -m revChatGPT --text?

'OpenAIAuth' object has no attribute 'session_token'
acheong08 commented 1 year ago

Can you figure out this issue when I run python3 -m revChatGPT --text?

'OpenAIAuth' object has no attribute 'session_token'

With --text and without does the exact same thing with auth. Should work now if it works without --text

yumusb commented 1 year ago

If there are a lot of people having that problem. Then you should not simply assume that it is an account password error. You should type specific log messages in the code to resolve the problem.

mazzzystar commented 1 year ago

@yumusb @acheong08 I will try to print some logs

acheong08 commented 1 year ago

@yumusb I get that error if I enter the wrong password. I am currently looking through the error handlers to spot where it is going wrong

yumusb commented 1 year ago
Microsoft ## The request is blocked. xxxxxx Maybe block by waf, or other bot manager ?

This is my response, not found some error about "wrong password". I think it 's waf return.

acheong08 commented 1 year ago

This is my response, not found some error about "wrong password". I think it 's waf return.

This happens when user agent isn't set or if you're in China.

User agent has been set since version 0.0.24.

acheong08 commented 1 year ago

@yumusb Chould you show the output of pip3 show revChatGPT?

acheong08 commented 1 year ago

This happens when user agent isn't set or if you're in China.

I have to use a VPN to use ChatGPT

yumusb commented 1 year ago
image

You can write a code to judge return html does have "Wrong email or password" to judge the wrong password.

yumusb commented 1 year ago

@yumusb Chould you show the output of pip3 show revChatGPT?

pip3 show revChatGPT Name: revChatGPT Version: 0.0.27 Summary: ChatGPT is a reverse engineering of OpenAI's ChatGPT API Home-page: https://github.com/acheong08/ChatGPT Author: Antonio Cheong Author-email: acheong@student.dalat.org License: GNU General Public License v2.0 Location: /usr/local/lib/python3.9/site-packages Requires: bs4, lxml, requests, tls-client Required-by:

acheong08 commented 1 year ago

Since it's updated, I think you're correct that it's a waf or geographical blocking

yumusb commented 1 year ago

This happens when user agent isn't set or if you're in China.

I have to use a VPN to use ChatGPT

Me too. And the proxy works in Chrome.

yumusb commented 1 year ago

My proxy IP address is Korea. And I can use chatgpt normally with my browser.

acheong08 commented 1 year ago
image

You can write a code to judge return html does have "Wrong email or password" to judge the wrong password.

Do you mind writing this? I can't figure it out and my brain is burnt out.

yumusb commented 1 year ago

I am trying to write the code, but found that I can use it properly. But I haven't changed config.json ...

acheong08 commented 1 year ago

Nevermind. I got it