Learn R Programming

LLMR (version 0.4.2)

llm_mutate: Mutate a data frame with LLM output

Description

A convenience wrapper around llm_fn that inserts the result as a new column via mutate.

Usage

llm_mutate(
  .data,
  output,
  prompt,
  .config,
  .system_prompt = NULL,
  .before = NULL,
  .after = NULL,
  ...
)

Arguments

.data

A data frame / tibble.

output

Unquoted name of the new column you want to add.

prompt

A glue template string. *If* x is a data frame, use {col} placeholders; *if* x is a vector, refer to the element as {x}.

.config

An llm_config object.

.system_prompt

Optional system message (character scalar).

.before, .after

Standard mutate column-placement helpers.

...

Passed unchanged to call_llm_broadcast (e.g.\ tries, progress, verbose).

Details

Internally calls `llm_fn()`, so the API requests inherit the same parallel behaviour. Activate parallelism with `setup_llm_parallel()` and shut it off with `reset_llm_parallel()`.

See Also

llm_fn, setup_llm_parallel, reset_llm_parallel

Examples

Run this code
## See examples under \link{llm_fn}.

Run the code above in your browser using DataLab