if (FALSE) {
library(batchLLM)
# Set API keys
Sys.setenv(OPENAI_API_KEY = "your_openai_api_key")
Sys.setenv(ANTHROPIC_API_KEY = "your_anthropic_api_key")
Sys.setenv(GEMINI_API_KEY = "your_gemini_api_key")
# Define LLM configurations
llm_configs <- list(
list(LLM = "openai", model = "gpt-4o-mini"),
list(LLM = "anthropic", model = "claude-3-haiku-20240307"),
list(LLM = "google", model = "1.5-flash")
)
# Apply batchLLM function to each configuration
beliefs <- lapply(llm_configs, function(config) {
batchLLM(
df = beliefs,
col = statement,
prompt = "classify as a fact or misinformation in one word",
LLM = config$LLM,
model = config$model,
batch_size = 10,
batch_delay = "1min",
case_convert = "lower"
)
})[[length(llm_configs)]]
# Print the updated data frame
print(beliefs)
}
Run the code above in your browser using DataLab