Update app.py
Browse files
app.py
CHANGED
@@ -63,6 +63,9 @@ def jailbreak_game(user_prompt, current_level, attempts):
|
|
63 |
else:
|
64 |
return ai_response, current_level, attempts + 1
|
65 |
|
|
|
|
|
|
|
66 |
def start_new_game():
|
67 |
welcome_message = (
|
68 |
"Welcome to the New Year 2025 Jailbreak Game! π\n"
|
@@ -73,13 +76,15 @@ def start_new_game():
|
|
73 |
|
74 |
# Gradio UI
|
75 |
with gr.Blocks() as app:
|
|
|
76 |
with gr.Row():
|
77 |
gr.Markdown("## π New Year 2025 Jailbreak Game π")
|
78 |
with gr.Row():
|
79 |
descripion, _0, _1 = start_new_game()
|
80 |
gr.Markdown(descripion)
|
81 |
with gr.Row():
|
82 |
-
current_level_display = gr.Label(value=
|
|
|
83 |
user_prompt = gr.Textbox(label="Your Prompt", placeholder="Enter your prompt here...")
|
84 |
game_output = gr.Textbox(label="AI Response", interactive=False)
|
85 |
attempts = gr.Number(value=0, interactive=False, label="Attempts")
|
@@ -89,18 +94,7 @@ with gr.Blocks() as app:
|
|
89 |
submit_button = gr.Button("Submit")
|
90 |
new_game_button = gr.Button("Start New Game")
|
91 |
|
92 |
-
submit_button.click(
|
93 |
-
jailbreak_game,
|
94 |
-
inputs=[user_prompt, current_level, attempts],
|
95 |
-
outputs=[game_output, current_level, attempts],
|
96 |
-
_js="""
|
97 |
-
function(response, currentLevel, attempts) {
|
98 |
-
const level = parseInt(currentLevel) + 1; // Increment for user-friendly level display
|
99 |
-
document.querySelector('[label="Current Level"]').value = `Level ${level}`;
|
100 |
-
return [response, currentLevel, attempts];
|
101 |
-
}
|
102 |
-
"""
|
103 |
-
)
|
104 |
new_game_button.click(start_new_game, [], [game_output, current_level, attempts])
|
105 |
|
106 |
# Launch the app
|
|
|
63 |
else:
|
64 |
return ai_response, current_level, attempts + 1
|
65 |
|
66 |
+
def format_level(current_level):
|
67 |
+
return f"Level {current_level + 1}" # Increment for user-friendly level display
|
68 |
+
|
69 |
def start_new_game():
|
70 |
welcome_message = (
|
71 |
"Welcome to the New Year 2025 Jailbreak Game! π\n"
|
|
|
76 |
|
77 |
# Gradio UI
|
78 |
with gr.Blocks() as app:
|
79 |
+
current_level = 0
|
80 |
with gr.Row():
|
81 |
gr.Markdown("## π New Year 2025 Jailbreak Game π")
|
82 |
with gr.Row():
|
83 |
descripion, _0, _1 = start_new_game()
|
84 |
gr.Markdown(descripion)
|
85 |
with gr.Row():
|
86 |
+
current_level_display = gr.Label(value=current_level, label="Current Level")
|
87 |
+
|
88 |
user_prompt = gr.Textbox(label="Your Prompt", placeholder="Enter your prompt here...")
|
89 |
game_output = gr.Textbox(label="AI Response", interactive=False)
|
90 |
attempts = gr.Number(value=0, interactive=False, label="Attempts")
|
|
|
94 |
submit_button = gr.Button("Submit")
|
95 |
new_game_button = gr.Button("Start New Game")
|
96 |
|
97 |
+
submit_button.click(jailbreak_game, [user_prompt, current_level, attempts], [game_output, current_level, attempts])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
new_game_button.click(start_new_game, [], [game_output, current_level, attempts])
|
99 |
|
100 |
# Launch the app
|