Spaces:
Paused
Paused
File size: 1,003 Bytes
6347098 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | # 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 |