Spaces:
Paused
Paused
builder
Browse files
app.py
CHANGED
|
@@ -88,4 +88,20 @@ def assistant(state: AgentState):
|
|
| 88 |
## The graph
|
| 89 |
builder = StateGraph(AgentState)
|
| 90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
demo.launch()
|
|
|
|
| 88 |
## The graph
|
| 89 |
builder = StateGraph(AgentState)
|
| 90 |
|
| 91 |
+
# Define nodes: these do the work
|
| 92 |
+
builder.add_node("assistant", assistant)
|
| 93 |
+
builder.add_node("tools", ToolNode(tools))
|
| 94 |
+
|
| 95 |
+
# Define edges: these determine how the control flow moves
|
| 96 |
+
builder.add_edge(START, "assistant")
|
| 97 |
+
builder.add_conditional_edges(
|
| 98 |
+
"assistant",
|
| 99 |
+
# If the latest message requires a tool, route to tools
|
| 100 |
+
# Otherwise, provide a direct response
|
| 101 |
+
tools_condition,
|
| 102 |
+
)
|
| 103 |
+
builder.add_edge("tools", "assistant")
|
| 104 |
+
alfred = builder.compile()
|
| 105 |
+
|
| 106 |
+
|
| 107 |
demo.launch()
|