How mayureshmohnalkar22/llm-cost-autopilot works
LLM Cost Autopilot is a local Ollama gateway that routes prompts across three sub-3B models, checks outputs, and escalates failures. The main workflow is API submission → complexity-based tier selection → inference → deterministic or sampled judge verification → durable result and attempts. A background worker handles pending verification, while persisted escalation history can raise future routing floors. The dashboard reads gateway results and resource metrics; a separate benchmark compares routing against the largest-model baseline. Edges reflect shown calls or README-documented behavior; unsampled benchmark implementation details are not inferred.
Main entry points: main.py FastAPI Gateway · engine.py Request Engine · provider.py Ollama Provider · database.py SQLite Store and Queue
Components 15
Gateway and Routing
- FastAPI Gateway
app/main.py - Runtime Settings
app/config.py - Complexity Classifier
app/routing.py - Request Engine
app/engine.py - Model Definitions
config/models.json
Inference and Quality
- Verification Worker
app/engine.py - Ollama Provider
app/provider.py - Response Checks
app/evaluation.py
Persistence and Metrics
- SQLite Store and Queue
app/database.py - Host Monitoring
app/monitoring.py
User Interfaces
- Streamlit Dashboard
dashboard/app.py
Benchmark and Training
- Paired Benchmark
scripts/benchmark.py - Classifier Training
scripts/train_classifier.py
Other components
- User
- Ollama Service
Connections 19
- User → FastAPI Gateway: submits prompt
README.md - FastAPI Gateway → Runtime Settings: loads settings
app/main.py - FastAPI Gateway → Request Engine: submits request
app/main.py - Runtime Settings → Model Definitions: loads models
app/config.py - Request Engine → Complexity Classifier: predicts tier
app/engine.py - Request Engine → SQLite Store and Queue: reads floor; records request
app/engine.py - Request Engine → Ollama Provider: generates response
app/engine.py - Request Engine → Response Checks: checks response
app/engine.py - FastAPI Gateway → Verification Worker: starts worker
app/main.py - Verification Worker → SQLite Store and Queue: claims pending work
app/engine.py - Verification Worker → Response Checks: checks and judges
app/engine.py - Verification Worker → Ollama Provider: judges or escalates
app/engine.py - Ollama Provider → Ollama Service: calls inference API
README.md - Ollama Provider → Host Monitoring: samples resources
app/provider.py - FastAPI Gateway → SQLite Store and Queue: reads requests and metrics
app/main.py - FastAPI Gateway → Host Monitoring: serves resource snapshot
app/main.py - Streamlit Dashboard → FastAPI Gateway: requests results and metrics
dashboard/app.py - Paired Benchmark → FastAPI Gateway: compares routing policies
README.md - Classifier Training → Complexity Classifier: provides optional model artifact
README.md