predict() on a module is run_dataset() under the name tidymodels users
expect: predict(module, new_data) is run_dataset(module, new_data).
Usage
# S3 method for class 'Module'
predict(object, new_data, .llm = NULL, ...)Arguments
- object
A module, such as one created with
module().- new_data
A data frame with one column per signature input.
- .llm
An ellmer Chat to use instead of the one stored on
objector the default chat.- ...
Passed to
run_dataset(), for example.return_format,.concurrencyor.cache.
Value
A tibble with the columns of new_data plus a result
list-column holding each row's output as a named list, exactly as
returned by run_dataset().
See also
Other execution:
concurrency_control(),
evaluate(),
run(),
run_async(),
run_dataset(),
run_stream(),
stream_async(),
stream_listener()
Examples
shout <- module_fn("text -> reply", function(text) toupper(text))
predictions <- predict(shout, data.frame(text = c("great", "terrible")))
predictions
#> # A tibble: 2 × 2
#> text result
#> <chr> <list>
#> 1 great <named list [1]>
#> 2 terrible <named list [1]>
vapply(predictions$result, function(r) r$reply, character(1))
#> [1] "GREAT" "TERRIBLE"