Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- agentic_rag.py +4 -4
- rag_engine.py +3 -2
agentic_rag.py
CHANGED
|
@@ -126,7 +126,7 @@ def tool_search_db(engine, query: str):
|
|
| 126 |
if not top:
|
| 127 |
return "لم أجد معلومات كافية في قاعدة البيانات.", []
|
| 128 |
context = "\n\n".join([f"[{i+1}] {c['content']}" for i, c in enumerate(top)])
|
| 129 |
-
sources = [{"url": c.get("url", ""), "page_name": c.get("page_name", ""), "content": c.get("content", "")} for c in top]
|
| 130 |
return context, sources
|
| 131 |
except Exception as e:
|
| 132 |
return f"خطأ في البحث: {e}", []
|
|
@@ -348,8 +348,8 @@ class AgenticRAG:
|
|
| 348 |
def evaluate_user_profile(self, user_info: str, lang: str) -> str:
|
| 349 |
"""يقيّم تأهل المستخدم بعد ما يعطي معلوماته"""
|
| 350 |
# جيب شروط المناظرات
|
| 351 |
-
context_ar = tool_get_concours_page("superieur_ar")
|
| 352 |
-
context_fr = tool_get_concours_page("general_ar")
|
| 353 |
context = f"{context_ar}\n\n{context_fr}"[:5000]
|
| 354 |
|
| 355 |
if lang == "ar":
|
|
@@ -445,4 +445,4 @@ Réponds en JSON uniquement: ["question1", "question2", "question3"]"""
|
|
| 445 |
"Quels documents pour le dossier?",
|
| 446 |
"Quand ouvrent les prochains concours?",
|
| 447 |
"Suis-je éligible?"
|
| 448 |
-
]
|
|
|
|
| 126 |
if not top:
|
| 127 |
return "لم أجد معلومات كافية في قاعدة البيانات.", []
|
| 128 |
context = "\n\n".join([f"[{i+1}] {c['content']}" for i, c in enumerate(top)])
|
| 129 |
+
sources = [{"url": c["meta"].get("url", ""), "page_name": c["meta"].get("page_name", ""), "content": c.get("content", "")} for c in top]
|
| 130 |
return context, sources
|
| 131 |
except Exception as e:
|
| 132 |
return f"خطأ في البحث: {e}", []
|
|
|
|
| 348 |
def evaluate_user_profile(self, user_info: str, lang: str) -> str:
|
| 349 |
"""يقيّم تأهل المستخدم بعد ما يعطي معلوماته"""
|
| 350 |
# جيب شروط المناظرات
|
| 351 |
+
context_ar, _ = tool_get_concours_page("superieur_ar")
|
| 352 |
+
context_fr, _ = tool_get_concours_page("general_ar")
|
| 353 |
context = f"{context_ar}\n\n{context_fr}"[:5000]
|
| 354 |
|
| 355 |
if lang == "ar":
|
|
|
|
| 445 |
"Quels documents pour le dossier?",
|
| 446 |
"Quand ouvrent les prochains concours?",
|
| 447 |
"Suis-je éligible?"
|
| 448 |
+
]
|
rag_engine.py
CHANGED
|
@@ -118,6 +118,8 @@ class ENAEngine:
|
|
| 118 |
if "informations-generales" in m_url:
|
| 119 |
score *= 1.5
|
| 120 |
|
|
|
|
|
|
|
| 121 |
# Boost الاستثناءات القانونية للسن — مهمة جداً
|
| 122 |
EXCEPTION_KEYWORDS = ["استثناء", "مكتب تشغيل", "مكتب التشغيل",
|
| 123 |
"سنوات العمل", "الجماعات المحلية",
|
|
@@ -131,7 +133,6 @@ class ENAEngine:
|
|
| 131 |
is_competition_q = any(b in qn.lower() for b in CONTEXT_PENALTIES["competition"])
|
| 132 |
is_journal_q = any(b in qn.lower() for b in CONTEXT_PENALTIES["journal"])
|
| 133 |
|
| 134 |
-
content_lower = t.lower()
|
| 135 |
has_journal_terms = any(b in content_lower for b in CONTEXT_PENALTIES["journal"])
|
| 136 |
|
| 137 |
# If it's a competition query, penalize journal content heavily
|
|
@@ -265,4 +266,4 @@ class ENAEngine:
|
|
| 265 |
|
| 266 |
5. **Rigueur numérique** : Ne jamais omettre un chiffre, un âge ou une dérogation légale.
|
| 267 |
|
| 268 |
-
6. **Sources** : Citer la référence [1] après chaque information."""
|
|
|
|
| 118 |
if "informations-generales" in m_url:
|
| 119 |
score *= 1.5
|
| 120 |
|
| 121 |
+
content_lower = t.lower()
|
| 122 |
+
|
| 123 |
# Boost الاستثناءات القانونية للسن — مهمة جداً
|
| 124 |
EXCEPTION_KEYWORDS = ["استثناء", "مكتب تشغيل", "مكتب التشغيل",
|
| 125 |
"سنوات العمل", "الجماعات المحلية",
|
|
|
|
| 133 |
is_competition_q = any(b in qn.lower() for b in CONTEXT_PENALTIES["competition"])
|
| 134 |
is_journal_q = any(b in qn.lower() for b in CONTEXT_PENALTIES["journal"])
|
| 135 |
|
|
|
|
| 136 |
has_journal_terms = any(b in content_lower for b in CONTEXT_PENALTIES["journal"])
|
| 137 |
|
| 138 |
# If it's a competition query, penalize journal content heavily
|
|
|
|
| 266 |
|
| 267 |
5. **Rigueur numérique** : Ne jamais omettre un chiffre, un âge ou une dérogation légale.
|
| 268 |
|
| 269 |
+
6. **Sources** : Citer la référence [1] après chaque information."""
|