Skip to contents

A shieldr_result is the high-level return value from secure_chat() and shield_ollama().

Usage

shieldr_result(output = NULL, audit, risk_summary, action)

Arguments

output

Cleaned model output, or NULL.

audit

A shieldr_audit object.

risk_summary

Named numeric vector keyed by OWASP category.

action

Final action. May be "allow", "redact", "block", "refuse", or "escalate".

Value

A shieldr_result S3 object.

Details

output is NULL when the final action is block; otherwise it contains the cleaned model output. risk_summary aggregates finding severity scores by OWASP category across prompt, context, and output reports, capping each category at 1.0. This gives dashboards and audit logs a compact view of which OWASP categories were triggered.

Examples

aud <- shieldr_audit(NULL, NULL, NULL, "hello", NULL, 0, 1L, "allow")
shieldr_result(NULL, aud, numeric(), "allow")
#> $output
#> NULL
#> 
#> $audit
#> $input_report
#> NULL
#> 
#> $output_report
#> NULL
#> 
#> $context_reports
#> NULL
#> 
#> $prompt_clean
#> [1] "hello"
#> 
#> $output_raw
#> NULL
#> 
#> $elapsed_ms
#> [1] 0
#> 
#> $token_estimate
#> [1] 1
#> 
#> $action
#> [1] "allow"
#> 
#> attr(,"class")
#> [1] "shieldr_audit"
#> 
#> $risk_summary
#> numeric(0)
#> 
#> $action
#> [1] "allow"
#> 
#> attr(,"class")
#> [1] "shieldr_result"