| llm_fn | R Documentation |
Apply an LLM prompt over vectors/data frames
llm_fn(
x,
prompt,
.config,
.system_prompt = NULL,
...,
.return = c("text", "columns", "object")
)
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 |
.return |
One of |
For generative mode:
.return = "text": character vector
.return = "columns": tibble with diagnostics
.return = "object": list of llmr_response (or NA on failure)
For embedding mode, always a numeric matrix.
llm_mutate(), llm_fn_structured(), setup_llm_parallel(),
call_llm_broadcast(), get_batched_embeddings()
## Not run:
words <- c("excellent", "awful")
cfg <- llm_config("openai", "gpt-4.1-nano", temperature = 0)
llm_fn(words, "Classify '{x}' as Positive/Negative.", cfg, .return = "text")
df <- tibble::tibble(text = words, source = c("review", "review"))
llm_fn(df, "Classify '{text}' from {source}.", cfg, .return = "columns")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.