| llm_preview | R Documentation |
Renders every row exactly as llm_fn() / llm_mutate() would (no API call,
no file I/O), then reports a tidy, row-level summary: the rendered text, the
roles, character counts, file presence and existence, the batch plan, and a
list-column of issues. Problems that would only surface mid-run (a missing
file, a "file" role combined with .rows_per_prompt > 1, an embedding config
with row batching, .return = "object" with batching, a schema supplied
without .structured, a template that references NA values or renders an
empty prompt, a file part with no accompanying user text, or a tag name that
collides with the batched <row_N> protocol) are collected per row so you
see all of them at once rather than hitting the first error.
llm_preview(
.data,
prompt = NULL,
.messages = NULL,
.system_prompt = NULL,
.config = NULL,
.structured = FALSE,
.schema = NULL,
.tags = NULL,
.return = c("columns", "text", "object"),
.rows_per_prompt = 1L,
rows = NULL,
max_chars = 500L
)
.data |
A data.frame/tibble whose columns feed the |
prompt |
A single |
.messages |
A character vector of |
.system_prompt |
Optional system string, prepended when a row has no
|
.config |
Optional |
.structured |
Logical; if |
.schema |
Optional JSON schema (list). Flagged if supplied without
|
.tags |
Optional character vector of tag names. Flagged if combined with
|
.return |
One of |
.rows_per_prompt |
Rows per call. |
rows |
Optional integer vector selecting which rows to render (default: all rows). |
max_chars |
Truncate each row's rendered preview to this many characters (default 500). Set higher to see full prompts. |
Batched data travels inside numbered <row_i>...</row_i> tags; the
rowpack_id / rows_per_prompt / rowpack_row columns show how rows would be
grouped into calls at the given .rows_per_prompt.
A tibble of class llmr_preview, one row per previewed input row,
with columns: row, ok (no issues), roles, rendered_preview,
chars, has_file, file_ok, rowpack_id, rows_per_prompt, rowpack_row, and
issues (a list-column of character vectors).
llm_render_messages(), llm_usage(), llm_failures().
df <- data.frame(text = c("a", "b", "c"), stringsAsFactors = FALSE)
llm_preview(df, prompt = "Classify: {text}", .rows_per_prompt = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.