mirror of
https://github.com/invariantlabs-ai/invariant-gateway.git
synced 2026-08-09 02:26:06 +02:00
* guardrails from header * use in-file guardrails in client.py * support case without request * remove client script * tests: guardrailing rule passed in header * include checked guardrails in annotation extra metadata * include guardrailing action * update guardrail metadata
32 lines
617 B
Python
32 lines
617 B
Python
"""Common guardrails data class."""
|
|
|
|
from enum import Enum
|
|
from typing import List
|
|
|
|
from dataclasses import dataclass
|
|
|
|
|
|
class GuardrailAction(str, Enum):
|
|
"""Enum representing the action to be taken for guardrail rules."""
|
|
|
|
BLOCK = "block"
|
|
LOG = "log"
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class Guardrail:
|
|
"""Represents a single guardrail rule."""
|
|
|
|
id: str
|
|
name: str
|
|
content: str
|
|
action: GuardrailAction
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class GuardrailRuleSet:
|
|
"""Grouped guardrail rules separated by their action."""
|
|
|
|
blocking_guardrails: List[Guardrail]
|
|
logging_guardrails: List[Guardrail]
|