Update app.py
Browse files
app.py
CHANGED
|
@@ -13,7 +13,7 @@ import os
|
|
| 13 |
st.title("Checkpoints and Breakpoints")
|
| 14 |
st.caption("Demonstrating workflow execution with checkpoints and tool invocation.")
|
| 15 |
|
| 16 |
-
# Fetch API Keys
|
| 17 |
openai_api_key = os.getenv("OPENAI_API_KEY")
|
| 18 |
tavily_api_key = os.getenv("TAVILY_API_KEY")
|
| 19 |
|
|
@@ -33,6 +33,8 @@ if openai_api_key and tavily_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]}
|
|
@@ -46,7 +48,12 @@ if openai_api_key and tavily_api_key:
|
|
| 46 |
|
| 47 |
graph.add_node("Agent", Agent)
|
| 48 |
graph.add_node("tools", tool_node)
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
graph.add_edge("tools", "Agent")
|
| 51 |
graph.set_entry_point("Agent")
|
| 52 |
|
|
|
|
| 13 |
st.title("Checkpoints and Breakpoints")
|
| 14 |
st.caption("Demonstrating workflow execution with checkpoints and tool invocation.")
|
| 15 |
|
| 16 |
+
# Fetch API Keys
|
| 17 |
openai_api_key = os.getenv("OPENAI_API_KEY")
|
| 18 |
tavily_api_key = os.getenv("TAVILY_API_KEY")
|
| 19 |
|
|
|
|
| 33 |
|
| 34 |
# Agent Function
|
| 35 |
def Agent(state: State):
|
| 36 |
+
print("Agent received state:", state)
|
| 37 |
+
# Force tool invocation
|
| 38 |
response = llm_with_tools.invoke(state["messages"])
|
| 39 |
print("Agent Response:", response)
|
| 40 |
return {"messages": [response]}
|
|
|
|
| 48 |
|
| 49 |
graph.add_node("Agent", Agent)
|
| 50 |
graph.add_node("tools", tool_node)
|
| 51 |
+
|
| 52 |
+
# Force tools_condition always True for testing purposes
|
| 53 |
+
def always_true(state):
|
| 54 |
+
return True
|
| 55 |
+
|
| 56 |
+
graph.add_conditional_edges("Agent", always_true, {"True": "tools"})
|
| 57 |
graph.add_edge("tools", "Agent")
|
| 58 |
graph.set_entry_point("Agent")
|
| 59 |
|