mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-06 08:16:43 +00:00
add noma guardrail provider to ui (#14415)
* add noma guardrail provider to ui * resolved linting issues * fix return value
This commit is contained in:
parent
0e8f60fe67
commit
fb9e2c93a0
2 changed files with 36 additions and 1 deletions
|
|
@ -8,7 +8,7 @@
|
|||
import asyncio
|
||||
import copy
|
||||
import os
|
||||
from typing import Any, Dict, Final, Literal, Optional, Union
|
||||
from typing import Any, Dict, Final, Literal, Optional, Union, Type, TYPE_CHECKING
|
||||
from urllib.parse import urljoin
|
||||
|
||||
from fastapi import HTTPException
|
||||
|
|
@ -34,7 +34,10 @@ SENSITIVE_DATA_DETECTOR_KEYS: Final[list[str]] = ["sensitiveData", "dataDetector
|
|||
MessageRole = Literal["user", "assistant"]
|
||||
LLMResponse = Union[Any, ModelResponse, EmbeddingResponse, ImageResponse]
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from litellm.types.proxy.guardrails.guardrail_hooks.base import GuardrailConfigModel
|
||||
|
||||
|
||||
class NomaBlockedMessage(HTTPException):
|
||||
"""Exception raised when Noma guardrail blocks a message"""
|
||||
|
||||
|
|
@ -730,3 +733,12 @@ class NomaGuardrail(CustomGuardrail):
|
|||
verbose_proxy_logger.info(msg)
|
||||
else:
|
||||
verbose_proxy_logger.debug(msg)
|
||||
|
||||
@staticmethod
|
||||
def get_config_model() -> Optional[Type["GuardrailConfigModel"]]:
|
||||
from litellm.types.proxy.guardrails.guardrail_hooks.noma import (
|
||||
NomaGuardrailConfigModel,
|
||||
)
|
||||
|
||||
return NomaGuardrailConfigModel
|
||||
|
||||
|
|
|
|||
23
litellm/types/proxy/guardrails/guardrail_hooks/noma.py
Normal file
23
litellm/types/proxy/guardrails/guardrail_hooks/noma.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from .base import GuardrailConfigModel
|
||||
|
||||
class NomaGuardrailConfigModel(GuardrailConfigModel):
|
||||
api_key: Optional[str] = Field(
|
||||
default=None,
|
||||
description="The Noma API key. Reads from NOMA_API_KEY env var if None.",
|
||||
)
|
||||
api_base: Optional[str] = Field(
|
||||
default=None,
|
||||
description="The Noma API base URL. Defaults to https://api.noma.security. Also checks if the NOMA_API_KEY env var is set.",
|
||||
)
|
||||
application_id: Optional[str] = Field(
|
||||
default=None,
|
||||
description="The Noma Application ID. Reads from NOMA_APPLICATION_ID env var if None.",
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def ui_friendly_name() -> str:
|
||||
return "Noma Security"
|
||||
Loading…
Add table
Reference in a new issue