Dockerfile / main.py
kkthakur's picture
Deploy Local Hybrid Engine
b336134
Raw
History Blame Contribute Delete
1.98 kB
"""
Zero-LLM Multi-Agent Excel/CSV Editing Engine
==============================================
Production-ready FastAPI server. No LLM call anywhere.
Usage:
uvicorn main:app --host 0.0.0.0 --port 8000 --reload
Endpoints:
POST /api/upload Upload CSV/Excel/Parquet
GET /api/download/{session_id} Download as CSV
GET /api/session/{session_id} Session metadata
DELETE /api/session/{session_id} Delete session
GET /api/history/{session_id} Command history
WS /ws/{session_id} Real-time command channel
"""
from __future__ import annotations
from contextlib import asynccontextmanager
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from api.routes import router as rest_router
from api.websocket import websocket_handler
from services.audit_service import close as close_audit
@asynccontextmanager
async def lifespan(app: FastAPI):
"""Startup / shutdown hooks."""
yield
await close_audit()
app = FastAPI(
title="Zero-LLM Data Engine",
description="Natural-language Excel/CSV editing β€” no LLM, pure Python + Polars",
version="1.0.0",
lifespan=lifespan,
)
# CORS β€” allow all origins for dev; restrict in production
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Mount REST routes under /api
app.include_router(rest_router, prefix="/api")
# WebSocket endpoint
from fastapi import WebSocket
@app.websocket("/ws/{session_id}")
async def ws_endpoint(ws: WebSocket, session_id: str):
await websocket_handler(ws, session_id)
# ── Health check ────────────────────────────────────────────────────
@app.get("/", tags=["health"])
async def root():
return {"status": "running", "engine": "zero-llm", "version": "1.0.0"}