| 
1 |  | -.PHONY: all build clean test docker-build podman-build docker-run podman-run  | 
 | 1 | +.PHONY: all build clean test docker-build podman-build docker-run podman-run start-milvus stop-milvus restart-milvus milvus-status clean-milvus test-milvus-cache test-semantic-router-milvus help  | 
2 | 2 | 
 
  | 
3 | 3 | # Default target  | 
4 | 4 | all: build  | 
5 | 5 | 
 
  | 
 | 6 | +# Help target  | 
 | 7 | +help:  | 
 | 8 | +	@echo "Available targets:"  | 
 | 9 | +	@echo "  Build targets:"  | 
 | 10 | +	@echo "    all                     - Build everything (default)"  | 
 | 11 | +	@echo "    build                   - Build Rust library and Go router"  | 
 | 12 | +	@echo "    rust                    - Build only the Rust library"  | 
 | 13 | +	@echo "    build-router            - Build only the Go router"  | 
 | 14 | +	@echo "    clean                   - Clean build artifacts"  | 
 | 15 | +	@echo ""  | 
 | 16 | +	@echo "  Run targets:"  | 
 | 17 | +	@echo "    run-router              - Run the router (CONFIG_FILE=config/config.yaml)"  | 
 | 18 | +	@echo "    run-envoy               - Run Envoy proxy"  | 
 | 19 | +	@echo ""  | 
 | 20 | +	@echo "  Test targets:"  | 
 | 21 | +	@echo "    test                    - Run all tests"  | 
 | 22 | +	@echo "    test-binding            - Test candle-binding"  | 
 | 23 | +	@echo "    test-semantic-router    - Test semantic router"  | 
 | 24 | +	@echo "    test-category-classifier - Test category classifier"  | 
 | 25 | +	@echo "    test-pii-classifier     - Test PII classifier"  | 
 | 26 | +	@echo "    test-jailbreak-classifier - Test jailbreak classifier"  | 
 | 27 | +	@echo ""  | 
 | 28 | +	@echo "  Milvus targets (CONTAINER_RUNTIME=docker|podman):"  | 
 | 29 | +	@echo "    start-milvus            - Start Milvus container for testing"  | 
 | 30 | +	@echo "    stop-milvus             - Stop and remove Milvus container"  | 
 | 31 | +	@echo "    restart-milvus          - Restart Milvus container"  | 
 | 32 | +	@echo "    milvus-status           - Check Milvus container status"  | 
 | 33 | +	@echo "    clean-milvus            - Stop container and clean data"  | 
 | 34 | +	@echo "    test-milvus-cache       - Test cache with Milvus backend"  | 
 | 35 | +	@echo "    test-semantic-router-milvus - Test router with Milvus cache"  | 
 | 36 | +	@echo "    Example: CONTAINER_RUNTIME=podman make start-milvus"  | 
 | 37 | +	@echo ""  | 
 | 38 | +	@echo "  Demo targets:"  | 
 | 39 | +	@echo "    test-auto-prompt-reasoning - Test reasoning mode"  | 
 | 40 | +	@echo "    test-auto-prompt-no-reasoning - Test normal mode"  | 
 | 41 | +	@echo "    test-pii                - Test PII detection"  | 
 | 42 | +	@echo "    test-prompt-guard       - Test jailbreak detection"  | 
 | 43 | +	@echo "    test-tools              - Test tool auto-selection"  | 
 | 44 | +	@echo ""  | 
 | 45 | +	@echo "  Documentation targets:"  | 
 | 46 | +	@echo "    docs-dev                - Start documentation dev server"  | 
 | 47 | +	@echo "    docs-build              - Build documentation"  | 
 | 48 | +	@echo "    docs-serve              - Serve built documentation"  | 
 | 49 | +	@echo "    docs-clean              - Clean documentation artifacts"  | 
 | 50 | +	@echo ""  | 
 | 51 | +	@echo "  Environment variables:"  | 
 | 52 | +	@echo "    CONTAINER_RUNTIME       - Container runtime (docker|podman, default: docker)"  | 
 | 53 | +	@echo "    CONFIG_FILE             - Config file path (default: config/config.yaml)"  | 
 | 54 | +	@echo "    VLLM_ENDPOINT           - vLLM endpoint URL for testing"  | 
 | 55 | +	@echo ""  | 
 | 56 | +	@echo "  Usage examples:"  | 
 | 57 | +	@echo "    make start-milvus                    # Use Docker (default)"  | 
 | 58 | +	@echo "    CONTAINER_RUNTIME=podman make start-milvus  # Use Podman"  | 
 | 59 | +	@echo "    CONFIG_FILE=custom.yaml make run-router     # Use custom config"  | 
 | 60 | + | 
 | 61 | +# Container runtime (docker or podman)  | 
 | 62 | +CONTAINER_RUNTIME ?= docker  | 
 | 63 | + | 
6 | 64 | # vLLM env var  | 
7 | 65 | VLLM_ENDPOINT ?=  | 
8 | 66 | 
 
  | 
 | 
30 | 88 | build-router: rust  | 
31 | 89 | 	@echo "Building router..."  | 
32 | 90 | 	@mkdir -p bin  | 
33 |  | -	@cd src/semantic-router && go build -o ../../bin/router cmd/main.go  | 
 | 91 | +	@cd src/semantic-router && go build --tags=milvus -o ../../bin/router cmd/main.go  | 
34 | 92 | 
 
  | 
35 | 93 | # Config file path with default  | 
36 | 94 | CONFIG_FILE ?= config/config.yaml  | 
@@ -177,6 +235,65 @@ download-models:  | 
177 | 235 | 		hf download LLM-Semantic-Router/pii_classifier_modernbert-base_presidio_token_model --local-dir models/pii_classifier_modernbert-base_presidio_token_model; \  | 
178 | 236 | 	fi  | 
179 | 237 | 
 
  | 
 | 238 | +# Milvus container management  | 
 | 239 | +start-milvus:  | 
 | 240 | +	@echo "Starting Milvus container for testing with $(CONTAINER_RUNTIME)..."  | 
 | 241 | +	@mkdir -p /tmp/milvus-data  | 
 | 242 | +	@$(CONTAINER_RUNTIME) run -d \  | 
 | 243 | +		--name milvus-semantic-cache \  | 
 | 244 | +		--security-opt seccomp:unconfined \  | 
 | 245 | +		-e ETCD_USE_EMBED=true \  | 
 | 246 | +		-e ETCD_DATA_DIR=/var/lib/milvus/etcd \  | 
 | 247 | +		-e ETCD_CONFIG_PATH=/milvus/configs/advanced/etcd.yaml \  | 
 | 248 | +		-e COMMON_STORAGETYPE=local \  | 
 | 249 | +		-e CLUSTER_ENABLED=false \  | 
 | 250 | +		-p 19530:19530 \  | 
 | 251 | +		-p 9091:9091 \  | 
 | 252 | +		-v /tmp/milvus-data:/var/lib/milvus \  | 
 | 253 | +		milvusdb/milvus:v2.3.3 \  | 
 | 254 | +		milvus run standalone  | 
 | 255 | +	@echo "Waiting for Milvus to be ready..."  | 
 | 256 | +	@sleep 15  | 
 | 257 | +	@echo "Milvus should be available at localhost:19530"  | 
 | 258 | + | 
 | 259 | +stop-milvus:  | 
 | 260 | +	@echo "Stopping Milvus container..."  | 
 | 261 | +	@$(CONTAINER_RUNTIME) stop milvus-semantic-cache || true  | 
 | 262 | +	@$(CONTAINER_RUNTIME) rm milvus-semantic-cache || true  | 
 | 263 | +	@sudo rm -rf /tmp/milvus-data || true  | 
 | 264 | +	@echo "Milvus container stopped and removed"  | 
 | 265 | + | 
 | 266 | +restart-milvus: stop-milvus start-milvus  | 
 | 267 | + | 
 | 268 | +milvus-status:  | 
 | 269 | +	@echo "Checking Milvus container status..."  | 
 | 270 | +	@if $(CONTAINER_RUNTIME) ps --filter "name=milvus-semantic-cache" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" | grep -q milvus-semantic-cache; then \  | 
 | 271 | +		echo "Milvus container is running:"; \  | 
 | 272 | +		$(CONTAINER_RUNTIME) ps --filter "name=milvus-semantic-cache" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"; \  | 
 | 273 | +	else \  | 
 | 274 | +		echo "Milvus container is not running"; \  | 
 | 275 | +		echo "Run 'make start-milvus' to start it"; \  | 
 | 276 | +	fi  | 
 | 277 | + | 
 | 278 | +clean-milvus: stop-milvus  | 
 | 279 | +	@echo "Cleaning up Milvus data..."  | 
 | 280 | +	@sudo rm -rf milvus-data || rm -rf milvus-data  | 
 | 281 | +	@echo "Milvus data directory cleaned"  | 
 | 282 | + | 
 | 283 | +# Test semantic cache with Milvus backend  | 
 | 284 | +test-milvus-cache: start-milvus rust  | 
 | 285 | +	@echo "Testing semantic cache with Milvus backend..."  | 
 | 286 | +	@export LD_LIBRARY_PATH=$${PWD}/candle-binding/target/release && \  | 
 | 287 | +		cd src/semantic-router && CGO_ENABLED=1 go test -tags=milvus -v ./pkg/cache/  | 
 | 288 | +	@echo "Consider running 'make stop-milvus' when done testing"  | 
 | 289 | + | 
 | 290 | +# Test semantic-router with Milvus enabled  | 
 | 291 | +test-semantic-router-milvus: build-router start-milvus  | 
 | 292 | +	@echo "Testing semantic-router with Milvus cache backend..."  | 
 | 293 | +	@export LD_LIBRARY_PATH=$${PWD}/candle-binding/target/release && \  | 
 | 294 | +		cd src/semantic-router && CGO_ENABLED=1 go test -tags=milvus -v ./...  | 
 | 295 | +	@echo "Consider running 'make stop-milvus' when done testing"  | 
 | 296 | + | 
180 | 297 | # Documentation targets  | 
181 | 298 | docs-install:  | 
182 | 299 | 	@echo "Installing documentation dependencies..."  | 
 | 
0 commit comments