nikhmr1235 commited on
Commit
209f479
·
verified ·
1 Parent(s): 058ffea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -121,15 +121,19 @@ def resume_graph(human_input_from_ui: str, thread_id_state):
121
  print(f"Type of global_memory_saver before put_state: {type(global_memory_saver)}") # ADD THIS LINE
122
 
123
  # Use put_state() from the SqliteSaver instance
124
- global_memory_saver.put_state(current_state_values, {"configurable": {"thread_id": thread_id_state}})
125
 
126
- for s in global_graph.stream(None, {"configurable": {"thread_id": thread_id_state}}):
 
 
 
 
127
  if "__end__" in s:
128
  break
129
  else:
130
  pass
131
 
132
- final_state_snapshot = global_graph.get_state({"configurable": {"thread_id": thread_id_state}})
133
  final_state_values = final_state_snapshot.values
134
 
135
  final_message = final_state_values.get("final_response", "Graph finished without final response.")
@@ -139,6 +143,7 @@ def resume_graph(human_input_from_ui: str, thread_id_state):
139
  return (f"An error occurred during graph resumption: {e}",
140
  gr.update(interactive=False), gr.update(interactive=False), gr.update(interactive=True), thread_id_state)
141
 
 
142
  # Gradio Interface setup
143
  with gr.Blocks() as demo:
144
  gr.Markdown("# LangGraph Human-in-the-Loop Demo (SqliteSaver)")
 
121
  print(f"Type of global_memory_saver before put_state: {type(global_memory_saver)}") # ADD THIS LINE
122
 
123
  # Use put_state() from the SqliteSaver instance
124
+ #global_memory_saver.put_state(current_state_values, {"configurable": {"thread_id": thread_id_state}})
125
 
126
+ # Update the state directly
127
+ config = {"configurable": {"thread_id": thread_id_state}}
128
+ global_graph.update_state(config, current_state_values)
129
+
130
+ for s in global_graph.stream(None, config):
131
  if "__end__" in s:
132
  break
133
  else:
134
  pass
135
 
136
+ final_state_snapshot = global_graph.get_state(config)
137
  final_state_values = final_state_snapshot.values
138
 
139
  final_message = final_state_values.get("final_response", "Graph finished without final response.")
 
143
  return (f"An error occurred during graph resumption: {e}",
144
  gr.update(interactive=False), gr.update(interactive=False), gr.update(interactive=True), thread_id_state)
145
 
146
+
147
  # Gradio Interface setup
148
  with gr.Blocks() as demo:
149
  gr.Markdown("# LangGraph Human-in-the-Loop Demo (SqliteSaver)")