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
The tool policy nemoguardrails hooks-server applies to each hook’s call; no engine reads it.
Whether the policy can deny a call: it blocks something, denies unlisted tools, or limits a tool’s arguments.
Refuse tool lists that name a tool twice, or that allow a tool they block by name.
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-4o-mini” }
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>
Make sure we have every model a tool rail’s manifest binds, such as the judge named by $model=
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 call rails.
Tool call 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
A tool in hooks_server.allowed_tools or blocked_tools, named with the arguments its entry is about.
Refuse an entry that names an argument twice.
Bases: BaseModel
Configuration of tool result rails.
Tool result rails are applied to tool results before they are processed. They can validate, filter, or transform tool results for security and safety.
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.
A configured tool rail flow, with its section, its direction and, for a per-tool flow, its tool.
Yield the model types surface binds for a flow’s params: baked-in literals and model $params it sets.
The first tool tool_list names a second time, or None when it names each tool once.
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; source names where additional_config was read from, for errors.
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
The tool a list entry names.
Yield each tool rail flow, global flows before per-tool ones.
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.
Compare with validated values to follow the selected union and preserve open dictionaries.
Merges the fields of two dictionaries recursively.