mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-14 09:03:16 +00:00
fix(proxy): also redact instructions and system fields on guardrail failure
This commit is contained in:
parent
da3176cceb
commit
baa488a10a
2 changed files with 5 additions and 1 deletions
|
|
@ -2623,7 +2623,7 @@ def redact_proxy_server_request_body_on_guardrail_block(
|
|||
body: Final = proxy_server_request.get("body")
|
||||
if not isinstance(body, dict):
|
||||
return
|
||||
for field in ("messages", "prompt", "input"):
|
||||
for field in ("messages", "prompt", "input", "instructions", "system"):
|
||||
if field in body:
|
||||
body[field] = "[REDACTED - BLOCKED BY GUARDRAIL]"
|
||||
|
||||
|
|
|
|||
|
|
@ -1410,6 +1410,8 @@ def test_redact_proxy_server_request_body_on_guardrail_block():
|
|||
"model": "gpt-4",
|
||||
"messages": [{"role": "user", "content": "secret password is supersecret"}],
|
||||
"prompt": "supersecret prompt",
|
||||
"instructions": "supersecret instruction",
|
||||
"system": "supersecret system",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -1419,6 +1421,8 @@ def test_redact_proxy_server_request_body_on_guardrail_block():
|
|||
body = data["proxy_server_request"]["body"]
|
||||
assert body["messages"] == "[REDACTED - BLOCKED BY GUARDRAIL]"
|
||||
assert body["prompt"] == "[REDACTED - BLOCKED BY GUARDRAIL]"
|
||||
assert body["instructions"] == "[REDACTED - BLOCKED BY GUARDRAIL]"
|
||||
assert body["system"] == "[REDACTED - BLOCKED BY GUARDRAIL]"
|
||||
assert "supersecret" not in json.dumps(body)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue