Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'KeyError: None' when running main.py #44

Closed
Cerisk opened this issue May 1, 2023 · 2 comments
Closed

'KeyError: None' when running main.py #44

Cerisk opened this issue May 1, 2023 · 2 comments

Comments

@Cerisk
Copy link

Cerisk commented May 1, 2023

Recently I was getting an error (the could not encode error) that was fixed with the latest release of PentestGPT. I am now getting an error that says this when I run it with the command (python3 main.py --reasoning_model=gpt-4 --useAPI=False):

`python3 main.py --reasoning_model=gpt-4 --useAPI=False

  • ChatGPT Sessions Initialized.
    Please describe the penetration testing task in one line, including the target IP, task type, etc.

i want to test 10.10.11.189
Traceback (most recent call last):
File "/Users/gold/Documents/Programs/PentestGPT/main.py", line 25, in
pentestGPTHandler.main()
File "/Users/gold/Documents/Programs/PentestGPT/utils/pentest_gpt.py", line 466, in main
_response = self.reasoning_handler(prefixed_init_description)
File "/Users/gold/Documents/Programs/PentestGPT/utils/pentest_gpt.py", line 128, in reasoning_handler
response = self.chatGPT4Agent.send_message(
File "/Users/gold/Documents/Programs/PentestGPT/utils/chatgpt_api.py", line 92, in send_message
conversation = self.conversation_dict[conversation_id]
KeyError: None`

Again, this seems to be an error that may relate to the cookie and the ability for the program to send and receive messages from ChatGPT. I do have a ChatGPT plus so that is not the issue (using the cookie for GPT-4). I will check later if it is working on my Windows device still.

@r1cs3c
Copy link

r1cs3c commented May 1, 2023

I raised a new issue by mistake, moving text here and closing the issue. I have the same problem and I have plus. Here is my description:

Trying to test the new changes to the tool, I run into the following error as soon as I tried. As you can see test_connection seems to work:

python3 test_connection.py 
#### Test connection for chatgpt cookie
1. You're connected with ChatGPT Plus cookie. 
To start PentestGPT, please use <python3 main.py --reasoning_model=gpt-4 --useAPI=False>
#### Test connection for OpenAI api (GPT-4)
The OpenAI API key is not properly configured. Please follow README to update OpenAI API key in config/chatgpt_config.py
#### Test connection for OpenAI api (GPT-3.5)
The OpenAI API key is not properly configured. Please follow README to update OpenAI API key in config/chatgpt_config.py

but main doesn't:

python3 main.py --reasoning_model=gpt-4 --useAPI=False
- ChatGPT Sessions Initialized.
Please describe the penetration testing task in one line, including the target IP, task type, e
> test localhost 127.0.0.1
Traceback (most recent call last):
  File "/media/psf/Documents/GitHub/PentestGPT/main.py", line 25, in <module>
    pentestGPTHandler.main()
  File "/media/psf/Documents/GitHub/PentestGPT/utils/pentest_gpt.py", line 466, in main
    _response = self.reasoning_handler(prefixed_init_description)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/media/psf/Documents/GitHub/PentestGPT/utils/pentest_gpt.py", line 128, in reasoning_handler
    response = self.chatGPT4Agent.send_message(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/media/psf/Documents/GitHub/PentestGPT/utils/chatgpt_api.py", line 92, in send_message
    conversation = self.conversation_dict[conversation_id]
                   ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
KeyError: None

@GreyDGL
Copy link
Owner

GreyDGL commented May 2, 2023

This problem should be fixed. You may refer to the latest documentation. Note that there is a change in the tool usage. Now --useAPI does not require input params. If you use OpenAI API, you can do it with python3 main.py --reasoning_model=gpt-4 --useAPI. Otherwise, just use python3 main.py --reasoning_model=gpt-4.

@GreyDGL GreyDGL closed this as completed May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants