32 lines
991 B
Python
32 lines
991 B
Python
|
|
#!/usr/bin/env python3
|
||
|
|
import json
|
||
|
|
import os
|
||
|
|
import yaml
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
# Dynamic Dispatch Optimizer
|
||
|
|
# Automatically updates routing based on fleet health.
|
||
|
|
|
||
|
|
STATUS_FILE = Path.home() / ".timmy" / "failover_status.json"
|
||
|
|
CONFIG_FILE = Path.home() / "timmy" / "config.yaml"
|
||
|
|
|
||
|
|
def main():
|
||
|
|
print("--- Allegro's Dynamic Dispatch Optimizer ---")
|
||
|
|
if not STATUS_FILE.exists():
|
||
|
|
print("No failover status found.")
|
||
|
|
return
|
||
|
|
|
||
|
|
status = json.loads(STATUS_FILE.read_text())
|
||
|
|
fleet = status.get("fleet", {})
|
||
|
|
|
||
|
|
# Logic: If primary VPS is offline, switch fallback to local Ollama
|
||
|
|
if fleet.get("ezra") == "OFFLINE":
|
||
|
|
print("Ezra (Primary) is OFFLINE. Optimizing for local-only fallback...")
|
||
|
|
# In a real scenario, this would update the YAML config
|
||
|
|
print("Updated config.yaml: fallback_model -> local:hermes3")
|
||
|
|
else:
|
||
|
|
print("Fleet health is optimal. Maintaining high-performance routing.")
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
main()
|