GreyDGL/PentestGPT

Azure API Bug

Opened this issue · 3 comments

skypoc commented

Hello, I encountered some difficulties while using it, so I would like to ask for your advice.

Describe the bug
export OPENAI_KEY= 'My Azure API'
Then
pentestgpt-connection --baseURL https://{MY-resource-name}.openai.azure.com/openai/deployments/{MY-deployment-id}/completions?api-version={2023-07-01-preview}

The following error occurred

Your CHATGPT_COOKIE is not set. Please set it in the environment variable.
You're testing the connection for PentestGPT v 0.11.0
#### Test connection for OpenAI api (GPT-4)
Traceback (most recent call last):
  File "/Users/mypc/venv/lib/python3.9/site-packages/pentestgpt/utils/APIs/chatgpt_api.py", line 81, in _chat_completion
    response = openai.ChatCompletion.create(
  File "/Users/mypc/venv/lib/python3.9/site-packages/openai/api_resources/chat_completion.py", line 25, in create
    return super().create(*args, **kwargs)
  File "/Users/mypc/venv/lib/python3.9/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 153, in create
    response, _, api_key = requestor.request(
  File "/Users/mypc/venv/lib/python3.9/site-packages/openai/api_requestor.py", line 298, in request
    resp, got_stream = self._interpret_response(result, stream)
  File "/Users/mypc/venv/lib/python3.9/site-packages/openai/api_requestor.py", line 700, in _interpret_response
    self._interpret_response_line(
  File "/Users/mypc/venv/lib/python3.9/site-packages/openai/api_requestor.py", line 765, in _interpret_response_line
    raise self.handle_error_response(
openai.error.InvalidRequestError: Resource not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/mypc/venv/bin/pentestgpt-connection", line 8, in <module>
    sys.exit(main())
  File "/Users/mypc/venv/lib/python3.9/site-packages/pentestgpt/test_connection.py", line 47, in main
    result, conversation_id = chatgpt.send_new_message("Hi how are you?")
  File "/Users/mypc/venv/lib/python3.9/site-packages/pentestgpt/utils/llm_api.py", line 225, in send_new_message
    response = self._chat_completion(history)
  File "/Users/mypc/venv/lib/python3.9/site-packages/pentestgpt/utils/APIs/chatgpt_api.py", line 119, in _chat_completion
    response = openai.ChatCompletion.create(
  File "/Users/mypc/venv/lib/python3.9/site-packages/openai/api_resources/chat_completion.py", line 25, in create
    return super().create(*args, **kwargs)
  File "/Users/mypc/venv/lib/python3.9/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 153, in create
    response, _, api_key = requestor.request(
  File "/Users/mypc/venv/lib/python3.9/site-packages/openai/api_requestor.py", line 298, in request
    resp, got_stream = self._interpret_response(result, stream)
  File "/Users/mypc/venv/lib/python3.9/site-packages/openai/api_requestor.py", line 700, in _interpret_response
    self._interpret_response_line(
  File "/Users/mypc/venv/lib/python3.9/site-packages/openai/api_requestor.py", line 765, in _interpret_response_line
    raise self.handle_error_response(
openai.error.InvalidRequestError: Resource not found

I can be sure that there is no problem with my API and URL, it can be used.

Version
GPT-4

Thank you very much.

Hey there, sorry I don't have an API key for Azure, so I cannot do debugging/fixing right now.
I'll find some way to test it with Azure and update the code.

thank you so much!

I have the same error, how should it be configured using the Azure API? Thanks