Download engine/jobs.py from Alaa75/CV-Engine: direct link, hf CLI and curl.
- Browser
- Download file 1.5 kB
-
https://huggingface.co/spaces/Alaa75/CV-Engine/resolve/main/engine/jobs.py
- Command line
-
hf download hf://spaces/Alaa75/CV-Engine/engine/jobs.py
-
curl -L -o jobs.py https://huggingface.co/spaces/Alaa75/CV-Engine/resolve/main/engine/jobs.py
1.5 kB
| """Étape 1 : analyse de l'offre -> JSON structuré.""" | |
| import re | |
| from .llm import call_json | |
| SYSTEM = """Tu es un consultant en recrutement international et expert ATS. Réponds UNIQUEMENT en JSON valide.""" | |
| PROMPT = """Analyse cette offre d'emploi. Renvoie exactement ce JSON : | |
| {{"lang":"fr|en","job_title":"","company":"","industry":"","seniority":"", | |
| "must_have":["exigences obligatoires, courtes (1 à 4 mots chacune), dans la langue de l'offre"], | |
| "nice_to_have":["souhaitables, courtes"], | |
| "ats_keywords":["15 à 25 mots-clés/termes exacts de l'offre à reprendre tels quels"], | |
| "responsibilities":["5 à 8 missions clés, courtes"]}} | |
| Ne rien inventer qui ne soit pas dans l'offre. | |
| OFFRE : | |
| {offer}""" | |
| FR_WORDS = {"le","la","les","des","et","pour","vous","nous","dans","avec","une","un","du","de","sur","poste","experience","compétences"} | |
| def detect_lang(text: str) -> str: | |
| words = re.findall(r"[a-zéèêàùçô]+", text.lower()) | |
| if not words: return "fr" | |
| return "fr" if sum(w in FR_WORDS for w in words) / len(words) > 0.08 else "en" | |
| def analyze_offer(offer: str, lang_override: str | None = None) -> dict: | |
| job = call_json(SYSTEM, PROMPT.format(offer=offer[:9000]), temperature=0.1) | |
| job["lang"] = lang_override or (job.get("lang") if job.get("lang") in ("fr", "en") else detect_lang(offer)) | |
| for k in ("must_have", "nice_to_have", "ats_keywords", "responsibilities"): | |
| job[k] = [x for x in job.get(k, []) if isinstance(x, str) and x.strip()] | |
| return job | |