Spaces:
Sleeping
Sleeping
fix: Add missing app.py and agent.py for Docker build
Browse files
agent.py
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
ALTYZEN Agent - Wrapper for Order Agent Worker
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
from order_agent_worker import validate_order
|
| 6 |
+
|
| 7 |
+
__all__ = ["validate_order"]
|
app.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
ALTYZEN HuggingFace Worker - FastAPI Entry Point
|
| 3 |
+
"""
|
| 4 |
+
|
| 5 |
+
import os
|
| 6 |
+
import logging
|
| 7 |
+
from fastapi import FastAPI, Request
|
| 8 |
+
from fastapi.responses import JSONResponse
|
| 9 |
+
import uvicorn
|
| 10 |
+
|
| 11 |
+
from agent import validate_order
|
| 12 |
+
|
| 13 |
+
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 14 |
+
logger = logging.getLogger(__name__)
|
| 15 |
+
|
| 16 |
+
app = FastAPI(title="ALTYZEN Order Validator", version="2.0")
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
@app.get("/health")
|
| 20 |
+
async def health():
|
| 21 |
+
return {"status": "healthy", "version": "2.0", "architecture": "Info-Driven"}
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
@app.get("/")
|
| 25 |
+
async def root():
|
| 26 |
+
return {"message": "ALTYZEN Order Validator v2.0", "endpoints": ["/health", "/run-task"]}
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
@app.post("/run-task")
|
| 30 |
+
async def run_task(request: Request):
|
| 31 |
+
try:
|
| 32 |
+
data = await request.json()
|
| 33 |
+
logger.info(f"📥 Received task: {data.get('task_id', 'unknown')}")
|
| 34 |
+
|
| 35 |
+
result = await validate_order(data)
|
| 36 |
+
|
| 37 |
+
logger.info(f"📤 Task complete: {result.get('decision', 'UNKNOWN')}")
|
| 38 |
+
return JSONResponse(content=result)
|
| 39 |
+
except Exception as e:
|
| 40 |
+
logger.error(f"❌ Task error: {e}")
|
| 41 |
+
return JSONResponse(content={"decision": "ERROR", "error": str(e)}, status_code=500)
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
if __name__ == "__main__":
|
| 45 |
+
port = int(os.getenv("PORT", 7860))
|
| 46 |
+
logger.info(f"🚀 Starting ALTYZEN Worker on port {port}")
|
| 47 |
+
uvicorn.run(app, host="0.0.0.0", port=port)
|