## ----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.7) ## ----robustness--------------------------------------------------------------- # rate_risk <- function(cond, rep, perturb) { # a <- agent("Rater", perturb$config) # answer <- a$reply(perturb$prompt( # "On a scale of 1 to 10, how risky is skydiving? Reply with one integer." # )) # as.numeric(gsub("[^0-9].*$", "", trimws(answer))) # } # # battery <- agent_robustness( # rate_risk, # vary = list(temperature = c("0", "1")), # reps = 3, # measure = function(x) x, # config = cfg # ) # # battery$by_axis # battery$overall ## ----personas----------------------------------------------------------------- # base <- persona_frame( # "A first-time voter in a competitive district.", # source = "synthetic", # scope = list(country = "US") # ) # # set <- persona_variants( # base, # vary = list(age = c("22", "52"), # employment = c("salaried", "hourly")) # ) # # audit <- persona_audit(set) # audit # diagnostics(audit) ## ----claims------------------------------------------------------------------- # coder <- agent("Coder", cfg) # coder$chat("Is this abstract about climate? Answer yes or no.\n...") # run <- mark_claim_type(as_agent_run(coder), "coding") # # report(run) ## ----lint--------------------------------------------------------------------- # llm_claim_lint( # "We find that 60% of Americans support the policy.", # run = run, # action = "scope" # )