Shago commited on
Commit
de78c81
·
verified ·
1 Parent(s): 1881245

Update interfaces/interface.py

Browse files
Files changed (1) hide show
  1. interfaces/interface.py +6 -17
interfaces/interface.py CHANGED
@@ -8,33 +8,22 @@ def create_interface():
8
 
9
  graph = StateGraph(AgentState)
10
  graph.add_node("agent", agent_node)
 
 
 
 
11
  graph.add_conditional_edges(
12
  "agent",
13
  lambda state: "tool" if state["messages"][-1].tool_calls else "format",
14
  {"tool": "tool", "format": "format"}
15
  )
16
- graph.add_node("tool", tool_node)
17
- graph.add_node("format", format_output)
18
-
19
- graph.set_entry_point("agent")
20
- graph.add_edge("agent", "tool")
21
  graph.add_edge("tool", "format")
22
- graph.add_conditional_edges(
23
- "tool",
24
- lambda state: "format",
25
- {"format": "format"}
26
- )
27
  graph.add_edge("format", END)
 
 
28
 
29
  app = graph.compile()
30
 
31
- # def process_query(query: str) -> dict:
32
- # try:
33
- # inputs = {"messages": [HumanMessage(content=query)]}
34
- # result = app.invoke(inputs)
35
- # return messages_to_dict(result['messages'])[2]['data']['content']
36
- # except Exception as e:
37
- # return {"error": f"Execution error: {str(e)}"}
38
 
39
  def process_query(query: str) -> dict:
40
  try:
 
8
 
9
  graph = StateGraph(AgentState)
10
  graph.add_node("agent", agent_node)
11
+ graph.add_node("tool", tool_node)
12
+ graph.add_node("format", format_output)
13
+
14
+ # Conditional routing
15
  graph.add_conditional_edges(
16
  "agent",
17
  lambda state: "tool" if state["messages"][-1].tool_calls else "format",
18
  {"tool": "tool", "format": "format"}
19
  )
 
 
 
 
 
20
  graph.add_edge("tool", "format")
 
 
 
 
 
21
  graph.add_edge("format", END)
22
+
23
+
24
 
25
  app = graph.compile()
26
 
 
 
 
 
 
 
 
27
 
28
  def process_query(query: str) -> dict:
29
  try: