Spaces:
Running
Running
| from fastapi import HTTPException, APIRouter | |
| router = APIRouter() | |
| async def get_stats(): | |
| import psutil | |
| return { | |
| "cpu": psutil.cpu_percent(), | |
| "ram": psutil.virtual_memory().percent, | |
| "disk": psutil.disk_usage('/').percent, | |
| "gpu": 0 | |
| } | |
| async def get_info(): | |
| return {"os": "windows", "version": "1.0.0-OMEGA", "build": "V15_FINAL_PRODUCTION"} | |
| async def health_mongo(): | |
| """Check MongoDB Atlas connectivity.""" | |
| try: | |
| from backend.db.mongodb import MongoDBClient | |
| await MongoDBClient.get_db().command("ping") | |
| return {"status": "online", "service": "MongoDB Atlas"} | |
| except Exception as e: | |
| raise HTTPException(status_code=503, detail=f"MongoDB offline: {e}") | |
| async def health_chroma(): | |
| """Check ChromaDB local vector store connectivity.""" | |
| try: | |
| import chromadb | |
| from chromadb.config import Settings | |
| client = chromadb.PersistentClient(path="chroma_db", settings=Settings(anonymized_telemetry=False)) | |
| collections = client.list_collections() | |
| return {"status": "online", "service": "ChromaDB", "collections": len(collections)} | |
| except Exception as e: | |
| raise HTTPException(status_code=503, detail=f"ChromaDB offline: {e}") | |
| async def health_supervisor(): | |
| """Check AI Self-Heal supervisor status.""" | |
| import os | |
| supervisor_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "backend", "supervisor.py") | |
| exists = os.path.exists(supervisor_path) | |
| return { | |
| "status": "online" if exists else "error", | |
| "service": "AI Self-Heal Supervisor", | |
| "supervisor_present": exists, | |
| "max_restarts_per_minute": 5, | |
| "heal_engine": "Gemini API" | |
| } | |
| from pydantic import BaseModel | |
| class ActivationEventPayload(BaseModel): | |
| persona: str | |
| trigger_source: str | |
| async def handle_activation_event(payload: ActivationEventPayload): | |
| from backend.voice.activation import on_jarvis_friday_activated | |
| import asyncio | |
| asyncio.create_task(on_jarvis_friday_activated(payload.persona, payload.trigger_source)) | |
| return {"status": "ok", "message": "Activation sequence initiated"} | |