1- .PHONY : deploy start stop status help postgres phoenix loki-stack aap-mock replay stop-replay backend ui annotation health logs restart clean stop-postgres stop-phoenix stop-loki-stack stop-aap-mock embedding stop-embedding wait-for-embedding test-embedding test-rag
1+ .PHONY : deploy start stop status help postgres phoenix loki-stack aap-mock replay stop-replay backend ui annotation health logs restart clean stop-postgres stop-phoenix stop-loki-stack stop-aap-mock embedding stop-embedding wait-for-embedding rag stop-rag test-embedding test-rag
22.DEFAULT_GOAL := help
33
44include ../../.env
@@ -36,8 +36,10 @@ help: ## Show this help message
3636 @echo " "
3737 @echo " 📚 RAG Setup:"
3838 @echo " 1. Place PDF files in data/knowledge_base/"
39- @echo " 2. Run 'make run-whole-training-pipeline' to build RAG index"
40- @echo " 3. Ensure RAG_ENABLED=true in .env file"
39+ @echo " 2. Start services: 'make start' (includes RAG service)"
40+ @echo " 3. Run 'make run-whole-training-pipeline' to build RAG embeddings in PostgreSQL"
41+ @echo " 4. RAG service will automatically load embeddings when available"
42+ @echo " 5. Ensure RAG_ENABLED=true and RAG_SERVICE_URL=http://alm-rag:8002 in .env file"
4143 @echo " "
4244
4345
@@ -51,6 +53,7 @@ start: stop ## 🚀 Start all services locally
5153 @$(MAKE ) -s embedding
5254 @echo " ⚠️ Note: Embedding service may take 3-5 minutes to load the model"
5355 @echo " You can check status with: make test-embedding"
56+ @$(MAKE ) -s rag
5457 @$(MAKE ) -s aap-mock
5558 @$(MAKE ) -s backend
5659 @$(MAKE ) -s ui
@@ -79,6 +82,12 @@ embedding: ## 🤖 Start Embedding Service (TEI)
7982 @echo " Starting Embedding Service (TEI)..."
8083 @$(COMPOSE_CMD ) -f compose.yaml up -d alm-embedding
8184
85+ rag : # # 🔍 Start RAG Service
86+ @echo " Starting RAG Service..."
87+ @$(COMPOSE_CMD ) -f compose.yaml up -d alm-rag
88+ @echo " ⚠️ Note: RAG service will poll PostgreSQL for embeddings"
89+ @echo " It will become ready once embeddings are available (after init job runs)"
90+
8291wait-for-embedding : # # ⏳ Wait for embedding service to be ready (optional, for manual use)
8392 @echo " Waiting for embedding service to be ready (this may take 3-5 minutes for model loading)..."
8493 @timeout=300; \
@@ -167,6 +176,7 @@ stop: ## 🛑 Stop all services
167176 @$(MAKE ) -s stop-postgres
168177 @$(MAKE ) -s stop-phoenix
169178 @$(MAKE ) -s stop-embedding
179+ @$(MAKE ) -s stop-rag
170180 @$(MAKE ) -s kill-ports
171181 @echo " 👋 All services stopped"
172182
@@ -190,6 +200,10 @@ stop-embedding: ## 🛑 Stop Embedding Service
190200 @$(COMPOSE_CMD ) -f compose.yaml down alm-embedding || true
191201 @echo " ✓ Embedding service stopped and removed"
192202
203+ stop-rag : # # 🛑 Stop RAG Service
204+ @$(COMPOSE_CMD ) -f compose.yaml down alm-rag || true
205+ @echo " ✓ RAG service stopped and removed"
206+
193207kill-ports : # # 🔌 Kill processes using required ports
194208 @if [ " $$ (uname)" = " Darwin" ]; then \
195209 lsof -ti :7860 | xargs kill -9 2> /dev/null || true ; \
@@ -239,6 +253,12 @@ kill-ports: ## 🔌 Kill processes using required ports
239253 fuser -k 8081/tcp 2> /dev/null || true ; \
240254 fi
241255 @echo " ✓ Loki MCP Server 8081 killed"
256+ @if [ " $$ (uname)" = " Darwin" ]; then \
257+ lsof -ti :8002 | xargs kill -9 2> /dev/null || true ; \
258+ else \
259+ fuser -k 8002/tcp 2> /dev/null || true ; \
260+ fi
261+ @echo " ✓ RAG Service 8002 killed"
242262 @if [ " $$ (uname)" = " Darwin" ]; then \
243263 lsof -ti :3000 | xargs kill -9 2> /dev/null || true ; \
244264 else \
@@ -259,6 +279,7 @@ status: ## 📊 Show status of all services
259279 @echo " 📊 Loki: $( shell $( COMPOSE_CMD) ps 2> /dev/null | grep ' loki' | grep -v ' loki-mcp' | grep -q ' Up' && echo ' Running' || echo ' Stopped' ) - http://localhost:3100"
260280 @echo " 🔍 Loki MCP Server: $( shell $( COMPOSE_CMD) ps 2> /dev/null | grep ' loki-mcp-server' | grep -q ' Up' && echo ' Running' || echo ' Stopped' ) - http://localhost:8081"
261281 @echo " 🤖 Embedding Service: $( shell $( COMPOSE_CMD) ps 2> /dev/null | grep ' alm-embedding' | grep -q ' Up' && echo ' Running' || echo ' Stopped' ) - http://localhost:8080"
282+ @echo " 🔍 RAG Service: $( shell $( COMPOSE_CMD) ps 2> /dev/null | grep ' alm-rag' | grep -q ' Up' && echo ' Running' || echo ' Stopped' ) - http://localhost:8002"
262283 @echo " 📈 Grafana: $( shell $( COMPOSE_CMD) ps 2> /dev/null | grep ' grafana' | grep -q ' Up' && echo ' Running' || echo ' Stopped' ) - http://localhost:3000"
263284 @echo " 📝 Promtail: $( shell $( COMPOSE_CMD) ps 2> /dev/null | grep ' promtail' | grep -q ' Up' && echo ' Running' || echo ' Stopped' ) "
264285 @echo " 🎭 AAP Mock: $( shell $( COMPOSE_CMD) ps 2> /dev/null | grep ' aap-mock' | grep -q ' Up' && echo ' Running' || echo ' Stopped' ) - http://localhost:8082"
@@ -293,14 +314,20 @@ run-whole-training-pipeline: ## 🔍 Run whole training pipeline (builds RAG ind
293314 @ ( cd ../.. && uv run init_pipeline.py )
294315
295316# Add new target to check RAG status
296- rag-status : # # 📊 Check RAG index status
297- @echo " 📊 RAG Index Status:"
298- @if [ -f " ../../data/ansible_errors.index" ] && [ -f " ../../data/error_metadata.pkl" ]; then \
299- echo " ✅ RAG index exists" ; \
300- ls -lh ../../data/ansible_errors.index ../../data/error_metadata.pkl; \
317+ rag-status : # # 📊 Check RAG service and index status
318+ @echo " 📊 RAG Service Status:"
319+ @if curl -s -f http://localhost:8002/health > /dev/null 2>&1 ; then \
320+ echo " ✅ RAG service is running" ; \
321+ if curl -s -f http://localhost:8002/ready > /dev/null 2>&1 ; then \
322+ index_size=$$(curl -s http://localhost:8002/ready | grep -o '"index_size":[0-9]*' | grep -o '[0-9]*' || echo "unknown" ) ; \
323+ echo " ✅ RAG index is loaded ($$ index_size embeddings)" ; \
324+ else \
325+ echo " ⚠️ RAG index not loaded yet (waiting for embeddings)" ; \
326+ echo " Run 'make run-whole-training-pipeline' to build embeddings" ; \
327+ fi ; \
301328 else \
302- echo " ❌ RAG index not found " ; \
303- echo " Run 'make run-whole-training-pipeline' to build it " ; \
329+ echo " ❌ RAG service is not running " ; \
330+ echo " Start it with: make rag " ; \
304331 fi
305332 @if [ -d " ../../data/knowledge_base" ]; then \
306333 pdf_count=$$(ls -1 ../../data/knowledge_base/*.pdf 2>/dev/null | wc -l ) ; \
@@ -335,14 +362,40 @@ test-embedding: ## 🧪 Test embedding service
335362 @echo " "
336363 @echo " ✅ Embedding service test passed!"
337364
338- test-rag : # # 🧪 Test RAG system (requires RAG index)
339- @echo " 🧪 Testing RAG System..."
340- @if [ ! -f " ../../data/ansible_errors.index" ]; then \
341- echo " ❌ RAG index not found. Run 'make run-whole-training-pipeline' first." ; \
365+ test-rag : # # 🧪 Test RAG service (requires RAG service running and embeddings in PostgreSQL)
366+ @echo " 🧪 Testing RAG Service..."
367+ @echo " "
368+ @echo " 1. Health Check:"
369+ @if curl -s -f http://localhost:8002/health > /dev/null 2>&1 ; then \
370+ echo " ✅ Service is healthy" ; \
371+ else \
372+ echo " ❌ Service is not responding" ; \
373+ exit 1; \
374+ fi
375+ @echo " "
376+ @echo " 2. Readiness Check:"
377+ @if curl -s -f http://localhost:8002/ready > /dev/null 2>&1 ; then \
378+ echo " ✅ Service is ready (index loaded)" ; \
379+ else \
380+ echo " ⚠️ Service is not ready (index not loaded yet)" ; \
381+ echo " Run 'make run-whole-training-pipeline' to build embeddings" ; \
382+ exit 1; \
383+ fi
384+ @echo " "
385+ @echo " 3. Test Query:"
386+ @response=$$(curl -s -X POST http://localhost:8002/rag/query \
387+ -H " Content-Type: application/json" \
388+ -d ' {"query": "ansible playbook execution failed", "top_k": 5, "top_n": 3, "similarity_threshold": 0.6}' ); \
389+ if echo " $$ response" | grep -q ' "results"' ; then \
390+ echo " ✅ Query successful" ; \
391+ echo " Response preview: $$ (echo $$ response | head -c 200)..." ; \
392+ else \
393+ echo " ❌ Query failed" ; \
394+ echo " Response: $$ response" ; \
342395 exit 1; \
343396 fi
344- @echo " Running RAG test script... "
345- @ (cd ../.. && uv run python tests/rag/test_embeddings.py)
397+ @echo " "
398+ @echo " ✅ RAG service test passed! "
346399
347400health : # # 🔍 Check health of running services
348401 @echo " 🔍 Health Checks:"
@@ -381,6 +434,16 @@ health: ## 🔍 Check health of running services
381434 else \
382435 echo " 🤖 Embedding Service http://localhost:8080: Unhealthy (may still be loading model)" ; \
383436 fi
437+ @if curl -s http://localhost:8002/health > /dev/null 2>&1 ; then \
438+ echo " 🔍 RAG Service http://localhost:8002: Healthy" ; \
439+ if curl -s http://localhost:8002/ready > /dev/null 2>&1 ; then \
440+ echo " 🔍 RAG Service http://localhost:8002: Ready (index loaded)" ; \
441+ else \
442+ echo " 🔍 RAG Service http://localhost:8002: Not ready (index not loaded yet)" ; \
443+ fi ; \
444+ else \
445+ echo " 🔍 RAG Service http://localhost:8002: Unhealthy" ; \
446+ fi
384447 @if curl -s http://localhost:3000 > /dev/null 2>&1 ; then \
385448 echo " 📈 Grafana http://localhost:3000: Healthy" ; \
386449 else \
0 commit comments