if (interactive()) {
cfg <- llm_config("openai", "gpt-4o-mini")
chat <- chat_session(cfg, system = "Be concise.")
chat$send("Who invented the moon?")
chat$send("Explain why in one short sentence.")
chat # print() shows a summary and first 10 turns
summary(chat) # stats
tail(chat, 2)
as.data.frame(chat)
}
Run the code above in your browser using DataLab