QuentinL52 commited on
Commit
bd13f59
·
verified ·
1 Parent(s): 69b529d

Update tools/analysis_tools.py

Browse files
Files changed (1) hide show
  1. tools/analysis_tools.py +25 -0
tools/analysis_tools.py CHANGED
@@ -41,3 +41,28 @@ def trigger_interview_analysis(user_id: str, job_offer_id: str, job_description:
41
  except Exception as e:
42
  logger.error(f"Erreur dans l'outil d'analyse : {e}", exc_info=True)
43
  return "Une erreur est survenue lors du lancement de l'analyse."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  except Exception as e:
42
  logger.error(f"Erreur dans l'outil d'analyse : {e}", exc_info=True)
43
  return "Une erreur est survenue lors du lancement de l'analyse."
44
+
45
+ def _final_analysis_node(self, state: AgentState):
46
+ """
47
+ Calls the final analysis tool. It constructs all arguments directly
48
+ from the graph's state, making the process robust and reliable.
49
+ """
50
+ print(">>> Final analysis node reached. Manually constructing tool arguments.")
51
+ conversation_history = []
52
+ for msg in state["messages"]:
53
+ if isinstance(msg, HumanMessage):
54
+ role = "user"
55
+ elif isinstance(msg, AIMessage):
56
+ role = "assistant"
57
+ else:
58
+ continue
59
+ conversation_history.append({"role": role, "content": msg.content})
60
+ tool_input = {
61
+ "user_id": state['user_id'],
62
+ "job_offer_id": state['job_offer_id'],
63
+ "job_description": state['job_description'],
64
+ "conversation_history": conversation_history
65
+ }
66
+ print(">>> Invoking the analysis tool with complete arguments.")
67
+ trigger_interview_analysis.invoke(tool_input)
68
+ return {}