Ignis Router
Intelligent LLM routing library that selects the best model for every query using ML routers and rule-based intent detection.
Features
- ML-based routing — KNN, SVM, Graph, MF routers predict the best LLM (via LLMRouter)
- Rule-based fallback — intent detection with automatic fallback when ML confidence is low
- Provider fallback — auto-switches to available LLM when API key is missing
- Decorators —
@route(),@chat()for easy integration into any app - REST API — FastAPI endpoints for routing and chat
- PostgreSQL logging — automatic persistence of routing decisions
- Retrainable — retrain ML models when new LLMs are introduced
Quick Install
pip install git+https://github.com/Infogain-GenAI/ignis_router.git@sakshi_dev_1
Quick Usage
from ignis_router import chat
@chat(system_prompt="You are a helpful assistant")
def ask(query, response):
print(response["routing_decision"]["ml_router_predicted"])
print(response["routing_decision"]["final_model"])
print(response["content"])
return response
ask("Write a Python sorting function")
Configuration
Create a .env file:
OPENAI_API_KEY=sk-your-key-here
ML_ROUTER_TYPE=svm
ENABLE_ML_MODEL_HINT_ROUTING=true
ML_CONFIDENCE_THRESHOLD=0.50
ROUTER_YAML_CONFIG=configs/cost-first.yaml
Run the API
python -m ignis_router.run_api
# Server at http://127.0.0.1:8080
# Swagger docs at http://127.0.0.1:8080/docs
API Endpoints
| Method | Path | Description |
|---|---|---|
| GET | /health |
Health check |
| GET | /docs |
Swagger UI |
| POST | /route |
Route a query (pick best model) |
| POST | /chat |
Route + call LLM + return AI response |
Architecture
User Query
→ ML Router (KNN/SVM/Graph/MF) predicts best model
→ API key check (fallback if unavailable)
→ Call LLM (OpenAI/Anthropic/Gemini)
→ Return response + routing decision
→ Save to PostgreSQL
Documentation
See user_guide.md for complete documentation including:
- Installation steps
- Configuration reference
- Decorator usage
- ML router training
- Database setup
- Troubleshooting
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ignis_router-0.1.0.tar.gz
(78.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ignis_router-0.1.0.tar.gz.
File metadata
- Download URL: ignis_router-0.1.0.tar.gz
- Upload date:
- Size: 78.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b6dddbba202232bfa046617bcea461cff8db62f6a28c6ed6c92ec63ec76bbce
|
|
| MD5 |
4959ac756058c41f69de87fe80fe346f
|
|
| BLAKE2b-256 |
376a1692f52992219ba7d62652910a7bcb9a1a47564a2c6564290945a2013743
|
File details
Details for the file ignis_router-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ignis_router-0.1.0-py3-none-any.whl
- Upload date:
- Size: 77.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1fe36e89e7b5af38eb27167fe0671ae75a562910d233374a58965601b0f8ac9b
|
|
| MD5 |
16e9e308b61517128aab3a88e28adca6
|
|
| BLAKE2b-256 |
7a36d7c7b50bbd15fa74bd77092301ec5936d0407d743f4ef55e9021366745e3
|