## ----include=FALSE------------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE, comment = "#>",
  eval = identical(tolower(Sys.getenv("LLMRAGENT_RUN_VIGNETTES", "false")), "true")
)

## ----setup--------------------------------------------------------------------
# library(LLMRagent)
# cfg <- LLMR::llm_config("groq", "openai/gpt-oss-20b", temperature = 0.8)

## ----debate-------------------------------------------------------------------
# d <- debate(
#   pro   = agent("Pro", cfg, persona = "You argue FOR the motion. Rigorous, concrete."),
#   con   = agent("Con", cfg, persona = "You argue AGAINST the motion. Rigorous, concrete."),
#   topic = "Algorithmic screening should be banned from hiring decisions.",
#   rounds = 1,
#   judge = agent("Judge", cfg, persona = "A strict, impartial debate judge.")
# )
# d                     # compact print: motion, statements, verdict
# d$transcript          # tidy: turn, phase, speaker, text
# d$verdict$reasoning

## ----focus-group--------------------------------------------------------------
# fg <- focus_group(
#   moderator = agent("Mod", cfg, persona = "A neutral, probing focus-group moderator."),
#   participants = list(
#     agent("Maya", cfg, persona = "A 34-year-old nurse; prudent, skeptical of tech."),
#     agent("Tom",  cfg, persona = "A 22-year-old gig worker; tech-optimistic."),
#     agent("Ines", cfg, persona = "A 58-year-old teacher; worries about fairness.")
#   ),
#   topic = "Using AI screening in hiring",
#   questions = c(
#     "How would you feel if an algorithm screened your next job application?",
#     "What, if anything, would make that acceptable to you?"
#   )
# )
# fg$summary            # the moderator's synthesis
# fg$transcript         # utterance-level frame for content analysis

## ----interview----------------------------------------------------------------
# iv <- interview(
#   interviewer = agent("Interviewer", cfg,
#                       persona = "A careful qualitative researcher."),
#   respondent  = agent("Respondent", cfg,
#                       persona = "A warehouse worker whose shift assignments are set by software."),
#   topic = "Working under algorithmic management",
#   n_questions = 3
# )
# iv[, c("type", "question")]

## ----deliberate---------------------------------------------------------------
# panel <- list(
#   agent("Aila", cfg, persona = "Data-driven; cautious about unintended effects."),
#   agent("Bo",   cfg, persona = "Mission-driven; impatient with delay."),
#   agent("Cyn",  cfg, persona = "A budget hawk. Blunt.")
# )
# dl <- deliberate(panel,
#                  proposal = "Adopt AI resume screening for all entry-level hiring.",
#                  rounds = 2)
# dl$votes              # voter, vote, reason
# dl$decision

## ----analyze------------------------------------------------------------------
# # Who spoke most, and how much?
# tr <- fg$transcript
# aggregate(nchar(text) ~ speaker, data = tr, FUN = sum)
# 
# # Score each utterance for stance with a one-line LLMR call:
# scored <- LLMR::llm_mutate(
#   tr, stance,
#   prompt = "One word, support/oppose/neutral. Stance on AI hiring in: {text}",
#   .config = cfg
# )
# table(scored$speaker, scored$stance)

