A node that maps over a list in the state and performs an operation.
Super class
HydraR::AgentNode -> AgentMapNode
Public fields
map_keyString. Key in state to map over.
logic_fnFunction(item, state) -> List(status, output).
Methods
Method new()
Initialize AgentMapNode
Usage
AgentMapNode$new(id, map_key, logic_fn, label = NULL, params = list())Examples
if (FALSE) { # \dontrun{
# Mapping over a list of URLs to fetch data
fetch_logic <- function(url, state) {
# Custom logic for each item
list(status = "success", output = paste0("Data from ", url))
}
node_map <- AgentMapNode$new(
id = "batch_fetcher",
map_key = "url_list",
logic_fn = fetch_logic
)
# Setup state with items to map over
state <- AgentState$new(list(url_list = c("url1", "url2", "url3")))
results <- node_map$run(state)
} # }