import logging from langchain_core.tools import tool from services.analysis_service import AnalysisService # Assurez-vous que le chemin d'importation est correct logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) @tool def trigger_interview_analysis(user_id: str, job_offer_id: str, conversation_history: list): """ Call this tool to end the interview and start the final analysis. This should be the very last step of the conversation. Do not ask the user for confirmation before calling this tool. """ try: logger.info(f"Tool 'trigger_interview_analysis' called for user_id: {user_id} and job_offer_id: {job_offer_id}.") # Initialisez et lancez votre service d'analyse exactement comme avant analysis_service = AnalysisService( user_id=user_id, job_offer_id=job_offer_id, conversation_history=conversation_history ) # Lance la tâche de fond analysis_service.run_analysis_in_background() logger.info("Analysis task successfully started in the background.") return "Analysis has been successfully triggered. The user has been notified." except Exception as e: logger.error(f"Error calling analysis tool: {e}", exc_info=True) return "An error occurred while trying to start the analysis."