Skip to content

Commit 7f72bfb

Browse files
committed
Beautifying shell output
1 parent ca75997 commit 7f72bfb

File tree

4 files changed

+173
-161
lines changed

4 files changed

+173
-161
lines changed

.gitignore

Lines changed: 141 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -1,138 +1,141 @@
1-
# Byte-compiled / optimized / DLL files
2-
__pycache__/
3-
*.py[cod]
4-
*$py.class
5-
6-
# C extensions
7-
*.so
8-
9-
# Distribution / packaging
10-
.Python
11-
build/
12-
develop-eggs/
13-
dist/
14-
downloads/
15-
eggs/
16-
.eggs/
17-
lib/
18-
lib64/
19-
parts/
20-
sdist/
21-
var/
22-
wheels/
23-
pip-wheel-metadata/
24-
share/python-wheels/
25-
*.egg-info/
26-
.installed.cfg
27-
*.egg
28-
MANIFEST
29-
30-
# PyInstaller
31-
# Usually these files are written by a python script from a template
32-
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33-
*.manifest
34-
*.spec
35-
36-
# Installer logs
37-
pip-log.txt
38-
pip-delete-this-directory.txt
39-
40-
# Unit test / coverage reports
41-
htmlcov/
42-
.tox/
43-
.nox/
44-
.coverage
45-
.coverage.*
46-
.cache
47-
nosetests.xml
48-
coverage.xml
49-
*.cover
50-
*.py,cover
51-
.hypothesis/
52-
.pytest_cache/
53-
54-
# Translations
55-
*.mo
56-
*.pot
57-
58-
# Django stuff:
59-
*.log
60-
local_settings.py
61-
db.sqlite3
62-
db.sqlite3-journal
63-
64-
# Flask stuff:
65-
instance/
66-
.webassets-cache
67-
68-
# Scrapy stuff:
69-
.scrapy
70-
71-
# Sphinx documentation
72-
docs/_build/
73-
74-
# PyBuilder
75-
target/
76-
77-
# Jupyter Notebook
78-
.ipynb_checkpoints
79-
80-
# IPython
81-
profile_default/
82-
ipython_config.py
83-
84-
# pyenv
85-
.python-version
86-
87-
# pipenv
88-
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89-
# However, in case of collaboration, if having platform-specific dependencies or dependencies
90-
# having no cross-platform support, pipenv may install dependencies that don't work, or not
91-
# install all needed dependencies.
92-
#Pipfile.lock
93-
94-
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
95-
__pypackages__/
96-
97-
# Celery stuff
98-
celerybeat-schedule
99-
celerybeat.pid
100-
101-
# SageMath parsed files
102-
*.sage.py
103-
104-
# Environments
105-
.env
106-
.venv
107-
env/
108-
venv/
109-
ENV/
110-
env.bak/
111-
venv.bak/
112-
113-
# Spyder project settings
114-
.spyderproject
115-
.spyproject
116-
117-
# Rope project settings
118-
.ropeproject
119-
120-
# mkdocs documentation
121-
/site
122-
123-
# mypy
124-
.mypy_cache/
125-
.dmypy.json
126-
dmypy.json
127-
128-
# Pyre type checker
129-
.pyre/
130-
131-
# Misc
132-
.sqlite3
133-
.bin
134-
src/rags
135-
src/test_results
136-
curent_five_turns.jsonl
137-
other_curent_five_turns.jsonl
138-
redundant_code.py
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
*.py,cover
51+
.hypothesis/
52+
.pytest_cache/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
target/
76+
77+
# Jupyter Notebook
78+
.ipynb_checkpoints
79+
80+
# IPython
81+
profile_default/
82+
ipython_config.py
83+
84+
# pyenv
85+
.python-version
86+
87+
# pipenv
88+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
90+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
91+
# install all needed dependencies.
92+
#Pipfile.lock
93+
94+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
95+
__pypackages__/
96+
97+
# Celery stuff
98+
celerybeat-schedule
99+
celerybeat.pid
100+
101+
# SageMath parsed files
102+
*.sage.py
103+
104+
# Environments
105+
.env
106+
.venv
107+
env/
108+
venv/
109+
ENV/
110+
env.bak/
111+
venv.bak/
112+
g.env
113+
114+
# Spyder project settings
115+
.spyderproject
116+
.spyproject
117+
118+
# Rope project settings
119+
.ropeproject
120+
121+
# mkdocs documentation
122+
/site
123+
124+
# mypy
125+
.mypy_cache/
126+
.dmypy.json
127+
dmypy.json
128+
129+
# Pyre type checker
130+
.pyre/
131+
132+
# Misc
133+
.sqlite3
134+
.bin
135+
src/rags
136+
src/test_results
137+
curent_five_turns.jsonl
138+
other_curent_five_turns.jsonl
139+
redundant_code.py
140+
index_freq.py
141+
jailbreak_freq.py

