项目文件夹

文件
2024-10-21 17:22:27 +08:00

37 行
926 B
Python

# modules/state.py
# handler that maintains the internal states of all the variables in PentestGPT.
class State:
def __init__(self):
self.variables = {}
self.history = {
"user": [],
"pentestGPT": [],
"reasoning": [],
"input_parsing": [],
"generation": [],
"exception": [],
}
def set_variable(self, key, value):
self.variables[key] = value
def get_variable(self, key):
return self.variables.get(key, None)
def show_all(self):
return self.variables
def clear_variable(self, key):
if key in self.variables:
del self.variables[key]
def log_conversation(self, source, text):
from time import time
timestamp = time()
if source not in self.history:
source = "exception"
self.history[source].append((timestamp, text))