## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")

## ----eval=FALSE---------------------------------------------------------------
# library(screenllm)
# check_setup()

## -----------------------------------------------------------------------------
library(screenllm)
toy_path <- system.file("extdata", "toy_cbfm.csv", package = "screenllm")
records <- read_records(toy_path)
head(records[, c("id", "title")])

## -----------------------------------------------------------------------------
criteria <- define_criteria(
  scope = "Articles potentially relevant to community-based fisheries management (CBFM) in Pacific Island contexts.",
  inclusions = c(
    "It is possible that the study includes a case study from a Pacific Island country (e.g. Fiji, Solomon Islands, Vanuatu, Papua New Guinea, Samoa, Tonga, or similar).",
    "It is possible that the study discusses fisheries and/or marine resource management.",
    "It is possible that the study discusses a community-based approach."
  )
)
print(criteria)

## -----------------------------------------------------------------------------
mock_ensemble <- custom_ensemble(
  models = c("gemma3:27b", "gpt-oss:20b"),
  replicates = 2,
  backend = backend_mock()
)
ranked <- rank_records(records, criteria, ensemble = mock_ensemble, verbose = FALSE)
head(ranked[, c("id", "title", "universal_best_score", "rank")])

## ----eval=FALSE---------------------------------------------------------------
# ranked <- rank_records(records, criteria, ensemble = default_ensemble())

## -----------------------------------------------------------------------------
plan <- plan_screening(ranked)
plan

## ----eval=FALSE---------------------------------------------------------------
# launch_screening_app(plan, ranked, out_file = "screening_decisions.csv")

## ----eval=FALSE---------------------------------------------------------------
# export_worksheet(plan, path = "to_screen.xlsx")
# # Reviewer fills in the human_decision column and saves as
# # 'to_screen_completed.xlsx'.
# decisions <- read_decisions("to_screen_completed.xlsx")

## ----eval=FALSE---------------------------------------------------------------
# report <- summarise_screening(ranked, decisions, plan = plan)
# print(report)
# 
# disagreements <- audit_disagreements(ranked, decisions)
# disagreements

