mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-21 00:21:49 +00:00
fix(llmguard): drop call types the proxy never routes through moderation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
012d82d85d
commit
c38dda2b2f
2 changed files with 18 additions and 10 deletions
|
|
@ -147,11 +147,6 @@ class _ENTERPRISE_LLMGuard(CustomLogger):
|
|||
"aembedding",
|
||||
"image_generation",
|
||||
"aimage_generation",
|
||||
"moderation",
|
||||
"amoderation",
|
||||
"audio_transcription",
|
||||
"transcription",
|
||||
"atranscription",
|
||||
)
|
||||
if call_type not in accepted_call_types:
|
||||
self.print_verbose(
|
||||
|
|
|
|||
|
|
@ -20,13 +20,8 @@ from litellm.types.utils import CallTypesLiteral
|
|||
("embeddings", "input"),
|
||||
("embedding", "input"),
|
||||
("aembedding", "input"),
|
||||
("moderation", "input"),
|
||||
("amoderation", "input"),
|
||||
("image_generation", "prompt"),
|
||||
("aimage_generation", "prompt"),
|
||||
("audio_transcription", "prompt"),
|
||||
("transcription", "prompt"),
|
||||
("atranscription", "prompt"),
|
||||
),
|
||||
)
|
||||
@pytest.mark.parametrize("is_valid", (True, False))
|
||||
|
|
@ -68,6 +63,24 @@ async def test_llm_guard_call_type_aliases(
|
|||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("call_type", ("amoderation", "atranscription", "aresponses", "aanthropic_messages"))
|
||||
@pytest.mark.asyncio
|
||||
async def test_llm_guard_ignores_call_types_the_proxy_never_moderates(
|
||||
call_type: CallTypesLiteral, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
monkeypatch.setattr(litellm, "llm_guard_mode", "all")
|
||||
llm_guard: Final = _ENTERPRISE_LLMGuard(
|
||||
mock_testing=True,
|
||||
mock_redacted_text={"sanitized_prompt": "[REDACTED]", "is_valid": False},
|
||||
)
|
||||
data: Final = {"input": "email: person@example.com"}
|
||||
result: Final = await llm_guard.async_moderation_hook(
|
||||
data=data, user_api_key_dict=UserAPIKeyAuth(), call_type=call_type
|
||||
)
|
||||
assert result is data
|
||||
assert data["input"] == "email: person@example.com"
|
||||
|
||||
|
||||
@pytest.mark.parametrize("call_type", ("text_completion", "atext_completion"))
|
||||
@pytest.mark.parametrize("is_valid", (True, False))
|
||||
@pytest.mark.asyncio
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue