mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-11-22 13:29:19 +08:00
feat/https-compose-caddy
3
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
6d23895dc0 |
refactor(memory): drop the unused extraction prompts and tool schemas (#4100)
## Description `headroom/memory/extraction.py` (546 lines) has one product consumer. `memory/wrapper_tools.py` imports `EXTRACTION_SYSTEM_PROMPT` and injects it when `with_memory_tools(..., optimized=True)` is used. Everything else in the module is used only by its own tests. This PR keeps that prompt and removes the rest: - three Mem0-derived extraction prompts; - a conversation-prompt generator; - an answer prompt; - an "enhanced" `memory_save` tool schema, a stale duplicate of `MEMORY_TOOLS_OPTIMIZED` in `memory/tools.py`; - `get_extraction_tools`. Evidence: - `grep -rnE` for each removed name across `headroom crates plugins sdk docs wiki scripts benchmarks examples e2e .github pyproject.toml` and the consumer repos finds only the definitions. - In `tests`, the only hits are `tests/test_memory/test_extraction.py` and one test in `tests/test_memory_integration.py`. - `headroom.memory.extraction` is not in `headroom.memory.__all__` and not in the docs. Refs #4136 ## Type of Change - [ ] Bug fix (non-breaking change that fixes an issue) - [ ] New feature (non-breaking change that adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update - [ ] Performance improvement - [x] Code refactoring (no functional changes) ## Changes Made - `headroom/memory/extraction.py`: keep `EXTRACTION_SYSTEM_PROMPT`, unchanged byte for byte. Remove these: - `FACT_EXTRACTION_PROMPT`, `ENTITY_EXTRACTION_PROMPT` and `RELATIONSHIP_EXTRACTION_PROMPT`; - `get_conversation_extraction_prompt` and `CONVERSATION_EXTRACTION_PROMPT_BASIC`; - `get_memory_answer_prompt`, `MEMORY_SAVE_TOOL_WITH_EXTRACTION` and `get_extraction_tools`. The module docstring now describes what is left. - `tests/test_memory/test_extraction.py`: keep `TestExtractionSystemPrompt`. Remove the tests of the deleted names. - `tests/test_memory_integration.py`: `test_extraction_prompts_exist_and_valid` now checks only the remaining prompt. ## Testing - [x] Unit tests pass (`pytest`) - [x] Linting passes (`ruff check .`) - [ ] Type checking passes (`mypy headroom`) - [ ] New tests added for new functionality - [x] Manual testing performed ### Test Output ```text $ pytest -q -p no:cacheprovider tests/test_memory/test_extraction.py tests/test_memory_integration.py tests/test_memory_system.py ================ 111 passed, 10 skipped, 512 warnings in 15.86s ================ $ uvx ruff@0.16.8 check headroom/memory/extraction.py tests/test_memory/test_extraction.py tests/test_memory_integration.py All checks passed! $ grep -rnE '<each removed name>' headroom tests (no output) ``` ## Real Behavior Proof - Environment: macOS, Python 3.12.13, repo .venv, branch checkout at |
||
|
|
7cf10675ea |
Add centralized ML model configuration
- Create headroom/models/config.py as single source of truth for all ML model defaults - Support environment variable overrides (HEADROOM_SENTENCE_TRANSFORMER, etc.) - Update all components to use ML_MODEL_DEFAULTS instead of hardcoded values - Switch LLMLingua default to smaller bert-base model (~350MB vs 1GB) - Total memory footprint reduced from ~1.6GB to ~980MB Updated files: - MLModelRegistry now resolves defaults from config - EmbeddingScorer, LocalEmbedder, TrainedRouter use config - All dataclass configs use field(default_factory=...) for consistency - Tests updated to handle auto-selected vector backends |
||
|
|
da74341858 |
Add hierarchical memory system with graph + vector storage
Implement comprehensive memory system supporting: - Local backend (SQLite + FTS5 + HNSW) for zero-dependency operation - Mem0 backends (Neo4j + Qdrant) for production graph memory - DirectMem0Adapter for optimized pre-extracted data (bypasses LLM) - Memory extraction with facts, entities, and relationships - Proxy integration with --memory flag for automatic memory injection Key components: - headroom/memory/backends/: LocalBackend, Mem0Backend, DirectMem0Adapter - headroom/memory/system.py: MemorySystem with tool-based interface - headroom/memory/extraction.py: Entity and relationship extraction - headroom/proxy/memory_handler.py: Proxy integration layer - headroom/prediction/feature_extractor.py: Content analysis features Testing: - 217 new memory system tests covering all backends - LoCoMo evaluation framework for memory quality assessment - Integration tests for proxy memory functionality Also removes deprecated example files in favor of focused test coverage. |