Adds a prompt column to a data frame of scientific articles, suitable for use with a language model summarization tool.
Prompts are generated using the build_prompt()
function, based on article titles and abstracts.
Arguments
- article
A data frame or tibble containing at least the columns
"title"
and"abstract"
.- ...
Additional arguments passed to
build_prompt()
, such asnsentences
.
Value
A modified data frame of class article_prompt
, including an additional column "prompt"
containing structured summarization prompts.
Details
The function checks for the presence of required columns before proceeding. It applies build_prompt()
row-wise to generate summarization prompts.
This function is typically used after retrieving articles via get_articles()
or get_article()
, to prepare data for summarization by a language model (e.g., using ollama::generate()
).
Examples
if (FALSE) { # \dontrun{
papers <- get_articles("Nature Medicine")
papers_with_prompts <- add_prompt(papers, nsentences = 3)
cat(papers_with_prompts$prompt[1])
} # }