| llm_mutate_structured | R Documentation |
Drop-in schema-first variant of llm_mutate(). Produces parsed columns.
llm_mutate_structured(
.data,
output,
prompt = NULL,
.messages = NULL,
.config,
.system_prompt = NULL,
.before = NULL,
.after = NULL,
.schema = NULL,
.fields = NULL,
...
)
.data |
A data.frame / tibble. |
output |
Unquoted name that becomes the new column (generative) or the prefix for embedding columns. |
prompt |
Optional glue template string for a single user turn; reference
any columns in |
.messages |
Optional named character vector of glue templates to build
a multi-turn message, using roles in |
.config |
An llm_config object (generative or embedding). |
.system_prompt |
Optional system message sent with every request when
|
.before, .after |
Standard dplyr::relocate helpers controlling where the generated column(s) are placed. |
.schema |
Optional JSON Schema (R list). When provided, this schema is sent to
the provider for strict validation and used for local parsing. When |
.fields |
Optional character vector of fields to extract from parsed JSON. Supports:
|
... |
Passed to the underlying calls: |
Like llm_mutate(), this function supports shorthand syntax:
df |> llm_mutate_structured(result = "{text}", .schema = schema)
df |> llm_mutate_structured(result = c(system = "Be brief.", user = "{text}"), .schema = schema)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.