Spaces:
Sleeping
Sleeping
Update src/crew/crew_pool.py
Browse files- src/crew/crew_pool.py +26 -28
src/crew/crew_pool.py
CHANGED
|
@@ -1,40 +1,27 @@
|
|
| 1 |
-
from crewai import Crew, Process
|
| 2 |
-
from langchain_core.tools import tool
|
| 3 |
import json
|
| 4 |
-
from
|
| 5 |
-
from
|
| 6 |
-
from .
|
| 7 |
-
from
|
| 8 |
-
from src.deep_learning_analyzer import MultiModelInterviewAnalyzer
|
| 9 |
-
from src.rag_handler import RAGHandler
|
| 10 |
-
from langchain_core.tools import BaseTool
|
| 11 |
|
| 12 |
-
|
| 13 |
-
def interview_analyser(conversation_history: list, job_description_text: list) -> str:
|
| 14 |
"""
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
Ne l'utilise PAS pour répondre à une question normale, mais seulement pour conclure et analyser l'entretien.
|
| 18 |
"""
|
| 19 |
-
|
| 20 |
-
analyzer = MultiModelInterviewAnalyzer()
|
| 21 |
-
structured_analysis = analyzer.run_full_analysis(conversation_history, job_description_text)
|
| 22 |
-
|
| 23 |
-
# 2. Enrichissement avec RAG
|
| 24 |
-
rag_handler = RAGHandler()
|
| 25 |
rag_feedback = []
|
| 26 |
-
# Extraire les intentions et sentiments pour trouver des conseils pertinents
|
| 27 |
if structured_analysis.get("intent_analysis"):
|
| 28 |
for intent in structured_analysis["intent_analysis"]:
|
| 29 |
-
# Exemple de requête basée sur l'intention
|
| 30 |
query = f"Conseils pour un candidat qui cherche à {intent['labels'][0]}"
|
| 31 |
rag_feedback.extend(rag_handler.get_relevant_feedback(query))
|
| 32 |
|
| 33 |
if structured_analysis.get("sentiment_analysis"):
|
| 34 |
for sentiment_group in structured_analysis["sentiment_analysis"]:
|
| 35 |
for sentiment in sentiment_group:
|
| 36 |
-
if sentiment['label'] == 'stress' and sentiment['score']
|
| 37 |
rag_feedback.extend(rag_handler.get_relevant_feedback("gestion du stress en entretien"))
|
|
|
|
| 38 |
unique_feedback = list(set(rag_feedback))
|
| 39 |
interview_crew = Crew(
|
| 40 |
agents=[report_generator_agent],
|
|
@@ -48,9 +35,23 @@ def interview_analyser(conversation_history: list, job_description_text: list) -
|
|
| 48 |
'structured_analysis_data': json.dumps(structured_analysis, indent=2),
|
| 49 |
'rag_contextual_feedback': "\n".join(unique_feedback)
|
| 50 |
})
|
|
|
|
| 51 |
return final_report
|
| 52 |
|
| 53 |
-
def analyse_cv(cv_content: str) ->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
crew = Crew(
|
| 55 |
agents=[
|
| 56 |
informations_personnelle_agent,
|
|
@@ -59,7 +60,6 @@ def analyse_cv(cv_content: str) -> json:
|
|
| 59 |
project_extractor_agent,
|
| 60 |
education_extractor_agent,
|
| 61 |
reconversion_detector_agent,
|
| 62 |
-
|
| 63 |
ProfileBuilderAgent
|
| 64 |
],
|
| 65 |
tasks=[
|
|
@@ -76,6 +76,4 @@ def analyse_cv(cv_content: str) -> json:
|
|
| 76 |
telemetry=False
|
| 77 |
)
|
| 78 |
result = crew.kickoff(inputs={"cv_content": cv_content})
|
| 79 |
-
return result
|
| 80 |
-
|
| 81 |
-
|
|
|
|
|
|
|
|
|
|
| 1 |
import json
|
| 2 |
+
from crewai import Crew, Process
|
| 3 |
+
from .agents import report_generator_agent
|
| 4 |
+
from .tasks import generate_report_task
|
| 5 |
+
from typing import List
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
def run_interview_analysis(conversation_history: list, job_description_text: str, analyzer_model, rag_handler) -> str:
|
|
|
|
| 8 |
"""
|
| 9 |
+
Analyse l'intégralité de la conversation et génère un rapport de feedback.
|
| 10 |
+
Cette fonction est conçue pour être appelée en arrière-plan.
|
|
|
|
| 11 |
"""
|
| 12 |
+
structured_analysis = analyzer_model.run_full_analysis(conversation_history, job_description_text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
rag_feedback = []
|
|
|
|
| 14 |
if structured_analysis.get("intent_analysis"):
|
| 15 |
for intent in structured_analysis["intent_analysis"]:
|
|
|
|
| 16 |
query = f"Conseils pour un candidat qui cherche à {intent['labels'][0]}"
|
| 17 |
rag_feedback.extend(rag_handler.get_relevant_feedback(query))
|
| 18 |
|
| 19 |
if structured_analysis.get("sentiment_analysis"):
|
| 20 |
for sentiment_group in structured_analysis["sentiment_analysis"]:
|
| 21 |
for sentiment in sentiment_group:
|
| 22 |
+
if sentiment['label'] == 'stress' and sentiment['score'] > 0.6:
|
| 23 |
rag_feedback.extend(rag_handler.get_relevant_feedback("gestion du stress en entretien"))
|
| 24 |
+
|
| 25 |
unique_feedback = list(set(rag_feedback))
|
| 26 |
interview_crew = Crew(
|
| 27 |
agents=[report_generator_agent],
|
|
|
|
| 35 |
'structured_analysis_data': json.dumps(structured_analysis, indent=2),
|
| 36 |
'rag_contextual_feedback': "\n".join(unique_feedback)
|
| 37 |
})
|
| 38 |
+
|
| 39 |
return final_report
|
| 40 |
|
| 41 |
+
def analyse_cv(cv_content: str) -> dict:
|
| 42 |
+
from .agents import (
|
| 43 |
+
informations_personnelle_agent, skills_extractor_agent,
|
| 44 |
+
experience_extractor_agent, project_extractor_agent,
|
| 45 |
+
education_extractor_agent, reconversion_detector_agent,
|
| 46 |
+
ProfileBuilderAgent
|
| 47 |
+
)
|
| 48 |
+
from .tasks import (
|
| 49 |
+
task_extract_informations, task_extract_skills,
|
| 50 |
+
task_extract_experience, task_extract_projects,
|
| 51 |
+
task_extract_education, task_detect_reconversion,
|
| 52 |
+
task_build_profile
|
| 53 |
+
)
|
| 54 |
+
|
| 55 |
crew = Crew(
|
| 56 |
agents=[
|
| 57 |
informations_personnelle_agent,
|
|
|
|
| 60 |
project_extractor_agent,
|
| 61 |
education_extractor_agent,
|
| 62 |
reconversion_detector_agent,
|
|
|
|
| 63 |
ProfileBuilderAgent
|
| 64 |
],
|
| 65 |
tasks=[
|
|
|
|
| 76 |
telemetry=False
|
| 77 |
)
|
| 78 |
result = crew.kickoff(inputs={"cv_content": cv_content})
|
| 79 |
+
return json.loads(result)
|
|
|
|
|
|