Defines a narrow adapter contract for external or local detectors. The
provider function receives text, stage, and a metadata list, and returns
either a list of findings or list(findings = ..., status = ...). Nothing is
contacted until a scan using the provider runs.
Arguments
- id
Stable provider identifier.
- scan
Function with arguments
text,stage, andmetadata.- version
Detector, ruleset, or service version.
- stages
Stages on which the provider may run.
- on_error
Whether provider errors create a blocking finding or are skipped with a warning.
- retries
Number of retries after the first failed call.
- timeout_seconds
Optional elapsed-time limit for each attempt. R and the underlying client must support interruption for this to stop promptly.
- show_stats
Show construction time and available usage metrics.
Value
A shieldr_provider object for scanner_options().
Examples
detector <- guardrail_provider(
"example/local",
function(text, stage, metadata) list()
)
scan_prompt("hello", scanners = scanner_options(providers = list(detector)))
#> llmshieldr report
#> action: allow
#> risk_score: 0.000
#> findings: 0
