Configuration Overview#
Before using the NeMo Guardrails toolkit, you need to prepare configuration files that define your guardrails behavior. 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 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 -
config.ymlreferenceColang Rails -
.coflow filesCustom Actions -
actions.pyfor callable actionsCustom Initialization -
config.pyfor provider registrationKnowledge 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.
Complete reference for config.yml structure including models, guardrails, prompts, and tracing settings.
Learn Colang, the event-driven language for defining guardrails flows, user messages, and bot responses.
Define custom Python actions in actions.py to extend guardrails with external integrations and validation logic.
Use config.py to register custom LLM providers, embedding providers, and shared resources at startup.
Additional configuration topics including knowledge base setup and exception handling.