Migrated all hardcoded configuration values from palefire-cli.py to a centralized configuration system in config.py. This improves maintainability, flexibility, and follows best practices for production applications.
- Purpose: Centralized configuration management
- Features:
- Loads all settings from environment variables
- Provides sensible defaults for all values
- Validates configuration on import
- Helper functions:
get_llm_config(),get_embedder_config(),print_config(),validate_config()
- Configuration Categories:
- Neo4j connection settings
- LLM provider configuration (Ollama/OpenAI)
- Embedder configuration
- Search parameters (method, limits, top-k)
- Ranking weights (connection, temporal, query match, entity type)
- NER settings
- Logging configuration
- Application settings
- Purpose: Template for environment variables
- Contents: All configurable settings with descriptions and defaults
- Usage:
cp env.example .envand customize
- Purpose: Comprehensive configuration documentation
- Contents:
- Complete list of all environment variables
- Configuration functions reference
- Setup instructions
- Best practices for production/development/research
- Troubleshooting guide
- Advanced configuration topics
- Purpose: Document this migration
- Contents: This file
Removed hardcoded values:
neo4j_uri = "bolt://10.147.18.253:7687"neo4j_user = "neo4j"neo4j_password = "password"openai_api_keychecksllm_confighardcoded parametersembedderhardcoded parametersnode_search_config.limit = 20node_search_config.limit = 5connection_weight=0.3default- Method default
'question-aware'
Added:
- Import of
configmodule - Use of
config.NEO4J_URI,config.NEO4J_USER,config.NEO4J_PASSWORD - Use of
config.get_llm_config()andconfig.get_embedder_config() - Use of
config.SEARCH_RESULT_LIMITandconfig.SEARCH_TOP_K - Use of
config.WEIGHT_CONNECTIONfor default weights - Use of
config.DEFAULT_SEARCH_METHOD - Use of
config.print_config()for config command - Configuration validation via
config.validate_config()
Function signature changes:
search_episodes_with_custom_ranking():connection_weight=0.3→connection_weight=None(usesconfig.WEIGHT_CONNECTIONif None)- CLI parser:
--methoddefault changed from'question-aware'toNone(usesconfig.DEFAULT_SEARCH_METHODif None)
Updated:
- Configuration section to reference
env.exampleandconfig.py - Added step to view configuration with
python palefire-cli.py config - Updated environment variable examples
- Added note about centralized configuration
Updated:
- Quick start section to include configuration viewing
- Configuration section with complete examples
- Added reference to
CONFIGURATION.md - Updated
.env.examplereferences toenv.example
NEO4J_URI(default:bolt://10.147.18.253:7687)NEO4J_USER(default:neo4j)NEO4J_PASSWORD(default:password)
LLM_PROVIDER(default:ollama)OPENAI_API_KEY(required)OLLAMA_BASE_URL(default:http://10.147.18.253:11434/v1)OLLAMA_MODEL(default:deepseek-r1:7b)OLLAMA_SMALL_MODEL(default:deepseek-r1:7b)OLLAMA_API_KEY(default:ollama)OPENAI_BASE_URL(default: None)OPENAI_MODEL(default:gpt-4)OPENAI_SMALL_MODEL(default:gpt-3.5-turbo)
EMBEDDER_PROVIDER(default:ollama)OLLAMA_EMBEDDING_MODEL(default:nomic-embed-text)OLLAMA_EMBEDDING_DIM(default:768)OLLAMA_EMBEDDING_BASE_URL(default:http://10.147.18.253:11434/v1)OPENAI_EMBEDDING_MODEL(default:text-embedding-ada-002)OPENAI_EMBEDDING_DIM(default:1536)
DEFAULT_SEARCH_METHOD(default:question-aware)SEARCH_RESULT_LIMIT(default:20)SEARCH_TOP_K(default:5)
WEIGHT_CONNECTION(default:0.15)WEIGHT_TEMPORAL(default:0.20)WEIGHT_QUERY_MATCH(default:0.20)WEIGHT_ENTITY_TYPE(default:0.15)- Semantic weight: calculated as
1.0 - sum(other weights)=0.30
NER_ENABLED(default:true)NER_USE_SPACY(default:true)SPACY_MODEL(default:en_core_web_sm)
LOG_LEVEL(default:INFO)LOG_FORMAT(default:%(asctime)s - %(name)s - %(levelname)s - %(message)s)LOG_DATE_FORMAT(default:%Y-%m-%d %H:%M:%S)
EPISODE_NAME_PREFIX(default:Episode)USE_CURRENT_TIME(default:true)
- All configuration in one place
- Easy to find and modify settings
- Clear separation of code and configuration
- Environment-specific configurations (dev/prod/test)
- Override any setting via environment variables
- No code changes needed for deployment
- Automatic validation on startup
- Clear error messages for missing/invalid settings
- Prevents runtime errors due to misconfiguration
- Self-documenting via
config.pycomments - Comprehensive
CONFIGURATION.mdguide - Example file (
env.example) with all options
- Follows 12-factor app methodology
- Secrets not hardcoded in source
- Easy to integrate with deployment tools
-
Copy example configuration:
cd /path/to/palefire cp env.example .env -
Update
.envwith your settings:nano .env # or your preferred editor -
Verify configuration:
python palefire-cli.py config
-
Test with a query:
python palefire-cli.py query "Test question?"
Just follow the Quick Start in README.md - the configuration system is already integrated.
- None for users who set environment variables via
.envfile - Hardcoded values in
palefire-cli.pyare removed, but defaults inconfig.pymatch the previous hardcoded values
- All default values match previous hardcoded values
- CLI interface unchanged
- Function signatures backward compatible (optional parameters)
-
✅ Configuration loads correctly
python3 -c "import config; config.print_config()" -
✅ Files compile without errors
python3 -m py_compile palefire-cli.py config.py
-
✅ CLI help works
python palefire-cli.py --help
-
✅ Config command works
python palefire-cli.py config
All tests passed successfully:
- Configuration module loads and validates
- All files compile without syntax errors
- CLI commands work as expected
- Configuration display shows correct values
-
Configuration Profiles
- Support for named profiles (dev, prod, test)
- Switch between profiles via CLI flag
-
Runtime Configuration
- CLI flags to override config values
- Example:
--search-limit 50 --top-k 10
-
Configuration Validation
- More sophisticated validation rules
- Warnings for suboptimal settings
-
Configuration Export
- Export current config to file
- Share configurations between environments
-
Configuration UI
- Interactive configuration wizard
- Web-based configuration editor
- Configuration Guide: CONFIGURATION.md
- CLI Guide: CLI_GUIDE.md
- Setup Guide: PALEFIRE_SETUP.md
- Main README: README.md
Migration performed on December 26, 2025, as part of the Pale Fire project modernization effort.
For issues related to configuration:
- Check CONFIGURATION.md for detailed documentation
- Verify
.envfile exists and has correct values - Run
python palefire-cli.py configto see current settings - Check logs for configuration validation errors
Configuration System v1.0 - Centralized, Validated, Documented 🎯