chore: initial project setup with AI usage dashboard for Codex and Devin
Add FastAPI-based monitoring dashboard with support for Codex CLI and Devin API v3 Enterprise consumption tracking. Includes Docker deployment, systemd service configuration, kiosk mode launcher, comprehensive documentation, and demo mode for testing without credentials.
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
from app.config import Settings
|
||||
from app.models import ProviderUsage, UsageLimit
|
||||
from app.providers.base import UsageProvider, utc_now
|
||||
|
||||
|
||||
class DemoProvider(UsageProvider):
|
||||
def __init__(self, provider: str, settings: Settings):
|
||||
super().__init__(provider, settings.provider_cache_ttl, 'Demo data')
|
||||
self.settings = settings
|
||||
|
||||
async def _fetch_usage(self) -> ProviderUsage:
|
||||
now = utc_now().astimezone(ZoneInfo(self.settings.timezone))
|
||||
if self.provider == 'codex':
|
||||
limits = [
|
||||
UsageLimit(id='demo-5-hour', name='5 Hour Limit', used_percent=27, remaining_percent=73,
|
||||
reset_at=now + timedelta(hours=2, minutes=15), window='5 hour', updated_at=now),
|
||||
UsageLimit(id='demo-weekly', name='Weekly Limit', used_percent=54, remaining_percent=46,
|
||||
reset_at=now + timedelta(days=4), window='weekly', updated_at=now),
|
||||
]
|
||||
else:
|
||||
limit, used = 320.0, 124.0
|
||||
next_month = (now.replace(day=28) + timedelta(days=4)).replace(day=1, hour=0, minute=0, second=0, microsecond=0)
|
||||
limits = [UsageLimit(id='demo-cycle', name='Cycle ACU Usage', used=used, limit=limit,
|
||||
remaining=limit - used, used_percent=used / limit * 100,
|
||||
remaining_percent=(limit - used) / limit * 100, unit='ACUs',
|
||||
reset_at=next_month, window='billing cycle', updated_at=now)]
|
||||
return ProviderUsage(provider=self.provider, status='ok', limits=limits,
|
||||
last_successful_update=now, source=self.source)
|
||||
Reference in New Issue
Block a user