mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-11 22:51:28 +00:00
Merge 42b97bc0a5 into 49affa7c01
This commit is contained in:
commit
b534e9c3b2
2 changed files with 34 additions and 0 deletions
|
|
@ -108,6 +108,20 @@ class GenericGuardrailAPIConfigModel(
|
|||
):
|
||||
"""Configuration parameters for the Generic Guardrail API guardrail"""
|
||||
|
||||
api_base: str | None = Field(
|
||||
default=None,
|
||||
description=(
|
||||
"Base URL of the guardrail service implementing the LiteLLM Basic Guardrail API spec; "
|
||||
"LiteLLM appends /beta/litellm_basic_guardrail_api to it. Falls back to the "
|
||||
"GENERIC_GUARDRAIL_API_BASE environment variable, and initialization fails when neither is set."
|
||||
),
|
||||
)
|
||||
|
||||
api_key: str | None = Field(
|
||||
default=None,
|
||||
description="API key for the guardrail service, sent as the x-api-key header.",
|
||||
)
|
||||
|
||||
optional_params: GenericGuardrailAPIOptionalParams | None = Field(
|
||||
default_factory=GenericGuardrailAPIOptionalParams,
|
||||
description="Optional parameters for the Generic Guardrail API guardrail",
|
||||
|
|
|
|||
|
|
@ -1150,6 +1150,26 @@ class TestGenericGuardrailAPIStreamingConfig:
|
|||
|
||||
assert GenericGuardrailAPI.get_config_model() is GenericGuardrailAPIConfigModel
|
||||
|
||||
def test_config_model_exposes_api_base_and_api_key(self):
|
||||
from litellm.types.proxy.guardrails.guardrail_hooks.generic_guardrail_api import (
|
||||
GenericGuardrailAPIConfigModel,
|
||||
)
|
||||
|
||||
assert set(GenericGuardrailAPIConfigModel.model_fields) >= {"api_base", "api_key"}
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_ui_provider_specific_params_expose_connection_fields(self):
|
||||
from litellm.proxy.guardrails.guardrail_endpoints import (
|
||||
get_provider_specific_params,
|
||||
)
|
||||
|
||||
provider_params = await get_provider_specific_params()
|
||||
generic_params = provider_params["generic_guardrail_api"]
|
||||
|
||||
assert generic_params["api_base"]["type"] == "string"
|
||||
assert generic_params["api_key"]["type"] == "string"
|
||||
assert generic_params["optional_params"]["type"] == "nested"
|
||||
|
||||
def test_streaming_transform_mode_defaults_block_only(self):
|
||||
guardrail = GenericGuardrailAPI(
|
||||
api_base="https://api.test.guardrail.com",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue