Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
|
| 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 |
-
|
|
|
|
|
|
|
|
|
|
| 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(
|