Files
Alexander Whitestone 5649aeb975
Some checks failed
CI / validate (pull_request) Has been cancelled
feat: Implement AdaptiveCalibrator for local cost estimation (Refs #770)
Add nexus/adaptive_calibrator.py with the AdaptiveCalibrator class that
provides online learning (EMA) for LLM inference cost prediction.

Key features:
- Per-model ModelCalibration state tracking ms/token and base overhead
- EMA updates from observed (prompt_tokens, completion_tokens, actual_ms)
- Confidence metric grows with sample count (1 - exp(-n/10))
- Seeded priors distinguish local Ollama models from Groq cloud models
- Atomic JSON persistence to ~/.nexus/calibrator_state.json
- reset() per-model or global; autosave on every record()
- 23 unit tests covering convergence, persistence, edge cases

Exported from nexus/__init__.py as AdaptiveCalibrator and CostPrediction.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 21:39:28 -04:00
..