fix: 🐛 fix param parsing

This commit is contained in:
Grey_D 2023-05-02 10:45:32 +08:00
parent eefd478f5a
commit 3bed2c0360
3 changed files with 15 additions and 6 deletions

View File

@ -9,7 +9,7 @@ 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', type=bool, default=True)
parser.add_argument('--useAPI', action="store_true", default=False)
args = parser.parse_args()
pentestGPTHandler = pentestGPT(reasoning_model=args.reasoning_model, useAPI=args.useAPI)

File diff suppressed because one or more lines are too long

View File

@ -3,6 +3,7 @@
import dataclasses
import json
import re
import sys
import time
from typing import Any, Dict, List, Tuple
from uuid import uuid1
@ -97,11 +98,18 @@ class ChatGPT:
self.headers["authorization"] = self.get_authorization()
def get_authorization(self):
url = "https://chat.openai.com/api/auth/session"
r = requests.get(url, headers=self.headers)
authorization = r.json()["accessToken"]
# authorization = self.config.accessToken
return "Bearer " + authorization
try:
url = "https://chat.openai.com/api/auth/session"
r = requests.get(url, headers=self.headers)
authorization = r.json()["accessToken"]
# authorization = self.config.accessToken
return "Bearer " + authorization
except requests.exceptions.JSONDecodeError as e:
logger.error(e)
print("Your cookie 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