QuentinL52 commited on
Commit
5db4cdd
·
verified ·
1 Parent(s): 76b4a9e

Create tools/analysis_tools.py

Browse files
Files changed (1) hide show
  1. tools/analysis_tools.py +32 -0
tools/analysis_tools.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import logging
2
+ from langchain_core.tools import tool
3
+ from services.analysis_service import AnalysisService # Assurez-vous que le chemin d'importation est correct
4
+
5
+ logging.basicConfig(level=logging.INFO)
6
+ logger = logging.getLogger(__name__)
7
+
8
+ @tool
9
+ def trigger_interview_analysis(user_id: str, job_offer_id: str, conversation_history: list):
10
+ """
11
+ Call this tool to end the interview and start the final analysis.
12
+ This should be the very last step of the conversation.
13
+ Do not ask the user for confirmation before calling this tool.
14
+ """
15
+ try:
16
+ logger.info(f"Tool 'trigger_interview_analysis' called for user_id: {user_id} and job_offer_id: {job_offer_id}.")
17
+
18
+ # Initialisez et lancez votre service d'analyse exactement comme avant
19
+ analysis_service = AnalysisService(
20
+ user_id=user_id,
21
+ job_offer_id=job_offer_id,
22
+ conversation_history=conversation_history
23
+ )
24
+
25
+ # Lance la tâche de fond
26
+ analysis_service.run_analysis_in_background()
27
+
28
+ logger.info("Analysis task successfully started in the background.")
29
+ return "Analysis has been successfully triggered. The user has been notified."
30
+ except Exception as e:
31
+ logger.error(f"Error calling analysis tool: {e}", exc_info=True)
32
+ return "An error occurred while trying to start the analysis."