Implementation:Infiniflow Ragflow Config Utils
| Knowledge Sources | |
|---|---|
| Domains | Configuration, Infrastructure |
| Last Updated | 2026-02-12 06:00 GMT |
Overview
Concrete tool for centralized YAML-based configuration loading, reading, writing, and password decryption provided by the RAGFlow common library.
Description
The config_utils module provides a complete configuration management system. It loads YAML configuration files, merges local overrides with global settings, masks sensitive values for logging, decrypts database passwords using CryptoUtil, and supports atomic configuration updates with file locking.
Usage
Import these utilities when accessing application configuration values such as database credentials, service endpoints, or LLM provider settings. The primary entry points are read_config for initial loading and get_base_config for accessing specific keys.
Code Reference
Source Location
- Repository: Infiniflow_Ragflow
- File: common/config_utils.py
- Lines: 1-156
Signature
def load_yaml_conf(conf_path: str) -> dict:
"""Load a YAML configuration file and return as dictionary."""
def read_config(conf_name: str = SERVICE_CONF) -> dict:
"""Read merged local + global configuration."""
def get_base_config(key: str, default=None):
"""Get a specific configuration value by key."""
def decrypt_database_password(password: str) -> str:
"""Decrypt an encrypted database password."""
def update_config(key: str, value, conf_name: str = SERVICE_CONF) -> None:
"""Update a configuration key with file locking."""
Import
from common.config_utils import read_config, get_base_config, CONFIGS
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| conf_path | str | Yes | Path to YAML configuration file |
| key | str | Yes | Configuration key to retrieve |
| default | any | No | Default value if key not found |
Outputs
| Name | Type | Description |
|---|---|---|
| read_config() returns | dict | Merged configuration dictionary |
| get_base_config() returns | any | Configuration value for specified key |
| CONFIGS | dict | Global configuration cache |
Usage Examples
from common.config_utils import get_base_config, read_config
# Read full configuration
config = read_config()
# Get specific setting
db_config = get_base_config("database", default={})
es_host = get_base_config("es", {}).get("host", "localhost")