mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +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("../..")
|
0, os.path.abspath("../..")
|
||||||
) # Adds the parent directory to the system path
|
) # Adds the parent directory to the system path
|
||||||
import pytest
|
import pytest
|
||||||
|
import litellm
|
||||||
from litellm import completion
|
from litellm import completion
|
||||||
|
|
||||||
messages=[{"role": "user", "content": "Hey, how's it going?"}]
|
messages=[{"role": "user", "content": "Hey, how's it going?"}]
|
||||||
|
|
|
@ -1077,21 +1077,19 @@ class Rules:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def pre_call_rules(self, input: str, model: str):
|
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:
|
for rule in litellm.pre_call_rules:
|
||||||
if callable(rule):
|
if callable(rule):
|
||||||
decision = rule(input)
|
decision = rule(input)
|
||||||
if decision is False:
|
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
|
return True
|
||||||
|
|
||||||
def post_call_rules(self, input: str, model: str):
|
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:
|
for rule in litellm.post_call_rules:
|
||||||
if callable(rule):
|
if callable(rule):
|
||||||
decision = rule(input)
|
decision = rule(input)
|
||||||
if decision is False:
|
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
|
return True
|
||||||
|
|
||||||
####### CLIENT ###################
|
####### CLIENT ###################
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue