ageraustine commited on
Commit
9c43365
1 Parent(s): 1568509

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -13
app.py CHANGED
@@ -81,19 +81,21 @@ def get_state(messages):
81
  return "profile"
82
  return "info"
83
 
84
-
85
-
86
- memory = SqliteSaver.from_conn_string(":memory:")
87
-
88
- nodes = {k:k for k in ['info', 'profile', END]}
89
- workflow = MessageGraph()
90
- workflow.add_node("info", chain)
91
- workflow.add_node("profile", profile_gen_chain)
92
- workflow.add_conditional_edges("info", get_state, nodes)
93
- workflow.add_conditional_edges("profile", get_state, nodes)
94
- workflow.set_entry_point("info")
95
- graph = workflow.compile(checkpointer=memory)
96
-
 
 
97
  config = {"configurable": {"thread_id": str(uuid.uuid4())}}
98
 
99
  # Streamlit app layout
 
81
  return "profile"
82
  return "info"
83
 
84
+ @st.cache_resource
85
+ def get_graph():
86
+ memory = SqliteSaver.from_conn_string(":memory:")
87
+
88
+ nodes = {k:k for k in ['info', 'profile', END]}
89
+ workflow = MessageGraph()
90
+ workflow.add_node("info", chain)
91
+ workflow.add_node("profile", profile_gen_chain)
92
+ workflow.add_conditional_edges("info", get_state, nodes)
93
+ workflow.add_conditional_edges("profile", get_state, nodes)
94
+ workflow.set_entry_point("info")
95
+ graph = workflow.compile(checkpointer=memory)
96
+ return graph
97
+
98
+ graph = get_graph()
99
  config = {"configurable": {"thread_id": str(uuid.uuid4())}}
100
 
101
  # Streamlit app layout