Skip to contents

Returns one row per problem: a hard failure (success not TRUE) or a truncated / content-filtered completion (finish_reason "length" or "filter"), with the diagnostic detail needed to act. Works on both call_llm_par() and llm_mutate() results. For a call_llm_par() result (which still carries config and messages), pass the original frame to llm_par_resume() to re-run only these rows.

Usage

llm_failures(x, prefix = NULL, include = c("all", "failed", "truncated"))

Arguments

x

A data frame from call_llm_par() or llm_mutate().

prefix

For an llm_mutate() result, the output column name whose diagnostics to summarize (e.g. "answer"). Inferred automatically when a single diagnostic block is present; required when several are.

include

One of "failed" (hard failures only), "truncated" (length/filter only), or "all" (default; both).

Value

A tibble (zero rows if nothing matched) with: row (index into x), success, finish_reason, status_code, error_code, bad_param, error_message, response_id. Columns absent from x are filled with NA.

See also

llm_par_resume() to re-run failed rows, llm_usage().

Examples

res <- tibble::tibble(
  success = c(TRUE, FALSE, TRUE),
  finish_reason = c("stop", "error:server", "length"),
  error_message = c(NA, "HTTP 503", NA)
)
llm_failures(res)