This is an interesting multi-modal retrieval and tool orchestration problem. Here's how I'd approach building this system:
Core Architecture
Context Orchestrator - A central component that takes the user request and coordinates between different retrieval mechanisms and tool selection systems.
Multi-Modal Retrieval Pipeline - Combine several retrieval strategies:
- Vector similarity search (RAG with ChromaDB) for semantic matching
- Graph traversal (Neo4j) for relationship-based context discovery
- Classical ML classifiers for intent classification and tool prediction
Detailed Approach
Intent Classification Layer: Use embeddings from Ollama as features for classical ML models (SVM, Random Forest, or XGBoost) to classify request types. Train on categories like "debugging", "testing", "refactoring", "documentation", etc. This gives you structured intent understanding beyond just semantic similarity.
Hierarchical Context Retrieval:
- First, use the classifier to determine the domain/intent
- Then use ChromaDB to find semantically similar past contexts or documentation
- Use Neo4j to traverse relationships - if it's a testing request, follow edges from test files to source files, to dependencies, to related configuration files
Tool Graph in Neo4j: Model your available tools as nodes with relationships indicating prerequisites, compatibility, and typical usage patterns. For your unit test example: discover_project -> read_files -> execute_tests -> parse_results -> suggest_fixes.
Dynamic Context Assembly: Based on the retrieval results, dynamically assemble the context package. Use a scoring system that combines semantic similarity scores, graph centrality measures, and classifier confidence to rank context relevance.
Feedback Loop: Track which context+tool combinations led to successful task completion to continuously improve the retrieval and ranking algorithms.
The key insight is treating this as a multi-objective optimization problem where you're simultaneously optimizing for semantic relevance, structural relationships, and task-specific tool requirements. The classical ML layer adds interpretability and can capture patterns that pure embedding similarity might miss.
Would you like me to elaborate on any specific component of this architecture?