nemoguardrails.rails.llm.config
Module for the configuration of rails.
Module Contents
Classes
Functions
Data
API
Bases: BaseModel
Configuration data for the Cisco AI Defense API
Bases: BaseModel
Configuration of action rails.
Action rails control various options related to the execution of actions. Currently, only
In the future multiple options will be added, e.g., what input validation should be performed per action, output validation, throttling, disabling, etc.
Bases: BaseModel
List of guardrails that are activated
Bases: BaseModel
Configuration data for the AutoAlign API
Bases: BaseModel
Configuration for cache statistics tracking and logging.
Bases: BaseModel
Configuration data for the Clavata API
Bases: BaseModel
Configuration data for the Clavata API
Bases: BaseModel
Configuration data for content safety rails.
Bases: BaseModel
Settings for core internal mechanics.
Bases: BaseModel
Configuration data for the CrowdStrike AIDR API
Bases: BaseModel
Configuration of topical rails.
Bases: BaseModel
Configuration for documents that should be used for question answering.
Bases: BaseModel
Configuration of a embedding search provider.
Bases: BaseModel
Configuration for the caching embeddings.
Bases: BaseModel
Configuration data for the fact-checking rail.
Bases: BaseModel
Configuration for Fiddler Guardrails.
Bases: BaseModel
Configuration for GLiNER PII detection.
Bases: BaseModel
Configuration options for GLiNER.
Bases: BaseModel
Configuration data for Guardrails AI integration.
Get a specific validator configuration by name.
Bases: BaseModel
Configuration for a single Guardrails AI validator.
Bases: BaseModel
Bases: BaseModel
Configuration of input rails.
Bases: BaseModel
Configuration for instructions in natural language that should be passed to the LLM.
Bases: BaseModel
Configuration data for jailbreak detection.
Helper to return an API key (if it exists) from a Jailbreak configuration. This can come from (in descending order of priority):
- The
api_keyfield, a Pydantic SecretStr from which we extract the full string. - The
api_key_env_varfield, a string stored in this environment variable.
If neither is found, None is returned.
Migrate deprecated nim_url/nim_port fields to nim_base_url format.
Validate URL formats for endpoints.
Bases: BaseModel
Bases: _HFClassifierBase
Configuration for a local HuggingFace Transformers pipeline classifier.
Bases: BaseModel
Bases: BaseModel
Template for a message structure.
Bases: BaseModel
OpenTelemetry Metrics Configuration. Configures and enables Metrics independent of OTEL Traces.
Bases: BaseModel
Configuration of a model used by the rails engine.
Typically, the main model is configured e.g.: { “type”: “main”, “engine”: “openai”, “model”: “gpt-3.5-turbo-instruct” }
Validate that a model name is present either directly or in parameters.
Bases: BaseModel
Configuration for model caching.
Bases: BaseModel
Configuration for multilingual refusal messages.
Bases: BaseModel
Configuration of output rails.
Bases: BaseModel
Configuration for managing streaming output of LLM tokens.
Bases: BaseModel
Configuration data for the Pangea AI Guard API
Bases: BaseModel
Configuration data for the Pangea AI Guard API
Bases: BaseModel
Config to parameterize the Patronus Evaluate API call
Bases: BaseModel
Config for the Patronus Evaluate API call
Bases: enum.Enum
Strategy for determining whether a Patronus Evaluation API request should pass, especially when multiple evaluators are called in a single request. ALL_PASS requires all evaluators to pass for success. ANY_PASS requires only one evaluator to pass for success.
Bases: BaseModel
Configuration data for the Patronus Evaluate API
Bases: BaseModel
Configuration for Private AI.
Bases: BaseModel
Configuration options for Private AI.
Bases: BaseModel
Configuration of specific rails.
Bases: BaseModel
Configuration object for the models and the rails.
TODO: add typed config for user_messages, bot_messages, and flows.
Adds two RailsConfig objects.
Validate jailbreak detection configuration against enabled flows.
Make sure we have a model for each input rail where one is provided using $model=<model_type>
Make sure we have a model for each output rail where one is provided using $model=<model_type>
Loads a configuration from the provided colang/YAML content/config dict.
Loads a configuration from a given path.
Supports loading a from a single file, or from a directory.
Parses a configuration object from a given dictionary.
Model API Key Env var must be set to make LLM calls
Bases: BaseModel
Configuration data for specific rails that are supported out-of-the-box.
Bases: BaseModel
Configuration for reasoning mode in content safety models.
Bases: BaseModel
Configuration for regex pattern detection.
Bases: BaseModel
Configuration options for regex pattern detection on a specific source.
Return the pre-compiled regex patterns.
Pre-compile regex patterns at config load time.
Bases: _HFClassifierBase
Configuration for a remote HuggingFace classifier (vLLM, KServe, FMS).
Bases: BaseModel
Configuration of retrieval rails.
Bases: BaseModel
Configuration of what sensitive data should be detected.
Bases: BaseModel
Bases: BaseModel
Configuration for the single LLM call option for topical rails.
Bases: enum.Enum
Bases: BaseModel
Configuration for prompts that will be used for a specific task.
Bases: BaseModel
Configuration of tool input rails.
Tool input rails are applied to tool results before they are processed. They can validate, filter, or transform tool outputs for security and safety.
Bases: BaseModel
Configuration of tool output rails.
Tool output rails are applied to tool calls before they are executed. They can validate tool names, parameters, and context to ensure safe tool usage.
Bases: BaseModel
Bases: BaseModel
Configuration data for the Trend Micro AI Guard API
Helper to return an API key (if it exists) from a Trend Micro configuration.
The api_key_env_var field, a string stored in this environment variable.
If the environment variable is not found None is returned.
Bases: BaseModel
Configuration for how the user messages are interpreted.
Bases: BaseModel
Shared fields for all HuggingFace classifier engines.
Generates flow definitions from the list of flows. Args: flows (dict): The dictionary of flows. Returns: str: The flow definitions.
Helper to return a model name from a flow definition
Helper to return a model name from a flow definition
Extracts the list of flows from the raw_config dictionary.
Parameters:
The raw configuration dictionary.
Returns:
The list of flows.
Checks if the raw configuration has input/output rails configured.
Helper to join two configuration.
Joins two dictionaries recursively.
- If values are dictionaries, it applies _join_dict recursively.
- If values are lists, it concatenates them, ensuring unique elements.
- For other types, values from dict2 overwrite dict1.
Helper to join two rails configuration.
Load recursively all the imported path in the specified raw_config.
Parameters:
The starting raw configuration (i.e., a dict)
The current set of colang files which will be extended as new configurations are loaded.
Load a configuration object from the specified path.
Parameters:
The path from which to load.
Returns: Tuple[dict, List[Tuple[str, str]]]
(raw_config, colang_files) The raw config object and the list of colang files.
Helper function to parse all the Colang files.
If there are imports, they will be imported recursively
Concatenates two lists ensuring all elements are unique. Handles unhashable types like dictionaries.
Merges the fields of two dictionaries recursively.