106 Inspect
prompt_designs %>% head() # Note: prompt_text uses the meme’s format/description; you can customize per design if you wish.
Part B: Build prompts, call API, and collect results 3) Generate captions for all memes under both designs - For each row in prompt_designs, build a chat messages payload and call the API. - Store both the caption and some metadata (length, token-like count, etc.).
Code: # Helper: build messages for a prompt build_messages <- function(desc, design_label) { system_msg <- “You are a witty meme caption generator with data-science flavor.” user_msg <- paste0(“Meme design”, design_label, “. Description:”, desc, ” Please output a short, humorous caption (<= 20 words).”) list(list(role = “system”, content = system_msg), list(role = “user”, content = user_msg)) }