DrishtiSharma commited on
Commit
368d3b7
Β·
verified Β·
1 Parent(s): 2b42de2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -11,7 +11,7 @@ import os
11
 
12
  # Streamlit UI Header
13
  st.title("Checkpoints and Breakpoints")
14
- #st.caption("A detailed demonstration of graph workflow execution with checkpoints and manual intervention.")
15
 
16
  # Fetch API Keys from Hugging Face Secrets
17
  openai_api_key = os.getenv("OPENAI_API_KEY")
@@ -33,7 +33,9 @@ if openai_api_key and tavily_api_key:
33
 
34
  # Agent Function
35
  def Agent(state: State):
36
- return {"messages": [llm_with_tools.invoke(state["messages"])]}
 
 
37
 
38
  # Memory Checkpoint
39
  memory = MemorySaver()
@@ -57,7 +59,7 @@ if openai_api_key and tavily_api_key:
57
 
58
  # Input Section
59
  st.subheader("Run the Workflow")
60
- user_input = st.text_input("Enter a message to start the graph:", "Hello, I am from U.P.")
61
  thread_id = st.text_input("Thread ID", "1")
62
 
63
  if st.button("Execute Workflow"):
@@ -71,14 +73,14 @@ if openai_api_key and tavily_api_key:
71
  latest_message = event["messages"][-1].pretty_print()
72
  outputs.append(latest_message)
73
  st.code(latest_message)
74
-
75
  if outputs:
76
  st.subheader("Intermediate Outputs")
77
  for i, output in enumerate(outputs, 1):
78
  st.write(f"**Step {i}:**")
79
  st.code(output)
80
  else:
81
- st.warning("No outputs generated.")
82
 
83
  # Snapshot of Current State
84
  st.subheader("Current State Snapshot")
 
11
 
12
  # Streamlit UI Header
13
  st.title("Checkpoints and Breakpoints")
14
+ st.caption("Demonstrating workflow execution with checkpoints and tool invocation.")
15
 
16
  # Fetch API Keys from Hugging Face Secrets
17
  openai_api_key = os.getenv("OPENAI_API_KEY")
 
33
 
34
  # Agent Function
35
  def Agent(state: State):
36
+ response = llm_with_tools.invoke(state["messages"])
37
+ print("Agent Response:", response)
38
+ return {"messages": [response]}
39
 
40
  # Memory Checkpoint
41
  memory = MemorySaver()
 
59
 
60
  # Input Section
61
  st.subheader("Run the Workflow")
62
+ user_input = st.text_input("Enter a message to start the graph:", "Search for the weather in Uttar Pradesh")
63
  thread_id = st.text_input("Thread ID", "1")
64
 
65
  if st.button("Execute Workflow"):
 
73
  latest_message = event["messages"][-1].pretty_print()
74
  outputs.append(latest_message)
75
  st.code(latest_message)
76
+
77
  if outputs:
78
  st.subheader("Intermediate Outputs")
79
  for i, output in enumerate(outputs, 1):
80
  st.write(f"**Step {i}:**")
81
  st.code(output)
82
  else:
83
+ st.warning("No outputs generated. Adjust your input to trigger tools.")
84
 
85
  # Snapshot of Current State
86
  st.subheader("Current State Snapshot")