Spaces:
Sleeping
Sleeping
File size: 1,975 Bytes
b336134 | 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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | """
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"} |