Skip to contents

This function is a wrapper around ai_text() to compute salience scores for topics in a corpus using a chat function.

Usage

ai_salience(.data, topics, chat_fn, ..., verbose = TRUE)

Arguments

.data

a character or quanteda::corpus object containing the documents to be summarized

topics

character; a vector of topic names for which salience scores will be computed; the scores sum to 1 across all topics

chat_fn

function; a chat function from ellmer

...

additional arguments passed to chat_fn

verbose

logical; output a progress indicator if TRUE

Value

character; the response from the LLM with a length equal to the number of input documents, with the elements named with the input element names

Examples

if (FALSE) { # \dontrun{
library(quanteda)
salience <- ai_salience(data_corpus_inaugural[1:3],
                        chat_fn = chat_openai, model = "gpt-4o",
                        api_args = list(temperature = 0, seed = 42),
                        topics = c("economy", "environment", "healthcare"))
} # }