A FastAPI-based service that accepts a natural-language prompt describing a statistical analysis to perform on a configured CSV dataset, executes the analysis, and writes a structured result into a SQLite database table.
- Natural language prompt to analysis mapping (basic patterns + safe eval of expressions)
- Pandas-based statistics and plotting (summaries, correlations, regressions)
- Results persisted to SQLite
resultstable - Simple REST API
- Create a virtual environment and install dependencies:
uv venv && source .venv/bin/activate || python -m venv .venv && source .venv/bin/activate pip install -r requirements.txt
- Place your dataset CSV at
data/dataset.csv(or setDATASET_PATH). - Run the server:
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
-
POST /analyze:- Body:
{ "prompt": "compute mean of sepal_length grouped by species" } - Response:
{ "result_id": 1 }
- Body:
-
GET /results/{id}: fetch a single result row -
GET /results: list recent results
DATASET_PATH: path to CSV (defaultdata/dataset.csv)DATABASE_URL: SQLite URL (defaultsqlite:///data/results.db)
- The NL-to-analysis layer uses simple pattern/rule-based parsing with guarded evaluation. For complex use, extend
app/agent.py.