if (FALSE) {
custom <- build_custom_agent(
node_functions = list(
start = function(state) make_command("classify"),
classify = function(state) {
if (grepl("weather", state$query, ignore.case = TRUE)) {
make_command("weather")
} else {
make_command("general")
}
},
weather = function(state) list(answer = "Routing to weather handler"),
general = function(state) list(answer = "Routing to general handler")
),
entry_point = "start",
edges = list(c("weather", "__end__"), c("general", "__end__")),
output = "both",
subgraphs = list(
Router = c("start", "classify"),
Handlers = c("weather", "general")
)
)
cat(custom$mermaid)
custom$run(list(query = "weather in Accra"))
}
Run the code above in your browser using DataLab