* stop using rebuff
Browse files* process Azure errors correctly
app.py
CHANGED
|
@@ -146,6 +146,9 @@ def detect_azure(prompt: str) -> (bool, bool):
|
|
| 146 |
response_json = response.json()
|
| 147 |
logger.info(f"Prompt injection result from Azure: {response.json()}")
|
| 148 |
|
|
|
|
|
|
|
|
|
|
| 149 |
return True, response_json["jailbreakAnalysis"]["detected"]
|
| 150 |
except requests.RequestException as err:
|
| 151 |
logger.error(f"Failed to call Azure API: {err}")
|
|
@@ -158,7 +161,7 @@ detection_providers = {
|
|
| 158 |
"FMOps (HF model)": detect_hf_fmops,
|
| 159 |
"Lakera Guard": detect_lakera,
|
| 160 |
"Automorphic Aegis": detect_automorphic,
|
| 161 |
-
"Rebuff": detect_rebuff,
|
| 162 |
"Azure Content Safety": detect_azure,
|
| 163 |
}
|
| 164 |
|
|
|
|
| 146 |
response_json = response.json()
|
| 147 |
logger.info(f"Prompt injection result from Azure: {response.json()}")
|
| 148 |
|
| 149 |
+
if "jailbreakAnalysis" not in response_json:
|
| 150 |
+
return False, False
|
| 151 |
+
|
| 152 |
return True, response_json["jailbreakAnalysis"]["detected"]
|
| 153 |
except requests.RequestException as err:
|
| 154 |
logger.error(f"Failed to call Azure API: {err}")
|
|
|
|
| 161 |
"FMOps (HF model)": detect_hf_fmops,
|
| 162 |
"Lakera Guard": detect_lakera,
|
| 163 |
"Automorphic Aegis": detect_automorphic,
|
| 164 |
+
# "Rebuff": detect_rebuff,
|
| 165 |
"Azure Content Safety": detect_azure,
|
| 166 |
}
|
| 167 |
|