Guardrails_configuration

This module contains functionality related to the the guardrails_configuration module for augmentation.bootstrap.configuration.components.

Guardrails_configuration

GuardrailsConfiguration

Bases: BaseConfiguration

Configuration settings for guardrails.

This class defines the necessary parameters for configuring and interacting with guardrails used in the system.

Source code in src/augmentation/bootstrap/configuration/components/guardrails_configuration.py
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
class GuardrailsConfiguration(BaseConfiguration):
    """
    Configuration settings for guardrails.

    This class defines the necessary parameters for configuring
    and interacting with guardrails used in the system.
    """

    llm: Any = Field(
        ..., description="The llm configuration for the guardrails."
    )
    input_prompt_name: str = Field(
        "default_input_guardrail_prompt",
        description=(
            "The name of the input guardrail prompt to use available in Langfuse prompts.",
            "The prompt is used to determine if the input is valid to be passed to the chat engine.",
            "The LLM should respond with 'yes' or 'true' if the input should be blocked.",
        ),
    )
    output_prompt_name: str = Field(
        "default_output_guardrail_prompt",
        description=(
            "The name of the output guardrail prompt to use available in Langfuse prompts.",
            "The prompt is used to determine if the output of the chat engine is valid to be returned to the user.",
            "The LLM should respond with 'yes' or 'true' if the output should be blocked.",
        ),
    )

    @field_validator("llm")
    @classmethod
    def _validate_llm(cls, value: Any, info: ValidationInfo) -> Any:
        """Validate llm configuration against registered llm types.

        Args:
            value: The llm configuration to validate
            info: Validation context information

        Returns:
            Validated llm configuration
        """
        return super()._validate(
            value,
            info=info,
            registry=LLMConfigurationRegistry,
        )

GuardrailsName

Bases: str, Enum

Enumeration of supported guardrails.

Source code in src/augmentation/bootstrap/configuration/components/guardrails_configuration.py
13
14
15
16
17
18
class GuardrailsName(str, Enum):
    """
    Enumeration of supported guardrails.
    """

    BASIC = "basic"

GurdrailsConfigurationRegistry

Bases: ConfigurationRegistry

Registry for guardrails configurations.

This registry maintains a mapping between guardrails names and their corresponding configuration classes, allowing the system to dynamically select and instantiate the appropriate configuration based on the provider name.

Attributes:
  • _key_class (Type) –

    The enumeration class for guardrails names.

Source code in src/augmentation/bootstrap/configuration/components/guardrails_configuration.py
68
69
70
71
72
73
74
75
76
77
78
79
80
81
class GurdrailsConfigurationRegistry(ConfigurationRegistry):
    """
    Registry for guardrails configurations.

    This registry maintains a mapping between guardrails names and
    their corresponding configuration classes, allowing the system to
    dynamically select and instantiate the appropriate configuration
    based on the provider name.

    Attributes:
        _key_class: The enumeration class for guardrails names.
    """

    _key_class: Type = GuardrailsName