Skip to contents

as_vitals_solver() wraps a module in a function that a vitals Task can call as its solver. The solver runs the module with run_dataset(), so the module's demonstrations, template and input descriptions are used as usual. as_vitals_task() builds the whole task in one step.

Usage

as_vitals_solver(module, .llm = NULL, .concurrency = NULL, ...)

Arguments

module

A module, such as one created with module().

.llm

An ellmer Chat. NULL (the default) uses the module's own chat or the default chat from get_default_chat(), resolved when the solver is created. Each batch runs on a fresh clone.

.concurrency

Optional policy from concurrency_control().

...

Further arguments passed to run_dataset().

Value

A function function(inputs, ..., solver_chat) that returns a list with result (character vector), solver_chat (the chats used) and, for non-text outputs, solver_metadata.

Details

vitals passes the solver a list of inputs. For a module with several inputs, each element must be a one-row data frame or list with fields named after the signature inputs; as_vitals_task() creates that structure from a flat data set.

String and enum outputs, including a single string or enum field, are returned as plain text, which string scorers such as vitals::detect_match() can compare. Other outputs are returned as JSON, together with per-row metadata. Rows run one after another unless .concurrency asks for more.

Examples

solver <- as_vitals_solver(
  module(signature("question -> answer")),
  .llm = ellmer::chat_openai(model = "gpt-6-luna")
)

if (FALSE) { # \dontrun{
tsk <- vitals::Task$new(
  dataset = tibble::tibble(input = "What is 2 + 2?", target = "4"),
  solver = solver,
  scorer = vitals::detect_includes()
)
tsk$eval()
} # }