Files
Luca Beurer-KellnerandGitHub e17b53b927 Extract guardrails from header if provided (#33)
* 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
2025-04-03 08:56:15 +02:00

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]