safiaa02 commited on
Commit
a3177d3
·
verified ·
1 Parent(s): 9c32df4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -7
app.py CHANGED
@@ -6,9 +6,8 @@ client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
6
 
7
  def analyze_prompt(user_prompt):
8
  if not user_prompt.strip():
9
- return "⚠️ Please enter a prompt to analyze.", "", "", ""
10
 
11
- # Step 1: Detect vulnerability type
12
  detection_prompt = f"""
13
  You are an AI security analyst.
14
  Analyze the following prompt for potential vulnerabilities against large language models.
@@ -23,7 +22,7 @@ def analyze_prompt(user_prompt):
23
 
24
  - Detected Vulnerability: <list types or "None">
25
  - Risk Level: <Low / Medium / High>
26
- - Short Explanation (1–2 sentences)
27
 
28
  Prompt to analyze:
29
  {user_prompt}
@@ -36,11 +35,10 @@ def analyze_prompt(user_prompt):
36
 
37
  analysis = detection_response.choices[0].message.content.strip()
38
 
39
- # Step 2: Suggest a safer reformulation of the prompt
40
  rewrite_prompt = f"""
41
- Rewrite the following prompt in a safer and responsible way
42
- that removes any security risks but keeps the learning intent.
43
-
44
  Prompt:
45
  {user_prompt}
46
  """
 
6
 
7
  def analyze_prompt(user_prompt):
8
  if not user_prompt.strip():
9
+ return "Please enter a prompt to analyze.", "", "", ""
10
 
 
11
  detection_prompt = f"""
12
  You are an AI security analyst.
13
  Analyze the following prompt for potential vulnerabilities against large language models.
 
22
 
23
  - Detected Vulnerability: <list types or "None">
24
  - Risk Level: <Low / Medium / High>
25
+ - Short Explanation (1 sentence)
26
 
27
  Prompt to analyze:
28
  {user_prompt}
 
35
 
36
  analysis = detection_response.choices[0].message.content.strip()
37
 
 
38
  rewrite_prompt = f"""
39
+ Rewrite the following prompt into a safer version that removes any security risks.
40
+ Output ONLY the rewritten prompt text, without any explanations, notes, or extra words.
41
+
42
  Prompt:
43
  {user_prompt}
44
  """