Custom Initialization#
The config.py file contains initialization code that runs once at startup, before the LLMRails instance is fully initialized. Use it to register custom providers and set up shared resources.
When to Use config.py vs actions.py#
Use Case |
File |
Reason |
|---|---|---|
Register custom LLM provider |
|
Must happen before LLMRails initialization |
Register custom embedding provider |
|
Must happen before LLMRails initialization |
Initialize database connection |
|
Shared resource, initialized once |
Validate user input |
|
Called during request processing |
Call external API |
|
Called during request processing |
Custom guardrail logic |
|
Called from Colang flows |
Configuration Sections#
Define the init() function to initialize resources and register action parameters at startup.
Register custom text completion (BaseLLM) and chat models (BaseChatModel) for use with NeMo Guardrails.
Register custom embedding providers for vector similarity search in NeMo Guardrails.
Pass and access custom data from config.yml in your initialization code and actions.