Skip to content

Commit e2c12c6

Browse files
authored
Merge pull request #18 from jfelten/issue-17
Issue 17 - add flag to disable danger check
2 parents 450a70f + fe3c0a2 commit e2c12c6

4 files changed

Lines changed: 22 additions & 12 deletions

File tree

browserpilot/agents/compilers/instruction_compiler.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ def __init__(
8787
base_prompt=BASE_PROMPT,
8888
model="gpt-4o-mini",
8989
use_compiled=True,
90+
disable_danger_check=False,
9091
):
9192
"""Initialize the compiler. The compiler handles the sequencing of
9293
each set of instructions which are injected into the base prompt.
@@ -125,6 +126,7 @@ def __init__(
125126
self.functions = {} # Set in _parse_instructions_into_queue.
126127
self.finished_instructions = []
127128
self.history = [] # Keep track of the history of actions.
129+
self.disable_danger_check = disable_danger_check
128130

129131
# Set the instructions.
130132
self.instructions = instructions # Overriden in set_instructions.
@@ -337,7 +339,8 @@ def get_action_output(self, instructions):
337339
prompt = self.base_prompt.format(instructions=instructions)
338340
completion = self.get_completion(prompt).strip()
339341
action_output = completion.strip()
340-
lines = [line for line in action_output.split("\n") if not line.startswith("import ")]
342+
print(self.disable_danger_check)
343+
lines = [line for line in action_output.split("\n") if (self.disable_danger_check is False or not line.startswith("import "))]
341344
action_output = "\n".join(lines)
342345
return {
343346
"instruction": instructions,

browserpilot/agents/gpt_selenium_agent.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ def __init__(
5656
debug_html_folder="",
5757
instruction_output_file=None,
5858
close_after_completion=True,
59-
remote_url=None,
59+
remote_url=None,
60+
disable_danger_check=False,
6061
):
6162
"""Initialize the agent.
6263
@@ -104,11 +105,13 @@ def __init__(
104105
self.memory_folder = memory_folder
105106
self.close_after_completion = close_after_completion
106107
self.remote_url = remote_url
108+
self.disable_danger_check = disable_danger_check
107109

108110
"""Fire up the compiler."""
109111
self.instruction_compiler = InstructionCompiler(
110112
instructions=instructions,
111113
model=self.model_for_instructions,
114+
disable_danger_check = self.disable_danger_check,
112115
)
113116

114117
"""Set up the memory."""
@@ -148,7 +151,10 @@ def __init__(
148151

149152
def _check_danger(self, action_str):
150153
"""Check that the action is not dangerous. If so, just quit."""
151-
if self._is_potentially_dangerous(action_str):
154+
if (self.disable_danger_check is True):
155+
logger.warning("Code Danger checking is disabled")
156+
return
157+
if (self._is_potentially_dangerous(action_str)):
152158
logger.warning("Action is potentially dangerous. Exiting.")
153159
logger.warning(f"Action: {action_str}")
154160
sys.exit(1)

examples.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def selenium(instructions, chromedriver_path, model, memory_folder, debug, outpu
2727
memory_folder=memory_folder,
2828
debug=debug,
2929
retry=True,
30+
disable_danger_check=True
3031
)
3132
agent.run()
3233

pyproject.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
[tool.poetry]
22
name = "browserpilot"
3-
version = "0.2.52"
3+
version = "0.2.53"
44
description = "Natural language browser automation"
55
authors = ["Andrew Han <handrew11@gmail.com>"]
66
readme = "README.md"
77

88
[tool.poetry.dependencies]
9-
click = "^8.1.3"
9+
click = "^8.1.7"
1010
python = "^3.10"
11-
openai = "^1.13.3"
12-
selenium = "^4.8.2"
13-
tqdm = "^4.66.1"
11+
openai = "^1.55.0"
12+
selenium = "^4.26.1"
13+
tqdm = "^4.67.0"
1414
beautifulsoup4 = "^4.12.3"
15-
pyyaml = "^6.0"
16-
langchain = "^0.1.11"
17-
llama-index = "^0.10.16"
18-
langchain_openai = "^0.1.1"
15+
pyyaml = "^6.0.2"
16+
langchain = "^0.1.20"
17+
llama-index = "^0.10.68"
18+
langchain_openai = "^0.1.7"
1919

2020

2121
[build-system]

0 commit comments

Comments
 (0)