Spaces:
Sleeping
Sleeping
| # handler.py | |
| from app.orchestrator import PennyOrchestrator | |
| from typing import Dict, Any | |
| import json | |
| class EndpointHandler: | |
| def __init__(self, path=""): | |
| """Initialize PENNY orchestrator when endpoint starts""" | |
| print("🤖 Initializing PENNY...") | |
| self.orchestrator = PennyOrchestrator() | |
| print("✅ PENNY ready!") | |
| def __call__(self, data: Dict[str, Any]) -> Dict[str, Any]: | |
| """ | |
| Handle inference requests from Hugging Face | |
| """ | |
| # Extract inputs | |
| inputs = data.get("inputs", "") | |
| tenant_id = data.get("tenant_id", "default") | |
| user_id = data.get("user_id", "anonymous") | |
| session_id = data.get("session_id", None) | |
| # Process through orchestrator | |
| response = self.orchestrator.process( | |
| message=inputs, | |
| tenant_id=tenant_id, | |
| user_id=user_id, | |
| session_id=session_id | |
| ) | |
| return response |