Skip to contents

The native panel: readers read the FULL report and answer every field with a supporting quote and confidence; after a hard barrier the auditors (a review chain, each auditing the previous stage) issue the final values. mode 1 = one reader, no auditor; 2 = 1 reader + auditor; 3 = 2 readers + auditor; 4 = 3 readers + auditor. num_readers / num_auditors scale beyond the presets. Readers run concurrently up to reader_concurrency (0 = all) against an HTTP backend; with a custom chat function they run one after another in this R session. Models that return an empty reply are dropped first (health_check). Works with any backend of morie_llm_backend.

Usage

morie_siu_audit_panel(
  report_text,
  parsed = NULL,
  mode = 4L,
  readers = NULL,
  auditors = NULL,
  num_readers = 0L,
  num_auditors = 0L,
  reader_concurrency = 0L,
  auditor_sequential = TRUE,
  reader_granularity = c("all", "per-field"),
  auditor_granularity = c("all", "per-field"),
  health_check = TRUE,
  api = "",
  base = "",
  key = "",
  timeout = 300,
  temperature = 0,
  chat = NULL
)

Arguments

report_text

Report text (see morie_siu_html_to_text).

parsed

Named list or character vector of parser guesses (default: morie_siu_parse_report of the text), or a JSON string.

mode

Panel mode 1-4.

readers, auditors

Model names (NULL: the default model).

num_readers, num_auditors

Counts (0: from the mode / lists).

reader_concurrency

Readers in flight (0 = all, 1 = sequential).

auditor_sequential

Serialize the auditor tier.

reader_granularity, auditor_granularity

"all" (one prompt for every field) or "per-field" (re-read the report once per field).

health_check

Drop models that return an empty reply.

api, base, key, timeout, temperature, chat

Backend, see morie_llm_backend.

Value

A list: fields (the final record, parsed) and json (the raw JSON string).

Examples

fake <- function(model, prompt) {
  if (startsWith(prompt, "Reply with")) return("OK")
  if (grepl("You are the AUDITOR", prompt,
  fixed = TRUE)) return('{"police_service": "Barrie Police Service"}')
  '{"police_service": {"value": "Barrie", "quote": "Barrie", "confidence": "high"}}'
}
morie_siu_audit_panel("The Barrie Police Service ...", mode = 2, readers = "r1",
  chat = fake)$fields
#> $police_service
#> [1] "Barrie Police Service"
#>