5.9 KiB
5.9 KiB
Prompts Changelog
All notable changes to the prompts system will be documented in this file.
The format is based on Keep a Changelog.
[1.0.0] - 2024-11-11
🎉 Initial Release - Prompts Externalization
Major refactoring to extract prompts from Python code to external Markdown files.
Added
Files Structure
-
Created
lightrag/prompts/directory -
Added 10 main prompt files in Markdown format:
entity_extraction_system_prompt.mdentity_extraction_user_prompt.mdentity_continue_extraction_user_prompt.mdsummarize_entity_descriptions.mdfail_response.mdrag_response.mdnaive_rag_response.mdkg_query_context.mdnaive_query_context.mdkeywords_extraction.md
-
Added 6 example files:
entity_extraction_example_1.md- Narrative text exampleentity_extraction_example_2.md- Financial/market data exampleentity_extraction_example_3.md- Sports event examplekeywords_extraction_example_1.md- International trade examplekeywords_extraction_example_2.md- Deforestation examplekeywords_extraction_example_3.md- Education example
Documentation
lightrag/prompts/README.md- Overview and usage guidelightrag/prompts/DOCKER_USAGE.md- Docker-specific usage guidedocs/PromptCustomization.md- Complete customization guide
Docker Support
- Volume mapping in
docker-compose.ymlfor prompts directory - Development override config:
docker-compose.prompts-dev.yml - Updated
Dockerfilewith prompts directory support
Code Changes
- Added
_load_prompt_from_file()function inlightrag/prompt.py - Added
_load_examples_from_files()function inlightrag/prompt.py - Implemented dynamic prompt loading mechanism
- Reduced
prompt.pyfrom 422 lines to 88 lines (-79%)
Changed
Format
- Changed prompt format from Python strings to Markdown (
.md) - UTF-8 encoding for all prompt files
- Consistent formatting across all prompts
Loading Mechanism
- Prompts now loaded dynamically from files at import time
- Examples loaded automatically with naming convention
- Error handling for missing prompt files
Technical Details
Backward Compatibility
- ✅ PROMPTS dictionary structure unchanged
- ✅ All dictionary keys remain identical
- ✅ API unchanged - existing code works without modification
- ✅ Placeholder variables preserved
File Naming Convention
- Main prompts:
{name}.md - Examples:
{base_name}_{number}.md - All lowercase with underscores
Placeholders Preserved
All original placeholders maintained:
{entity_types},{tuple_delimiter},{completion_delimiter}{language},{input_text},{examples}{response_type},{user_prompt},{context_data}{description_type},{description_name},{description_list}{summary_length},{query}
Performance
- No performance degradation
- File I/O only at module import time
- Caching via Python module system
- Minimal memory overhead
Testing
- ✅ All 14 PROMPTS dictionary keys validated
- ✅ UTF-8 encoding verified
- ✅ Placeholder integrity confirmed
- ✅ Docker volume mounting tested
- ✅ No linter errors
- ✅ 100% backward compatibility verified
Migration Guide
For End Users
No action required. Update will be transparent.
For Developers
git pull
# Prompts automatically load from new location
For Docker Users
git pull
docker-compose pull # or rebuild
docker-compose up -d
# Optional: Enable live editing
# Add to docker-compose.yml:
# - ./lightrag/prompts:/app/lightrag/prompts
For Custom Deployments
Ensure lightrag/prompts/ directory exists with all .md files.
Benefits
Maintainability
- ✅ 79% reduction in
prompt.pyline count - ✅ Clear separation of code and content
- ✅ Easier to review changes in git
User Experience
- ✅ Edit prompts without Python knowledge
- ✅ Use any text editor
- ✅ Markdown preview support
- ✅ Syntax highlighting
DevOps
- ✅ Docker volume mounting for live editing
- ✅ No image rebuild needed for prompt changes
- ✅ Different prompts per environment
- ✅ Easy A/B testing
Known Issues
None at this time.
Security
- No security implications
- Files read with UTF-8 encoding
- No user input in file paths
- Standard file I/O operations
Dependencies
No new dependencies added.
Breaking Changes
None. This release is 100% backward compatible.
Future Versions
Planned for [1.1.0]
Features Under Consideration
- Hot reload without application restart
- API endpoint to reload prompts
- File watcher for auto-reload
- Prompt validation tool
- Prompt versioning system
Enhancements
- Multi-language prompt variants
- Prompt A/B testing framework
- Performance metrics integration
- Quality monitoring dashboard
Version History
| Version | Date | Description |
|---|---|---|
| 1.0.0 | 2024-11-11 | Initial release - Prompts externalization |
Contributing
When modifying prompts:
- Preserve placeholders - Don't remove
{variable_name} - Test thoroughly - Validate changes before committing
- Document changes - Update this CHANGELOG
- Backup first - Use git branches or backup files
- Version control - Commit with clear messages
Prompt Modification Checklist
- Placeholders intact
- UTF-8 encoding
- No syntax errors
- Tested with sample data
- Documentation updated
- CHANGELOG updated
- Git committed
Support
For questions or issues:
- Check README.md for basic usage
- Check DOCKER_USAGE.md for Docker specifics
- Check docs/PromptCustomization.md for advanced guide
- Open issue on GitHub
- Contact development team
Maintained by: LightRAG Team
Last Updated: November 11, 2024