QuentinL52 commited on
Commit
1e0aa4f
·
verified ·
1 Parent(s): 8c2922b

Create src/services/cv_service.py

Browse files
Files changed (1) hide show
  1. src/services/cv_service.py +56 -0
src/services/cv_service.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import logging
3
+ from typing import Dict, Any
4
+ from src.config import load_pdf
5
+ from src.agents.cv_agents import CVAgentOrchestrator
6
+ from src.agents.scoring_agent import ScoringAgent
7
+
8
+ logger = logging.getLogger(__name__)
9
+
10
+ class CVParsingService:
11
+ def __init__(self, models: Dict[str, Any]):
12
+ self.models = models
13
+ self.orchestrator = CVAgentOrchestrator(models.get("llm"))
14
+ self.scoring_agent = ScoringAgent()
15
+
16
+ def parse_cv(self, pdf_path: str) -> Dict[str, Any]:
17
+ cv_text = load_pdf(pdf_path)
18
+
19
+ if not cv_text or not cv_text.strip():
20
+ return self._create_fallback_data()
21
+
22
+ sections = self.orchestrator.split_cv_sections(cv_text)
23
+ cv_data = self.orchestrator.extract_all_sections(sections)
24
+
25
+ if cv_data and cv_data.get("candidat"):
26
+ scores = self.scoring_agent.calculate_scores(cv_data["candidat"])
27
+ cv_data["candidat"].update(scores)
28
+
29
+ return cv_data
30
+
31
+ def _create_fallback_data(self) -> Dict[str, Any]:
32
+ return {
33
+ "candidat": {
34
+ "informations_personnelles": {
35
+ "nom": "Non spécifié",
36
+ "email": "Non spécifié",
37
+ "numero_de_telephone": "Non spécifié",
38
+ "localisation": "Non spécifiée"
39
+ },
40
+ "compétences": {
41
+ "hard_skills": [],
42
+ "soft_skills": []
43
+ },
44
+ "expériences": [],
45
+ "projets": {
46
+ "professional": [],
47
+ "personal": []
48
+ },
49
+ "formations": [],
50
+ "reconversion": {
51
+ "is_reconversion": False,
52
+ "analysis": "Analyse non disponible"
53
+ },
54
+ "analyse_competences": []
55
+ }
56
+ }