mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 03:04:13 +00:00
(feat) post call rules - fail with error message
This commit is contained in:
parent
4e6a238820
commit
e864c78d15
1 changed files with 8 additions and 3 deletions
|
@ -1761,9 +1761,14 @@ class Rules:
|
|||
for rule in litellm.post_call_rules:
|
||||
if callable(rule):
|
||||
decision = rule(input)
|
||||
if decision is False:
|
||||
raise litellm.APIResponseValidationError(message="LLM Response failed post-call-rule check", llm_provider="", model=model) # type: ignore
|
||||
return True
|
||||
if type(decision) == bool:
|
||||
if decision is False:
|
||||
raise litellm.APIResponseValidationError(message="LLM Response failed post-call-rule check", llm_provider="", model=model) # type: ignore
|
||||
return True
|
||||
elif type(decision) == dict:
|
||||
decision, message = decision["decision"], decision["message"]
|
||||
if decision is False:
|
||||
raise litellm.APIResponseValidationError(message=message, llm_provider="", model=model) # type: ignore
|
||||
|
||||
|
||||
####### CLIENT ###################
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue