Aswini96 commited on
Commit
8e31ba1
Β·
verified Β·
1 Parent(s): 35fd763

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -10
app.py CHANGED
@@ -11,7 +11,7 @@ NY_msg_model = genai.GenerativeModel(model_name="gemini-1.5-flash")
11
  # List of New Year 2025 related words for each level
12
  new_year_levels = [os.getenv("First_Word"), os.getenv("Second_Word"), os.getenv("Third_Word"), os.getenv("Fourth_Word"), os.getenv("Fifth_Word")]
13
 
14
- # Function to interact with OpenAI API
15
  def ask_openai(prompt, secret_word):
16
  """
17
  Sends the user prompt and safeguards to the OpenAI API to generate a response.
@@ -24,15 +24,11 @@ def ask_openai(prompt, secret_word):
24
  except Exception as e:
25
  return f"Error: {str(e)}"
26
 
27
-
28
  # Function to handle game logic
29
  def jailbreak_game(user_prompt, current_level, attempts):
30
  # Determine the secret word for the current level
31
  if current_level >= len(new_year_levels):
32
- return (
33
- "Congratulations! πŸŽ‰ You have completed all levels. ",
34
- current_level,
35
- attempts)
36
 
37
  secret_word = new_year_levels[current_level]
38
  ai_response = ask_openai(user_prompt, secret_word)
@@ -63,9 +59,6 @@ def jailbreak_game(user_prompt, current_level, attempts):
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"
@@ -83,7 +76,7 @@ with gr.Blocks() as app:
83
  descripion, _0, _1 = start_new_game()
84
  gr.Markdown(descripion)
85
  with gr.Row():
86
- current_level_display = gr.Label(value=(current_level.value+1), 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)
 
11
  # List of New Year 2025 related words for each level
12
  new_year_levels = [os.getenv("First_Word"), os.getenv("Second_Word"), os.getenv("Third_Word"), os.getenv("Fourth_Word"), os.getenv("Fifth_Word")]
13
 
14
+ # Function to interact with Gemini API
15
  def ask_openai(prompt, secret_word):
16
  """
17
  Sends the user prompt and safeguards to the OpenAI API to generate a response.
 
24
  except Exception as e:
25
  return f"Error: {str(e)}"
26
 
 
27
  # Function to handle game logic
28
  def jailbreak_game(user_prompt, current_level, attempts):
29
  # Determine the secret word for the current level
30
  if current_level >= len(new_year_levels):
31
+ return ("Congratulations! πŸŽ‰ You have completed all levels. ", current_level, attempts)
 
 
 
32
 
33
  secret_word = new_year_levels[current_level]
34
  ai_response = ask_openai(user_prompt, secret_word)
 
59
  else:
60
  return ai_response, current_level, attempts + 1
61
 
 
 
 
62
  def start_new_game():
63
  welcome_message = (
64
  "Welcome to the New Year 2025 Jailbreak Game! πŸŽ†\n"
 
76
  descripion, _0, _1 = start_new_game()
77
  gr.Markdown(descripion)
78
  with gr.Row():
79
+ current_level_display = gr.Textbox(value=(current_level.value+1), label="Current Level", interactive=False)
80
 
81
  user_prompt = gr.Textbox(label="Your Prompt", placeholder="Enter your prompt here...")
82
  game_output = gr.Textbox(label="AI Response", interactive=False)