mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-24 18:24:20 +00:00
fix(utils.py): fix rules calling
This commit is contained in:
parent
b2e52eedf8
commit
ab2986290e
2 changed files with 3 additions and 4 deletions
|
@ -8,6 +8,7 @@ sys.path.insert(
|
|||
0, os.path.abspath("../..")
|
||||
) # Adds the parent directory to the system path
|
||||
import pytest
|
||||
import litellm
|
||||
from litellm import completion
|
||||
|
||||
messages=[{"role": "user", "content": "Hey, how's it going?"}]
|
||||
|
|
|
@ -1077,21 +1077,19 @@ class Rules:
|
|||
pass
|
||||
|
||||
def pre_call_rules(self, input: str, model: str):
|
||||
model, custom_llm_provider, _, _ = get_llm_provider(model=model)
|
||||
for rule in litellm.pre_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=custom_llm_provider, model=model) # type: ignore
|
||||
raise litellm.APIResponseValidationError(message="LLM Response failed post-call-rule check", llm_provider="", model=model) # type: ignore
|
||||
return True
|
||||
|
||||
def post_call_rules(self, input: str, model: str):
|
||||
model, custom_llm_provider, _, _ = get_llm_provider(model=model)
|
||||
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=custom_llm_provider, model=model) # type: ignore
|
||||
raise litellm.APIResponseValidationError(message="LLM Response failed post-call-rule check", llm_provider="", model=model) # type: ignore
|
||||
return True
|
||||
|
||||
####### CLIENT ###################
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue