Skip to contents

Returns diagnostic rows for calls whose success value is not TRUE and, according to include, replies whose finish_reason is "length" or "filter". Accepts results from call_llm_par() and llm_mutate().

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.

Details

Pass the original call_llm_par() result to llm_par_resume() to repeat rows whose success value is not TRUE. Successful truncated or filtered replies are retained. To repeat those requests, pass their config and messages columns to call_llm_par(). A token-limit truncation may require a larger max_tokens value in the configuration.

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)