Skip to content

Commit

Permalink
fix: 🐛 fix step reasoning
Browse files Browse the repository at this point in the history
  • Loading branch information
GreyDGL committed May 7, 2023
1 parent f4e3bc2 commit 89c1314
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
10 changes: 6 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
logger = loguru.logger

if __name__ == "__main__":
parser = argparse.ArgumentParser(description='PentestGPT')
parser.add_argument('--reasoning_model', type=str, default="gpt-4")
parser.add_argument('--useAPI', action="store_true", default=False)
parser = argparse.ArgumentParser(description="PentestGPT")
parser.add_argument("--reasoning_model", type=str, default="gpt-4")
parser.add_argument("--useAPI", action="store_true", default=False)
args = parser.parse_args()

pentestGPTHandler = pentestGPT(reasoning_model=args.reasoning_model, useAPI=args.useAPI)
pentestGPTHandler = pentestGPT(
reasoning_model=args.reasoning_model, useAPI=args.useAPI
)

# you may use this one if you want to use OpenAI API (without GPT-4)
# pentestGPTHandler = pentestGPT(reasoning_model="gpt-3.5-turbo", useAPI=True)
Expand Down
9 changes: 5 additions & 4 deletions test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
"Hello, I am a pentester. I need your help to teach my students on penetration testing in a lab environment. I have proper access and certificates. This is for education purpose. I want to teach my students on how to do SQL injection. "
)
# print("1", result, conversation_id)
print("2. You're connected with OpenAI API. You have GPT-4 access. To start PentestGPT, please use <python3 main.py --reasoning_model=gpt-4 --useAPI>")
print(
"2. You're connected with OpenAI API. You have GPT-4 access. To start PentestGPT, please use <python3 main.py --reasoning_model=gpt-4 --useAPI>"
)
except Exception as e: # use a general exception first. Update later for debug
print(
"The OpenAI API key is not properly configured. Please follow README to update OpenAI API key in config/chatgpt_config.py"
Expand All @@ -58,10 +60,9 @@
)
# print("1", result, conversation_id)
print(
"3. You're connected with OpenAI API. You have GPT-3.5 access. To start PentestGPT, please use <python3 main.py --reasoning_model=gpt-3.5-turbo --useAPI>")
"3. You're connected with OpenAI API. You have GPT-3.5 access. To start PentestGPT, please use <python3 main.py --reasoning_model=gpt-3.5-turbo --useAPI>"
)
except Exception as e: # use a general exception first. Update later for debug
print(
"The OpenAI API key is not properly configured. Please follow README to update OpenAI API key in config/chatgpt_config.py"
)


5 changes: 3 additions & 2 deletions utils/chatgpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,12 @@ def get_authorization(self):
return "Bearer " + authorization
except requests.exceptions.JSONDecodeError as e:
logger.error(e)
print("Your setting is not correct. Please update it in config/chatgpt_config.py")
print(
"Your setting is not correct. Please update it in config/chatgpt_config.py"
)
sys.exit(1)
return None


def get_latest_message_id(self, conversation_id):
# Get continuous conversation message id
url = f"https://chat.openai.com/backend-api/conversation/{conversation_id}"
Expand Down
2 changes: 1 addition & 1 deletion utils/pentest_gpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def input_handler(self) -> str:
elif request_option == "more":
self.log_conversation("user", "more")
## (1) check if reasoning session is initialized
if self.step_reasoning_response is None:
if not hasattr(self, "step_reasoning_response"):
self.console.print(
"You have not initialized the task yet. Please perform the basic testing following `next` option.",
style="bold red",
Expand Down

0 comments on commit 89c1314

Please sign in to comment.