| llm_fn_structured | R Documentation |
Schema-first variant of llm_fn(). It enables structured output on the config,
calls the model via call_llm_broadcast(), parses JSON, and optionally validates.
llm_fn_structured(
x,
prompt,
.config,
.system_prompt = NULL,
...,
.schema = NULL,
.fields = NULL,
.local_only = FALSE,
.validate_local = TRUE,
.rows_per_prompt = 1L,
.rowpack_payload = c("user", "system"),
.rowpack_recovery = c("halve_recursive", "halve_once", "singletons", "retry_same",
"none")
)
x |
A character vector or a data.frame/tibble. |
prompt |
A glue template string. With a data-frame you may reference
columns ( |
.config |
An llm_config object. |
.system_prompt |
Optional system message (character scalar). |
... |
Passed unchanged to |
.schema |
Optional JSON Schema list; if |
.fields |
Optional fields to hoist from parsed JSON (supports nested paths). |
.local_only |
If TRUE, do not send schema to the provider (parse/validate locally). |
.validate_local |
If TRUE and |
.rows_per_prompt |
Integer scalar, or |
.rowpack_payload |
One of |
.rowpack_recovery |
How to handle rows that a batched call leaves unresolved (dropped, malformed, or truncated). One of:
Recovery is bounded by an internal call budget so it always terminates. |
A tibble: the call_llm_broadcast() diagnostics plus the parsed
structured columns (structured_ok, structured_data, one column per
hoisted field, and structured_valid/structured_error when .schema is
validated locally).
llm_fn(), llm_mutate_structured(), enable_structured_output(),
llm_parse_structured_col()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.