Spaces:
Sleeping
Sleeping
Create analysis_agent.py
Browse files- src/agents/analysis_agent.py +49 -0
src/agents/analysis_agent.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
+
from typing import Dict, Any
|
| 3 |
+
from src.config import chat_openai
|
| 4 |
+
|
| 5 |
+
logger = logging.getLogger(__name__)
|
| 6 |
+
|
| 7 |
+
class AnalysisAgent:
|
| 8 |
+
def __init__(self, llm=None):
|
| 9 |
+
self.llm = llm or chat_openai()
|
| 10 |
+
|
| 11 |
+
def analyze_candidate(self, cv_data: Dict[str, Any]) -> Dict[str, Any]:
|
| 12 |
+
"""Produit une analyse enrichie du profil à partir des données structurées du CV"""
|
| 13 |
+
if not cv_data or "candidat" not in cv_data:
|
| 14 |
+
return {}
|
| 15 |
+
|
| 16 |
+
candidat = cv_data["candidat"]
|
| 17 |
+
prompt = f"""
|
| 18 |
+
Tu es un expert en recrutement. Analyse ce profil candidat en te basant sur les données suivantes :
|
| 19 |
+
{candidat}
|
| 20 |
+
|
| 21 |
+
Fournis une analyse complète avec ces sections :
|
| 22 |
+
1. Évaluation des compétences techniques (niveau de maîtrise par domaine)
|
| 23 |
+
2. Analyse des projets (objectifs, technologies, compétences démontrées)
|
| 24 |
+
3. Évaluation des soft skills
|
| 25 |
+
4. Analyse de l’expérience professionnelle (niveau, cohérence, domaines)
|
| 26 |
+
5. Détection d’une reconversion (si oui, précise depuis quel domaine et pourquoi)
|
| 27 |
+
6. Profil global (forces, axes d’amélioration, positionnement)
|
| 28 |
+
7. Recommandations de postes et de progression de carrière
|
| 29 |
+
8. Suggestions d’amélioration du CV
|
| 30 |
+
|
| 31 |
+
Donne ta réponse au format JSON clair, par exemple :
|
| 32 |
+
{{
|
| 33 |
+
"competence_analysis": [...],
|
| 34 |
+
"project_analysis": [...],
|
| 35 |
+
"soft_skills_analysis": "...",
|
| 36 |
+
"experience_evaluation": "...",
|
| 37 |
+
"reconversion": {{ "is_reconversion": true, "details": "..." }},
|
| 38 |
+
"global_profile": "...",
|
| 39 |
+
"career_recommendations": [...],
|
| 40 |
+
"cv_improvement_suggestions": [...]
|
| 41 |
+
}}
|
| 42 |
+
"""
|
| 43 |
+
|
| 44 |
+
response = self.llm.invoke(prompt)
|
| 45 |
+
try:
|
| 46 |
+
return response.to_dict() if hasattr(response, "to_dict") else response
|
| 47 |
+
except Exception as e:
|
| 48 |
+
logger.error(f"Erreur d'analyse enrichie : {e}")
|
| 49 |
+
return {}
|