safiaa02 commited on
Commit
c5ca70d
·
verified ·
1 Parent(s): 5456eb4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -37,9 +37,8 @@ def analyze_prompt(user_prompt):
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 the risk level is concerning.
42
- If the analysis indicates no risk, simply return the original prompt as-is.
43
 
44
  Analysis Result:
45
  {analysis}
@@ -47,7 +46,10 @@ def analyze_prompt(user_prompt):
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(
 
37
 
38
  # Step 2: Suggest a safer reformulation of the prompt (conditional)
39
  rewrite_prompt = f"""
40
+ You are an AI security assistant.
41
+ Here is the risk analysis of a user prompt and the prompt itself.
 
42
 
43
  Analysis Result:
44
  {analysis}
 
46
  Original Prompt:
47
  {user_prompt}
48
 
49
+ Your task:
50
+ - If the analysis indicates risk (Low or Medium or High), rewrite the prompt so it becomes a safe, educational question about the same topic.
51
+ - If the analysis indicates no risk, return the original prompt unchanged.
52
+ - Output ONLY the final safe prompt text, with no explanations, notes, or extra words.
53
  """
54
 
55
  rewrite_response = client.chat.completions.create(