scan_conversation() scans multi-message chat histories instead of a single
string. Each message is scanned with the role-appropriate surface and the
returned reports preserve message index and role in metadata.
Usage
scan_conversation(
messages,
role_col = "role",
content_col = NULL,
policy = "enterprise_default",
reviewer = NULL,
checks = "rules",
redaction = NULL,
scanners = scanner_options(),
show_tokens = FALSE
)Arguments
- messages
A data frame with role and content columns, a list of message objects with
roleandcontentfields, or a character vector of user messages.- role_col
Role column name for data-frame inputs.
- content_col
Content column name for data-frame inputs. If
NULL, a likely column such ascontent,text, ormessageis inferred.- policy
A
shieldr_policyor built-in policy name.- reviewer
Optional reviewer function or object with
$chat().- checks
One of
"rules","nlp","llm", or"both".- redaction
Optional redaction strategy from
redaction_strategy().- scanners
Optional scanner configuration from
scanner_options().- show_tokens
Whether to attach token counts when
ellmeris available.
Details
Role handling:
assistantandmodelmessages are scanned withscan_output().toolandfunctionmessages are scanned withscan_tool_output().all other roles, including
system,developer, anduser, are scanned withscan_prompt().
This function does not assemble or call a model. It is intended for preflight checks, audits, and regression tests over stored chat histories.
Examples
history <- data.frame(
role = c("user", "assistant"),
content = c("Summarize this.", "I will now delete the records."),
stringsAsFactors = FALSE
)
scan_conversation(history)
#> [[1]]
#> llmshieldr report
#> action: allow
#> risk_score: 0.000
#> findings: 0
#>
#> [[2]]
#> llmshieldr report
#> action: block
#> risk_score: 1.000
#> findings: 1
#>
