Configuration Overview#
Before using the NeMo Guardrails toolkit, you need to prepare configuration files that define your guardrails behavior. When you initialize the toolkit’s core classes or the nemoguardrails CLI chat or server, it will load the configuration files you’ll create in the next chapter Run Rails. This section provides complete instructions on preparing your configuration files and executable scripts.
A guardrails configuration includes the following components. You can start with a basic configuration and add more components as needed. All the components should be placed in the config folder, and the locations in the following table are relative to the config folder.
Component |
Required/Optional |
Description |
Location |
|---|---|---|---|
Core Configuration |
Required |
A |
|
Colang Flows |
Optional |
A collection of Colang files ( |
|
Custom Actions |
Optional |
Python functions decorated with |
|
Custom Initialization |
Optional |
Python code that runs once at startup to register custom LLM providers, embedding providers, or shared resources (for example, database connections). |
|
Knowledge Base Documents |
Optional |
Documents ( |
|
Example Configuration Folder Structures#
The following are example configuration folder structures.
Basic configuration
config/ └── config.yml
Configuration with Colang rails and custom actions
config/ ├── config.yml ├── rails/ │ ├── input.co │ ├── output.co │ └── ... └── actions.py # Custom actions called from Colang flows
Configuration with custom LLM provider registration
config/ ├── config.yml ├── rails/ │ └── ... ├── actions.py # Custom actions └── config.py # Registers custom LLM provider at startup
Complete configuration with all components
config/ ├── config.yml # Core configuration ├── config.py # Custom initialization (LLM providers, etc.) ├── rails/ # Colang flow files │ ├── input.co │ ├── output.co │ └── ... ├── actions/ # Custom actions (as a package) │ ├── __init__.py │ ├── validation.py │ ├── external_api.py │ └── ... └── kb/ # Knowledge base documents ├── policies.md ├── faq.md └── ...
Next Steps#
For each component, refer to the following sections for more details:
Core Configuration - A complete guide to writing your
config.ymlfile.Colang Rails -
.coflow files.Custom Actions -
actions.pyfor callable actions.Custom Initialization -
config.pyfor provider registration.Knowledge Base Documents -
kb/folder for RAG.
After preparing your configuration files, use the NeMo Guardrails SDK to instantiate the core classes (RailsConfig and LLMRails) and run guardrails on your LLM applications.
For detailed SDK usage, including loading configurations, generating responses, streaming, and debugging, refer to Run Rails.