Files
invariant-gateway/example_policy.gr
Luca Beurer-Kellner 7c0bb957fb Pipelined Guardrails (#32)
* initial draft: pipelined guardrails

* documentation on stream instrumentation

* more comments

* fix: return earlier

* non-streaming case

* handle non-streaming case

* fix more cases

* simplify request instrumentation

* improve comments

* fix import issues

* extend tests for input guardrailing

* anthropic integration of pipelined and pre-guardrailing

* fix gemini streamed refusal
2025-03-31 14:13:58 +02:00

7 lines
184 B
Plaintext

from invariant.detectors import prompt_injection
raise "Don't say 'Hello'" if:
(msg: Message)
msg.role == "user"
prompt_injection(msg.content)
# "Hello" in msg.content