jailbreaks_and_PIs.txt

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
Ignore Attack - Context Ignoring
2-
Escape Character Attack
3-
Completion Attacks
4-
HackAPrompt
5-
Prefix Injection
6-
Hidden_Attack
7-
Refusal Suppression
8-
GoodBot-BadBot
9-
DAN (Do Anything Now)
10-
Style Injection
11-
Base64 Jailbreak
12-
Response Priming
13-
Combination of Jailbreaks
14-
Leetspeak
15-
Opposite Intent
16-
Dev_Mode
17-
Evil_Sytem
18-
Inverted Instruction
1+
Ignore Attack - Context Ignoring
2+
Escape Character Attack
3+
Completion Attacks
4+
HackAPrompt
5+
Prefix Injection
6+
Hidden_Attack
7+
Refusal Suppression
8+
GoodBot-BadBot
9+
DAN (Do Anything Now)
10+
Style Injection
11+
Response Priming
12+
Combination of Jailbreaks
13+
Leetspeak
14+
Opposite Intent
15+
Dev_Mode
16+
Evil_Sytem
17+
Inverted Instruction
18+
Base64 Jailbreak

src/llm_executor.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@
66
import os
77
import random
88
import requests
9+
from rich.console import Console
10+
from rich.panel import Panel
911
import setup
1012
import string
1113
import sys
1214
import yaml
1315
import google.generativeai as genai
1416

17+
console = Console()
18+
1519
genai.configure(api_key="AIzaSyATRofXI_xK5Gz6TFeppSvw6Zag9xmXd4c")
1620

1721

@@ -172,7 +176,7 @@ def send_request(api_used, model_used, config_path, history_path, task, jailbrea
172176
message_for_evaluator = {"role": 'assistant', "content": msg}
173177
message_for_lambda = msg
174178

175-
print(f"\nR: {message_for_lambda}\n")
179+
console.print(Panel.fit(f"\n[bold red]REQUEST: [/bold red]{message_for_lambda}\n"))
176180

177181
other_messages.append({"role": "user", "content": message_for_lambda})
178182

@@ -184,7 +188,7 @@ def send_request(api_used, model_used, config_path, history_path, task, jailbrea
184188
lambda_output = call_openai_api(other_messages, target)
185189
elif setup.target == "local":
186190
lambda_output = call_gemini_api(other_messages, target)
187-
print(f"A: {lambda_output}\n")
191+
console.print(Panel.fit(f"\n[bold blue]ANSWER: [/bold blue]{lambda_output}\n"))
188192

189193
messages.append({"role": "user", "content": lambda_output})
190194
other_messages.append({"role": "assistant", "content": lambda_output})

src/llm_planner.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,16 @@
1111
import os
1212
import random
1313
import re
14+
from rich.console import Console
15+
from rich.panel import Panel
16+
from rich.table import Table
1417
import setup
1518
import string
1619
import sys
1720
import yaml
1821

22+
console = Console()
23+
1924

2025
def check_openai():
2126
if not openai.api_key:
@@ -337,7 +342,7 @@ def get_step_for_evaluator(conversation_context, jsonl_path, turn, messages, lin
337342

338343
message_for_evaluator = msg
339344

340-
print(f"\n---\n{message_for_evaluator}\n")
345+
console.print(Panel.fit(f"\n---\n[bold yellow]Strategy[/bold yellow]\n{message_for_evaluator}\n"))
341346

342347
except Exception as e:
343348
print("There was a little inchident. Please try again!\n")
@@ -440,7 +445,7 @@ def evlolve_tactic(history_path, conversations_history, initial_tactic, victory,
440445
plan_text = get_step_explanation(plan, turn)
441446
changes.append(change)
442447

443-
print(f"{plan_text}\n---\n")
448+
console.print(Panel.fit(f"[bold yellow]Step[/bold yellow]\n{plan_text}\n---\n"))
444449

445450
lambda_turn, one_turn = llm_executor.send_request(api_used, model_used, config_path, history_path, s_task, s_jailbreak, s_pdf_context, plan_text, step, session_id, turn, "gpt-4o-mini")
446451

@@ -519,7 +524,7 @@ def engage_llm(api_used, model_used, config_path, history_path):
519524
# tactic.append({"step": step})
520525

521526
plan_text = get_step_explanation(plan, turn)
522-
print(f"{plan_text}\n---\n")
527+
console.print(Panel.fit(f"[bold yellow]Step[/bold yellow]\n{plan_text}\n---\n"))
523528

524529
lambda_turn, one_turn = llm_executor.send_request(api_used, model_used, config_path, history_path, task, jailbreak, pdf_context, plan_text, step, session_id, turn, "gpt-4o-mini")
525530

0 commit comments

Comments
 (0)