mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-06 02:48:13 +00:00
chore(guardrails): remove unrelated test churn
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
8d2355392a
commit
c63fd3bd29
3 changed files with 13 additions and 7 deletions
|
|
@ -440,8 +440,8 @@ def _as_callback_tuple(
|
|||
def _configure_callback_scoping(
|
||||
custom_guardrail_callback: CustomGuardrail, guardrail_name: str, litellm_params: LitellmParams
|
||||
) -> None:
|
||||
custom_guardrail_callback.logging_only_scope = litellm_params.logging_only_scope
|
||||
logging_only_scope: Final = litellm_params.logging_only_scope
|
||||
custom_guardrail_callback.logging_only_scope = logging_only_scope
|
||||
if logging_only_scope is not None and GuardrailEventHooks.logging_only.value not in _configured_event_hooks(
|
||||
litellm_params.mode
|
||||
):
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ from pydantic import ValidationError
|
|||
|
||||
from litellm.integrations.custom_guardrail import CustomGuardrail
|
||||
from litellm.proxy.guardrails.guardrail_registry import (
|
||||
get_guardrail_initializer_from_hooks,
|
||||
GuardrailRegistry,
|
||||
InMemoryGuardrailHandler,
|
||||
get_guardrail_initializer_from_hooks,
|
||||
)
|
||||
from litellm.types.guardrails import Guardrail, GuardrailEventHooks, LitellmParams, LoggingOnlyScope, Mode
|
||||
from litellm.types.guardrails import GuardrailEventHooks, Guardrail, LitellmParams, LoggingOnlyScope, Mode
|
||||
from litellm.types.utils import GenericGuardrailAPIInputs
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -546,10 +546,14 @@ class TestApplyGuardrailCheck:
|
|||
class ParentGuardrail(CustomGuardrail):
|
||||
"""Parent that inherits apply_guardrail from CustomGuardrail"""
|
||||
|
||||
pass
|
||||
|
||||
# Child class that only inherits apply_guardrail (doesn't override)
|
||||
class ChildGuardrailWithoutOverride(ParentGuardrail):
|
||||
"""Child that only inherits apply_guardrail"""
|
||||
|
||||
pass
|
||||
|
||||
# Child class that overrides apply_guardrail
|
||||
class ChildGuardrailWithOverride(ParentGuardrail):
|
||||
"""Child that overrides apply_guardrail"""
|
||||
|
|
@ -2536,7 +2540,7 @@ class TestLoggingOnlyApplyGuardrail:
|
|||
from litellm.proxy.guardrails.guardrail_hooks.litellm_content_filter.content_filter import (
|
||||
ContentFilterGuardrail,
|
||||
)
|
||||
from litellm.types.guardrails import BlockedWord, ContentFilterAction
|
||||
from litellm.types.guardrails import BlockedWord, ContentFilterAction, GuardrailEventHooks
|
||||
|
||||
guardrail: Final = ContentFilterGuardrail(
|
||||
guardrail_name="content-review",
|
||||
|
|
@ -2628,7 +2632,7 @@ class TestLoggingOnlyApplyGuardrail:
|
|||
|
||||
@pytest.mark.asyncio
|
||||
async def test_block_verdict_is_recorded_without_raising(self):
|
||||
guardrail: Final = _ApplyOnlyObserver(block=True)
|
||||
guardrail = _ApplyOnlyObserver(block=True)
|
||||
kwargs, response = _logged_call([{"role": "user", "content": "flagged content"}])
|
||||
|
||||
out_kwargs, _ = await guardrail.async_logging_hook(kwargs, response, CallTypes.acompletion.value)
|
||||
|
|
@ -2637,7 +2641,7 @@ class TestLoggingOnlyApplyGuardrail:
|
|||
("request", ["flagged content"]),
|
||||
("response", ["general kenobi"]),
|
||||
]
|
||||
entries: Final = out_kwargs["standard_logging_object"]["guardrail_information"]
|
||||
entries = out_kwargs["standard_logging_object"]["guardrail_information"]
|
||||
assert [entry["guardrail_status"] for entry in entries] == ["guardrail_intervened", "guardrail_intervened"]
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
@ -2964,7 +2968,9 @@ async def test_native_lifecycle_guardrail_logging_only_scans_assembled_response(
|
|||
from litellm.types.utils import Choices, Message, ModelResponse
|
||||
|
||||
guardrail = _NativeLifecycleLoggingGuardrail()
|
||||
assembled = ModelResponse(choices=[Choices(message=Message(role="assistant", content="assembled stream text"))])
|
||||
assembled = ModelResponse(
|
||||
choices=[Choices(message=Message(role="assistant", content="assembled stream text"))]
|
||||
)
|
||||
sentinel_result = object()
|
||||
kwargs = {
|
||||
"model": "gpt-5.4-mini",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue