Skip to main content

An agentic data analyst that writes and runs its own pandas/matplotlib code to answer questions about your data.

Project description

📊 AutoAnalyst

An agent that writes and runs its own data analysis.
Ask a question in plain English → AutoAnalyst writes Python, runs it against your data, reads the result, draws charts, and explains the answer — one step at a time.


What is this?

AutoAnalyst is a local, open-source take on ChatGPT's Advanced Data Analysis. The difference from a normal "ask the LLM" tool is the agent loop: instead of guessing an answer in one shot, the model is given a single tool — run_python — and a live Python session with your DataFrame already loaded. It writes code, runs it, sees the real output, and decides what to do next, repeating until it can answer.

Because every number it reports comes from code that actually executed against your data, the answers are grounded — not hallucinated.

The agent loop

flowchart LR
    Q["question + data schema"] --> M{{"Groq · llama-3.3-70b"}}
    M -- "run_python(code)" --> S["🐍 sandbox<br/>df · pd · np · plt"]
    S -- "stdout · errors · charts" --> M
    M -- "no tool call" --> A["plain-English answer"]
  • One tool, real execution. The model writes pandas/matplotlib; the sandbox runs it.
  • Persistent session. Variables (and df) survive across steps, like a notebook.
  • Self-correcting. If code raises, the error is fed back and the model fixes it.
  • Charts come back as images; the model only hears "a chart was rendered."

▶ Live demo

Try it on the Hugging Face Space — pick a dataset, ask a question, and watch the agent think in real time (the UI streams each step over Server-Sent Events).

Quickstart

Install

pip install autoanalyst

Set a free Groq key (put it in a .env file or your env):

GROQ_API_KEY=gsk_...

Use the CLI

autoanalyst -q "What was the survival rate by passenger class?" --csv titanic.csv

You'll see each step it runs — the code, the output, chart markers — then the answer.

Run the web demo locally

pip install "autoanalyst[serve]"
uvicorn app.server:app --port 8000
# open http://localhost:8000

Locally you can upload your own CSV/Excel; the public Space ships curated samples only.

How it works

Piece File What it does
Sandbox autoanalyst/sandbox.py Persistent exec namespace; captures stdout + matplotlib figures (as PNGs); AST-based denylist + per-step timeout.
Agent autoanalyst/agent.py The Groq tool-calling loop → an ordered trace of steps + a final answer. Also exposes run_iter for streaming.
Data I/O autoanalyst/dataio.py Loads CSV/Excel and builds the compact schema summary the model sees.
Prompts autoanalyst/prompts.py System prompt + the run_python tool schema (single source of truth).
Server app/server.py FastAPI: health, datasets, upload, /api/analyze and the SSE /api/analyze/stream.
UI app/static/ Custom dark "analyst lab" frontend — live trace, syntax-highlighted code, inline charts.

Sample datasets

Four bundled, recognizable datasets (built by scripts/make_samples.py): Titanic (survival), restaurant tips, Palmer penguins, and a generated e-commerce sales table — each with a few verified example questions.

Safety

LLM-written code is executed, so the sandbox applies a pragmatic guard: an AST denylist (no os/subprocess/socket/file or network access), a per-snippet timeout, and capped output. It is not a bulletproof jail — what actually contains the risk is that the public demo runs only curated datasets inside a non-root container, and file upload is disabled there. Run untrusted analyses locally at your own discretion.

Limitations

  • Built on an open 70B model via Groq — tool-calling is good but occasionally needs a retry on a malformed call (handled with a step cap and a forced final answer).
  • It answers from the data you give it; it won't fetch external context.
  • Groq geo-restricts some regions; the hosted Space runs where Groq is reachable.

Tech

QLoRA-free and GPU-free by design: Groq API · pandas · numpy · matplotlib · FastAPI · Server-Sent Events. Tested (GPU- and network-free) in CI.

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autoanalyst-0.1.0.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

autoanalyst-0.1.0-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file autoanalyst-0.1.0.tar.gz.

File metadata

  • Download URL: autoanalyst-0.1.0.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for autoanalyst-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c56a8e73df69209b08283054cd508cdfc071f33ffa076f0540fcc382b2de8445
MD5 f2dc5458eae4c18938c1f9be51e9eb9f
BLAKE2b-256 02f57c87c1d3353019d8a803fd5db01474ae30787b013afb6fc0310d722b89c7

See more details on using hashes here.

File details

Details for the file autoanalyst-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: autoanalyst-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for autoanalyst-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bcc263dad6e125833f1102cd0c334af218c704ff8c92be8d15650072057a1e10
MD5 d4d8dc8bc615156356778ea1fc2d8204
BLAKE2b-256 458cd7ffe96d70c5ff9fc53e3e9511a2ad1d46729f75b747c27a8c7c2b0376b8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page