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

Update services/graph_service.py

Browse files
Files changed (1) hide show
  1. services/graph_service.py +23 -2
services/graph_service.py CHANGED
@@ -10,7 +10,7 @@ from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
10
  from langgraph.graph import StateGraph, END
11
  from langgraph.prebuilt import ToolNode
12
 
13
- from tools.analysis_tools import trigger_interview_analysis
14
 
15
  class AgentState(TypedDict):
16
  messages: Annotated[Sequence[BaseMessage], lambda x, y: x + y]
@@ -144,7 +144,7 @@ class GraphInterviewProcessor:
144
  return "call_final_tool"
145
  return "call_tool"
146
  return "end_turn"
147
-
148
  def _build_graph(self) -> any:
149
  """Construit et compile le graphe d'états."""
150
  tool_node = ToolNode([trigger_interview_analysis])
@@ -165,6 +165,27 @@ class GraphInterviewProcessor:
165
  graph.add_edge("tools", "agent")
166
  graph.add_edge("final_tool_node", END)
167
  return graph.compile()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
 
169
  def invoke(self, messages: List[Dict[str, Any]]):
170
  """Point d'entrée pour lancer une conversation dans le graphe."""
 
10
  from langgraph.graph import StateGraph, END
11
  from langgraph.prebuilt import ToolNode
12
 
13
+ from tools.analysis_tools import trigger_interview_analysis, _final_analysis_node
14
 
15
  class AgentState(TypedDict):
16
  messages: Annotated[Sequence[BaseMessage], lambda x, y: x + y]
 
144
  return "call_final_tool"
145
  return "call_tool"
146
  return "end_turn"
147
+ '''
148
  def _build_graph(self) -> any:
149
  """Construit et compile le graphe d'états."""
150
  tool_node = ToolNode([trigger_interview_analysis])
 
165
  graph.add_edge("tools", "agent")
166
  graph.add_edge("final_tool_node", END)
167
  return graph.compile()
168
+ '''
169
+ def _build_graph(self) -> any:
170
+ """Construit et compile le graphe d'états."""
171
+ tool_node = ToolNode([trigger_interview_analysis])
172
+ graph = StateGraph(AgentState)
173
+ graph.add_node("agent", self._agent_node)
174
+ graph.add_node("tools", tool_node)
175
+ graph.add_node("final_tool_node", self._final_analysis_node)
176
+ graph.set_entry_point("agent")
177
+ graph.add_conditional_edges(
178
+ "agent",
179
+ self._router,
180
+ {
181
+ "call_tool": "tools",
182
+ "call_final_tool": "final_tool_node",
183
+ "end_turn": END
184
+ }
185
+ )
186
+ graph.add_edge("tools", "agent")
187
+ graph.add_edge("final_tool_node", END)
188
+ return graph.compile()
189
 
190
  def invoke(self, messages: List[Dict[str, Any]]):
191
  """Point d'entrée pour lancer une conversation dans le graphe."""