Configuring Custom Initialization

View as Markdown

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 or actions.py

Use CaseFileReason
Register custom LLM providerconfig.pyMust happen before LLMRails initialization
Register custom embedding providerconfig.pyMust happen before LLMRails initialization
Initialize database connectionconfig.pyShared resource, initialized once
Validate user inputactions.pyCalled during request processing
Call external APIactions.pyCalled during request processing
Custom guardrail logicactions.pyCalled from Colang flows

Configuration Sections