mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 03:04:13 +00:00
(feat) Support Dynamic Params for guardrails
(#7415)
* update CustomGuardrail * unit test custom guardrails * add dynamic params for aporia * add dynamic params to bedrock guard * add dynamic params for all guardrails * fix linting * fix should_run_guardrail * _validate_premium_user * update guardrail doc * doc update * update code q * should_run_guardrail
This commit is contained in:
parent
77fa751639
commit
0ce5f9fe58
10 changed files with 411 additions and 21 deletions
|
@ -216,14 +216,27 @@ class lakeraAI_Moderation(CustomGuardrail):
|
|||
"Skipping lakera prompt injection, no roles with messages found"
|
||||
)
|
||||
return
|
||||
data = {"input": lakera_input}
|
||||
_json_data = json.dumps(data)
|
||||
_data = {"input": lakera_input}
|
||||
_json_data = json.dumps(
|
||||
_data,
|
||||
**self.get_guardrail_dynamic_request_body_params(request_data=data),
|
||||
)
|
||||
elif "input" in data and isinstance(data["input"], str):
|
||||
text = data["input"]
|
||||
_json_data = json.dumps({"input": text})
|
||||
_json_data = json.dumps(
|
||||
{
|
||||
"input": text,
|
||||
**self.get_guardrail_dynamic_request_body_params(request_data=data),
|
||||
}
|
||||
)
|
||||
elif "input" in data and isinstance(data["input"], list):
|
||||
text = "\n".join(data["input"])
|
||||
_json_data = json.dumps({"input": text})
|
||||
_json_data = json.dumps(
|
||||
{
|
||||
"input": text,
|
||||
**self.get_guardrail_dynamic_request_body_params(request_data=data),
|
||||
}
|
||||
)
|
||||
|
||||
verbose_proxy_logger.debug("Lakera AI Request Args %s", _json_data)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue