Thank you for your interest in contributing to the vLLM Semantic Router project! This guide will help you get started with development and contributing to the project.
- Development Setup
- Prerequisites
- Building the Project
- Running Tests
- Development Workflow
- Code Style and Standards
- Submitting Changes
- Project Structure
Before you begin, ensure you have the following installed:
- Rust (latest stable version)
- Go 1.24.1 or later
- Hugging Face CLI (
pip install huggingface_hub) - Make (for build automation)
- Python 3.8+ (Optiona: for training and testing)
-
Clone the repository:
git clone <repository-url> cd semantic-router
-
Download required models:
make download-models
This downloads the pre-trained classification models from Hugging Face.
-
Install Python dependencies(Optional):
# For training and development pip install -r requirements.txt # For end-to-end testing pip install -r e2e-tests/requirements.txt
The project consists of multiple components that need to be built in order:
make build-
Rust library (Candle binding):
make rust
-
Go router:
make build-router
-
Start Envoy proxy (in one terminal):
make run-envoy
-
Start the semantic router (in another terminal):
make run-router
-
Test Rust bindings:
make test-binding
-
Test Go semantic router:
make test-semantic-router
-
Test individual classifiers:
make test-category-classifier make test-pii-classifier make test-jailbreak-classifier
Test different routing scenarios:
# Test model auto-selection
make test-prompt
# Test PII detection
make test-pii
# Test prompt guard (jailbreak detection)
make test-prompt-guard
# Test tools auto-selection
make test-toolsEnsure both Envoy and the router are running, then:
# Run all e2e tests
python e2e-tests/run_all_tests.py
# Run specific test
python e2e-tests/00-client-request-test.py
# Run tests matching a pattern
python e2e-tests/run_all_tests.py --pattern "0*-*.py"
# Check if services are running
python e2e-tests/run_all_tests.py --check-onlyThe test suite includes:
- Basic client request tests
- Envoy ExtProc interaction tests
- Router classification tests
- Semantic cache tests
- Category-specific tests
- Metrics validation tests
-
Create a feature branch:
git checkout -b feature/your-feature-name
-
Make your changes following the project structure and coding standards.
-
Build and test:
make clean make build make test -
Run end-to-end tests:
# Start services make run-envoy & make run-router & # Run tests python e2e-tests/run_all_tests.py
-
Commit your changes:
git add . git commit -m "feat: add your feature description"
- Envoy logs: Check the terminal running
make run-envoyfor detailed request/response logs - Router logs: Check the terminal running
make run-routerfor classification and routing decisions - Rust library: Use
RUST_LOG=debugenvironment variable for detailed Rust logs
- Follow standard Go formatting (
gofmt) - Use meaningful variable and function names
- Add comments for exported functions and types
- Write unit tests for new functionality
- Follow Rust formatting (
cargo fmt) - Use
cargo clippyfor linting - Handle errors appropriately with
Resulttypes - Document public APIs
- Follow PEP 8 style guidelines
- Use type hints where appropriate
- Write docstrings for functions and classes
-
Ensure all tests pass:
make test python e2e-tests/run_all_tests.py -
Create a pull request with:
- Clear description of changes
- Reference to any related issues
- Test results and validation steps
-
Address review feedback promptly
├── candle-binding/ # Rust library for BERT classification
├── src/semantic-router/ # Go implementation of the router
├── src/training/ # Model training scripts
├── e2e-tests/ # End-to-end test suite
├── config/ # Configuration files
├── docs/ # Documentation
├── deploy/ # Deployment configurations
├── Makefile # Build automation
└── requirements.txt # Python dependencies
- Candle Binding: Rust library providing BERT-based classification
- Semantic Router: Go service implementing the Envoy ExtProc interface
- Training Scripts: Python scripts for fine-tuning classification models
- Configuration: YAML files defining routing rules and model endpoints
- Check the documentation
- Review existing issues and pull requests
- Ask questions in discussions or create a new issue
By contributing to this project, you agree that your contributions will be licensed under the same license as the project (Apache 2.0).