This guide explains how to set up your configuration file for BetterRAG.
BetterRAG uses two configuration files:
config.template.yaml: A template with placeholder values that is tracked in version control.config.yaml: Your personal configuration file that contains actual API keys and settings. This file is ignored by Git to keep your credentials safe.
-
Copy the template file to create your personal configuration:
# For Linux/Mac cp config.template.yaml config.yaml # For Windows (Command Prompt) copy config.template.yaml config.yaml # For Windows (PowerShell) Copy-Item config.template.yaml config.yaml
-
Edit the
config.yamlfile to add your personal settings:- Add your API keys
- Configure database connection
- Adjust chunking parameters as needed
- Customize evaluation metrics
You can add API keys in two ways:
-
Direct value: Add your API key directly in the config file
azure_openai: api_key: "your-actual-api-key-here"
-
Environment variable: Reference an environment variable (recommended for security)
azure_openai: api_key: "${AZURE_OPENAI_API_KEY}"
Then set the environment variable in your terminal:
# For Linux/Mac export AZURE_OPENAI_API_KEY="your-api-key" # For Windows (Command Prompt) set AZURE_OPENAI_API_KEY=your-api-key # For Windows (PowerShell) $env:AZURE_OPENAI_API_KEY="your-api-key"
Configure your MongoDB connection:
database:
provider: "mongodb"
mongodb:
connection_string: "mongodb://localhost:27017/" # Default local MongoDB
database_name: "betterrag"
collection_name: "chunks"For a remote MongoDB instance, update the connection string with your credentials:
connection_string: "mongodb+srv://username:password@your-cluster.mongodb.net/"You can enable/disable chunking strategies and adjust their parameters:
chunking_strategies:
fixed_size:
enabled: true # Set to false to disable this strategy
chunk_size: 500 # Adjust as needed
chunk_overlap: 50 # Adjust as neededAfter setting up your configuration, run the application:
python -m app.main- Never commit your
config.yamlfile to version control. - Use environment variables for sensitive information whenever possible.
- If you modify the structure of the configuration, update the template file.
If the application cannot find your configuration:
- Verify that
config.yamlexists in the root directory of the project. - Check for syntax errors in your YAML file.
- Ensure all required fields are properly filled.