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
This commit is contained in:
Luca Beurer-Kellner
2025-03-31 14:13:58 +02:00
committed by GitHub
parent 4671c8b67e
commit 7c0bb957fb
13 changed files with 1659 additions and 495 deletions
+7
View File
@@ -0,0 +1,7 @@
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