Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -85,10 +85,19 @@ def keyword_guard(normalized_query: str):
|
|
| 85 |
return category
|
| 86 |
return None
|
| 87 |
|
| 88 |
-
def check_query_safety(query: str):
|
| 89 |
-
nq = normalize_text(query)
|
| 90 |
-
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
# ===================== 3) Google Search Config (فتاوى) =====================
|
| 94 |
GOOGLE_API_KEY = os.environ.get("GOOGLE_API_KEY", "YOUR_API_KEY")
|
|
|
|
| 85 |
return category
|
| 86 |
return None
|
| 87 |
|
| 88 |
+
def check_query_safety(query: str):
|
| 89 |
+
nq = normalize_text(query)
|
| 90 |
+
|
| 91 |
+
# ✅ قائمة كلمات شرعية (Whitelist)
|
| 92 |
+
whitelist = {"الله", "الرسول", "النبي", "محمد", "القران", "الصلاة", "الصيام", "رمضان", "افطار", "الصوم", "زكاة", "الحج"}
|
| 93 |
+
|
| 94 |
+
# إذا السؤال يحتوي أي كلمة من القائمة، لا تمنعه الحراس
|
| 95 |
+
if any(word in nq for word in whitelist):
|
| 96 |
+
return None
|
| 97 |
+
|
| 98 |
+
# باقي الفحص
|
| 99 |
+
result = keyword_guard(nq)
|
| 100 |
+
return result
|
| 101 |
|
| 102 |
# ===================== 3) Google Search Config (فتاوى) =====================
|
| 103 |
GOOGLE_API_KEY = os.environ.get("GOOGLE_API_KEY", "YOUR_API_KEY")
|