Updated validator.py to be Qwn compatible
Browse filesSince Qwen doesnt use mistral's token tags(like <s>[INST]), we remove them to ensure clean text gen
- agents/validator.py +19 -11
agents/validator.py
CHANGED
|
@@ -90,17 +90,25 @@ class ValidatorAgent:
|
|
| 90 |
# ββ Stage 2: LLM Gatekeeper βββββββββββββββββββββββββββββββββββββββββββββββ
|
| 91 |
# Making _gatekeeper Mistral 7B v02 compatible(it accepts inside <s>[INST] tags only)
|
| 92 |
def _gatekeeper(self, clean_text: str) -> bool:
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
|
| 106 |
# ββ Stage 3: Profile Extraction βββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 90 |
# ββ Stage 2: LLM Gatekeeper βββββββββββββββββββββββββββββββββββββββββββββββ
|
| 91 |
# Making _gatekeeper Mistral 7B v02 compatible(it accepts inside <s>[INST] tags only)
|
| 92 |
def _gatekeeper(self, clean_text: str) -> bool:
|
| 93 |
+
"""Returns True only if the LLM classifies the text as a legitimate JD."""
|
| 94 |
+
# Standardized to plain English text layout for cross-model compatibility
|
| 95 |
+
prompt = f"""You are a security-hardened automated recruitment verification filter.
|
| 96 |
+
Your ONLY task is to classify whether the text inside the input tags is a legitimate, fully-structured job description containing real duties and organizational requirements.
|
| 97 |
+
|
| 98 |
+
If legitimate, reply with the exact word: VALID
|
| 99 |
+
If not legitimate, reply with the exact word: INVALID
|
| 100 |
+
|
| 101 |
+
Text to analyze:
|
| 102 |
+
{clean_text[:1200]}
|
| 103 |
+
|
| 104 |
+
Your response (VALID or INVALID):"""
|
| 105 |
+
|
| 106 |
+
raw_response = self._ask(prompt, temperature=0.0, max_tokens=40)
|
| 107 |
+
|
| 108 |
+
print(f"\n--- GATEKEEPER DEBUG --- \nRaw Model Output: '{raw_response}'\n-------------------------\n")
|
| 109 |
+
|
| 110 |
+
verdict = raw_response.strip().upper()
|
| 111 |
+
return "VALID" in verdict and "INVALID" not in verdict
|
| 112 |
|
| 113 |
|
| 114 |
# ββ Stage 3: Profile Extraction βββββββββββββββββββββββββββββββββββββββββββ
|