GreyDGL / PentestGPT

A GPT-empowered penetration testing tool
MIT License
7.29k stars 886 forks source link

conversation_id KeyError: None #198

Closed A6y55 closed 8 months ago

A6y55 commented 8 months ago

I use one-api(https://github.com/songquanpeng/one-api) to manage my openai api. Then I run pentestgpt as follow:

Screenshot 2024-03-11 at 10 58 24

seems that conversation_id is None, how can I fix that ?

Error: `Traceback (most recent call last): File "/usr/local/lib/python3.11/dist-packages/tenacity/init.py", line 382, in call result = fn(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^ File "/home/a6y55/PentestGPT/pentestgpt/utils/llm_api.py", line 253, in send_message conversation = self.conversation_dict[conversation_id]


KeyError: None

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

Traceback (most recent call last):
  File "/usr/local/bin/pentestgpt", line 33, in <module>
    sys.exit(load_entry_point('pentestgpt', 'console_scripts', 'pentestgpt')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/a6y55/PentestGPT/pentestgpt/main.py", line 61, in main
    pentestGPTHandler.main()
  File "/home/a6y55/PentestGPT/pentestgpt/utils/pentest_gpt.py", line 731, in main
    self.initialize(previous_session_ids=loaded_ids)
  File "/home/a6y55/PentestGPT/pentestgpt/utils/pentest_gpt.py", line 260, in initialize
    self._feed_init_prompts()
  File "/home/a6y55/PentestGPT/pentestgpt/utils/pentest_gpt.py", line 187, in _feed_init_prompts
    _reasoning_response = self.reasoningAgent.send_message(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/tenacity/__init__.py", line 289, in wrapped_f
    return self(f, *args, **kw)
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/tenacity/__init__.py", line 379, in __call__
    do = self.iter(retry_state=retry_state)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/tenacity/__init__.py", line 326, in iter
    raise retry_exc from fut.exception()
tenacity.RetryError: RetryError[<Future at 0x7f82fc972150 state=finished raised KeyError>]`
GreyDGL commented 8 months ago

Let me check on this one. It seems that PentestGPT just cannot get connection to the API; could you check if you set the correct baseurl when running the tool? Meanwhile I'll do some local testing and get back to this.

JiahaoLi2003 commented 7 months ago

Hi! I got the same error, is there any solution?

sti1l-0 commented 7 months ago

same error

A6y55 commented 7 months ago

Hi! I got the same error, is there any solution?

If you use a third-party APIs, you need to modify two files: One is utils/APIs/chatgpt_api.py,change openai.api_base = config_class.api_base to openai.api_base = "your_api_base/v1" The other is /config/chat_config.py,change api_base: str = os.getenv("OPENAI_BASEURL", "https://api.openai.com/v1") to api_base: str = "your_api_base/v1" This can solve my problem.

A6y55 commented 7 months ago

same error

Hello, try the above solution.