mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-07 02:59:05 +00:00
fix(guardrails): report Airia supported modes to the dashboard
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
eb9c5b6010
commit
d006b093a6
2 changed files with 11 additions and 0 deletions
|
|
@ -41,6 +41,10 @@ SUPPORTED_EVENT_HOOKS: Final = (GuardrailEventHooks.pre_call, GuardrailEventHook
|
||||||
class AiriaGuardrail(CustomGuardrail):
|
class AiriaGuardrail(CustomGuardrail):
|
||||||
"""Evaluates prompts and responses against your Airia guardrail policy."""
|
"""Evaluates prompts and responses against your Airia guardrail policy."""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_supported_event_hooks(cls) -> list[GuardrailEventHooks]:
|
||||||
|
return [*SUPPORTED_EVENT_HOOKS]
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
api_base: str | None = None,
|
api_base: str | None = None,
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,13 @@ def test_during_call_is_not_a_supported_event_hook() -> None:
|
||||||
assert list(hooks) == [GuardrailEventHooks.pre_call, GuardrailEventHooks.post_call]
|
assert list(hooks) == [GuardrailEventHooks.pre_call, GuardrailEventHooks.post_call]
|
||||||
|
|
||||||
|
|
||||||
|
def test_supported_event_hooks_are_exposed_for_ui() -> None:
|
||||||
|
assert AiriaGuardrail.get_supported_event_hooks() == [
|
||||||
|
GuardrailEventHooks.pre_call,
|
||||||
|
GuardrailEventHooks.post_call,
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("missing", ["api_base", "api_key"])
|
@pytest.mark.parametrize("missing", ["api_base", "api_key"])
|
||||||
def test_missing_credentials_raise_at_construction(missing: str, monkeypatch: pytest.MonkeyPatch) -> None:
|
def test_missing_credentials_raise_at_construction(missing: str, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||||
"""Fail at startup rather than on the first request."""
|
"""Fail at startup rather than on the first request."""
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue