ORromu commited on
Commit
bfd13b1
·
verified ·
1 Parent(s): 553d849

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +26 -16
agent.py CHANGED
@@ -33,19 +33,29 @@ tools = [add,
33
 
34
  chat_with_tools = chat.bind_tools(tools)
35
 
36
- ## Defining our nodes
37
- def assistant(state: MessagesState):
38
- """Assistant node"""
39
- return {"messages": [sys_msg] + [chat_with_tools.invoke(state["messages"])]}
40
-
41
- # Build graph / nodes
42
- builder = StateGraph(State)
43
- builder.add_node("assistant", chat) # Assistant
44
- builder.add_node("tools", ToolNode(tools)) # Tools
45
-
46
- # Logic / edges
47
- builder.add_edge(START, "assistant")
48
- builder.add_conditional_edges("assistant", tools_condition)
49
- builder.add_edge("tools", "assistant")
50
-
51
- graph = builder.compile()
 
 
 
 
 
 
 
 
 
 
 
33
 
34
  chat_with_tools = chat.bind_tools(tools)
35
 
36
+ def simple_graph():
37
+
38
+ ## Defining our nodes
39
+ def assistant(state: MessagesState):
40
+ """Assistant node"""
41
+ return {"messages": [sys_msg] + [chat_with_tools.invoke(state["messages"])]}
42
+
43
+ # Build graph / nodes
44
+ builder = StateGraph(State)
45
+ builder.add_node("assistant", chat) # Assistant
46
+ builder.add_node("tools", ToolNode(tools)) # Tools
47
+
48
+ # Logic / edges
49
+ builder.add_edge(START, "assistant")
50
+ builder.add_conditional_edges("assistant", tools_condition)
51
+ builder.add_edge("tools", "assistant")
52
+
53
+ graph = builder.compile()
54
+
55
+ return graph
56
+
57
+
58
+
59
+ if __name__ == "__main__":
60
+ # Build the graph
61
+ graph = simple_graph()