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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -35,12 +35,19 @@ def analyze_prompt(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
  """
45
 
46
  rewrite_response = client.chat.completions.create(
 
35
 
36
  analysis = detection_response.choices[0].message.content.strip()
37
 
38
+ # Step 2: Suggest a safer reformulation of the prompt (conditional)
39
  rewrite_prompt = f"""
40
+ You are an AI security assistant.
41
+ Based on the following analysis of a user prompt, output a safer version of the prompt ONLY if it is risky.
42
+ If the analysis indicates no risk, simply return the original prompt as-is.
43
 
44
+ Analysis Result:
45
+ {analysis}
46
+
47
+ Original Prompt:
48
  {user_prompt}
49
+
50
+ Output ONLY the rewritten prompt text (or the original prompt if safe), without explanations, notes, or extra words.
51
  """
52
 
53
  rewrite_response = client.chat.completions.create(