nemoguardrails.rails.llm.config
Module for the configuration of rails.
Module Contents
Classes
Functions
Data
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
Configuration for cache statistics tracking and logging.
Bases: BaseModel
Settings for core internal mechanics.
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 of input rails.
Bases: BaseModel
Configuration for instructions in natural language that should be passed to the LLM.
Bases: BaseModel
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 of output rails.
Bases: BaseModel
Configuration for managing streaming output of LLM tokens.
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>
Reject configs whose output rails transform response with stream_first == True
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: _RailsConfigDataBase
Bases: BaseModel
Configuration of retrieval rails.
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 for how the user messages are interpreted.
Bases: BaseModel
Configuration data for specific rails that are supported out-of-the-box.
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.
Ensure every enabled self-check rail has a prompt for its resolved task.
A self-check rail may select a custom task via $variant=...; the task falls
back to default_task when omitted. Custom prompts are scoped under the
default task name.
Merges the fields of two dictionaries recursively.