forked from harishsg993010/DamnVulnerableLLMProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
65 lines (59 loc) · 1.74 KB
/
main.py
File metadata and controls
65 lines (59 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import os
import sys
import select
import time
import subprocess
if "OPENAI_API_KEY" not in os.environ:
print("You must set an OPENAI_API_KEY using the Secrets tool",
file=sys.stderr)
else:
print("== OPENAI + REPLIT CUSTOM BOT==")
print("You have five seconds to select an option")
print()
print("1: Train Model\n2: Talk to your Bot\n3: Prompt Injection CTF MODE\n4: AISafety Bypass CTF MODE\n>",end="")
i, o, e = select.select([sys.stdin], [], [], 10)
print()
if (i):
choice = sys.stdin.readline().strip()
time.sleep(0.5)
os.system('clear')
if choice == "1":
print("BOT TRAINING MODE")
import process
process.train()
elif choice == "2":
print("BOT CONVERSATION MODE")
import process
process.runPrompt()
elif choice == "3":
print("Prompt Injection CTF MODE")
import level2
level2.runPrompt()
elif choice == "4":
print("AISafety Bypass CTF MODE")
import level3
level3.runPrompt()
else:
print("Booting into API Server…")
time.sleep(1)
os.system('clear')
print("BOT API SERVER RUNNING")
p = subprocess.Popen([sys.executable, 'server.py'],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
while True:
line = p.stdout.readline()
if not line: break
else:
time.sleep(0.5)
os.system('clear')
print("Booting into API Server…")
time.sleep(1)
os.system('clear')
print("BOT API SERVER RUNNING")
p = subprocess.Popen([sys.executable, 'server.py'],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
while True:
line = p.stdout.readline()
if not line: break