guardrails
guardrails
¶
GuardrailsEngine — security-aware inference engine wrapper.
Classes¶
SecurityBlockError
¶
Bases: Exception
Raised when mode is BLOCK and security findings are detected.
GuardrailsEngine
¶
GuardrailsEngine(engine: InferenceEngine, *, scanners: Optional[List[BaseScanner]] = None, mode: RedactionMode = WARN, scan_input: bool = True, scan_output: bool = True, bus: Optional[EventBus] = None)
Bases: InferenceEngine
Wraps an existing InferenceEngine with security scanning.
Not registered in EngineRegistry — instantiated dynamically to wrap
any engine at runtime.
| PARAMETER | DESCRIPTION |
|---|---|
engine
|
The wrapped inference engine.
TYPE:
|
scanners
|
List of scanners to run. Defaults to
TYPE:
|
mode
|
Action taken on findings: WARN, REDACT, or BLOCK.
TYPE:
|
scan_input
|
Whether to scan input messages.
TYPE:
|
scan_output
|
Whether to scan output content.
TYPE:
|
bus
|
Optional event bus for publishing security events.
TYPE:
|
Source code in src/openjarvis/security/guardrails.py
Attributes¶
Functions¶
generate
¶
generate(messages: Sequence[Message], *, model: str, temperature: float = 0.7, max_tokens: int = 1024, **kwargs: Any) -> Dict[str, Any]
Scan input, call wrapped engine, scan output.
Source code in src/openjarvis/security/guardrails.py
stream
async
¶
stream(messages: Sequence[Message], *, model: str, temperature: float = 0.7, max_tokens: int = 1024, **kwargs: Any) -> AsyncIterator[str]
Yield tokens in real-time, scan accumulated output post-hoc.