Events
Record GuardrailEvent rows: the audit trail of guardrails.
For the pii and secrets categories, the excerpt is masked, so that the event does not
store the personal data or secret that the guardrail detected: personal data keeps its last
four characters, and secrets only their length.
- smarter.apps.guardrail.services.events.excerpt(finding, segment_text)[source]
Return the excerpt of a finding, for its event: its matches, or the segment, masked for.
the
piiandsecretscategories.
- smarter.apps.guardrail.services.events.mask(text, category)[source]
Mask a match, for an event’s excerpt.
- smarter.apps.guardrail.services.events.record_event(*, guardrail, stage, disposition, finding=None, segment_text=None, error=None, llmclient=None, session_key=None)[source]
Record a guardrail event.
A failure to record is logged, and does not fail the prompt.
- Return type:
- Returns:
The event, or
Noneif it could not be recorded.