-
-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix missing 1 required positional argument bug & sqlite3.operationalerror: database is locked issue #78
base: main
Are you sure you want to change the base?
fix missing 1 required positional argument bug & sqlite3.operationalerror: database is locked issue #78
Changes from all commits
c8cab9c
6644f99
70ea983
66340e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,6 @@ def init(self): | |
self.add_capability(SSHRunCommand(conn=self.conn), default=True) | ||
self.add_capability(SSHTestCredential(conn=self.conn)) | ||
self._template_size = self.llm.count_tokens(template_next_cmd.source) | ||
|
||
def perform_round(self, turn): | ||
got_root : bool = False | ||
|
||
|
@@ -39,13 +38,27 @@ def perform_round(self, turn): | |
cmd = llm_util.cmd_output_fixer(answer.result) | ||
|
||
with self.console.status("[bold green]Executing that command..."): | ||
self.console.print(Panel(answer.result, title="[bold cyan]Got command from LLM:")) | ||
result, got_root = self.get_capability(cmd.split(" ", 1)[0])(cmd) | ||
self.console.print(Panel(answer.result, title="[bold cyan]Got command from LLM:")) | ||
|
||
# Assuming cmd is of the form "username password" | ||
parts = cmd.split(" ", 1) | ||
if len(parts) == 2: | ||
username, password = parts | ||
##here fix! | ||
result, got_root = self.get_capability("test_credential")(username, password) | ||
else: | ||
# Handle other cases or log error | ||
result = "Command format error. Expected 'username password'." | ||
got_root = False | ||
|
||
# log and output the command and its result | ||
self.log_db.add_log_query(self._run_id, turn, cmd, result, answer) | ||
self._sliding_history.add_command(cmd, result) | ||
self.console.print(Panel(result, title=f"[bold cyan]{cmd}")) | ||
#self.log_db.add_log_query(self._run_id, cmd, result, answer) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this looks wrong, wouldn't this only call test_credentials and not execute_command anymore? |
||
self.log_db.add_log_query(self._run_id, turn, cmd, result, answer) | ||
self._sliding_history.add_command(cmd, result) | ||
self.console.print(Panel(result, title=f"[bold cyan]{cmd}")) | ||
|
||
# if we got root, we can stop the loop | ||
return got_root | ||
|
||
|
||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,10 +11,12 @@ def __init__(self, connection_string: str = parameter(desc="sqlite3 database con | |
def init(self): | ||
self.connect() | ||
self.setup_db() | ||
|
||
def connect(self): | ||
self.db = sqlite3.connect(self.connection_string) | ||
# self.db = sqlite3.connect(self.connection_string, timeout=10) # Set timeout to 10 seconds | ||
self.db = sqlite3.connect(self.connection_string, check_same_thread=False, timeout=10) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is weird. I am trying to understand the error case. Are you running two instances of hackingBuddyGPT in parallel? This would not be supported by the sqlite3 database (that we are currently using). I think the clean solution would rather be to use a separate sqlite database per run (using the |
||
self.cursor = self.db.cursor() | ||
|
||
|
||
def insert_or_select_cmd(self, name: str) -> int: | ||
results = self.cursor.execute("SELECT id, name FROM commands WHERE name = ?", (name,)).fetchall() | ||
|
@@ -80,20 +82,21 @@ def setup_db(self): | |
self.query_cmd_id = self.insert_or_select_cmd('query_cmd') | ||
self.analyze_response_id = self.insert_or_select_cmd('analyze_response') | ||
self.state_update_id = self.insert_or_select_cmd('update_state') | ||
|
||
def create_new_run(self, model, context_size, tag): | ||
self.cursor.execute( | ||
"INSERT INTO runs (model, context_size, state, tag, started_at) VALUES (?, ?, ?, ?, datetime('now'))", | ||
(model, context_size, "in progress", tag)) | ||
return self.cursor.lastrowid | ||
with self.db: | ||
self.cursor.execute( | ||
"INSERT INTO runs (model, context_size, state, tag, started_at) VALUES (?, ?, ?, ?, datetime('now'))", | ||
(model, context_size, "in progress", tag)) | ||
return self.cursor.lastrowid | ||
|
||
def add_log_query(self, run_id, round, cmd, result, answer): | ||
self.cursor.execute( | ||
"INSERT INTO queries (run_id, round, cmd_id, query, response, duration, tokens_query, tokens_response, prompt, answer) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", | ||
( | ||
run_id, round, self.query_cmd_id, cmd, result, answer.duration, answer.tokens_query, answer.tokens_response, | ||
answer.prompt, answer.answer)) | ||
with self.db: | ||
self.cursor.execute( | ||
"INSERT INTO queries (run_id, round, cmd_id, query, response, duration, tokens_query, tokens_response, prompt, answer) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", | ||
(run_id, round, self.query_cmd_id, cmd, result, answer.duration, answer.tokens_query, answer.tokens_response, answer.prompt, answer.answer)) | ||
|
||
|
||
def add_log_analyze_response(self, run_id, round, cmd, result, answer): | ||
self.cursor.execute( | ||
"INSERT INTO queries (run_id, round, cmd_id, query, response, duration, tokens_query, tokens_response, prompt, answer) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", | ||
|
@@ -206,4 +209,4 @@ def run_was_failure(self, run_id, round): | |
self.db.commit() | ||
|
||
def commit(self): | ||
self.db.commit() | ||
self.db.commit() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove the comment