e2b-dev/ai-analyst

Open source AI analyst powered by E2B. Analyze your CSV files with Llama 3.1 and create interactive charts.

AI Analyst by E2B – What It Is

AI Analyst is a web‑app that lets you upload a CSV file, ask natural‑language questions about the data, and get back answers plus interactive charts. Under the hood it runs a large language model (Meta Llama 3.1) inside the E2B Sandbox, a hosted execution environment that can run code safely. The UI is built with Next.js and uses Vercel’s AI SDK to stream LLM responses, while the charting is powered by the echarts library.

Core capabilities

  • Data analysis with LLMs – The app sends the CSV content to a chosen LLM (TogetherAI, Fireworks, or a local Ollama instance) and lets the model generate Python‑style data‑analysis code (pandas, numpy, etc.).
  • File upload – Users can drag‑and‑drop a CSV; the file is stored temporarily in the sandbox for the LLM to read.
  • Interactive visualisations – The generated code can produce any chart type supported by E2B’s interactive‑charts API (see the linked docs). The front‑end renders them with echarts, so you can hover, zoom, and toggle series.
  • Provider flexibility – You can use cloud LLM providers (TogetherAI, Fireworks) or a self‑hosted Ollama server. API keys are supplied via environment variables; the app falls back to the server‑side key when none is provided.

How it works (high‑level flow)

  1. Upload a CSV → the file is saved in the sandbox.
  2. Ask a question in the chat UI.
  3. The front‑end forwards the prompt and a reference to the CSV to the server.
  4. The server selects a model (as defined in lib/models.json) and calls the provider’s API.
  5. The LLM returns code that reads the CSV, performs the requested analysis, and calls E2B’s chart‑creation helper.
  6. The sandbox executes the code, returns the result (text + chart data) to the client, and the UI displays it.

Running it yourself

  1. Clone the repo and cd fragments && npm i.
  2. Copy .example.env to .env.local and add your E2B_API_KEY plus the key for the LLM you want to use (e.g., TOGETHER_API_KEY).
  3. npm run dev (standard Next.js dev script) will start the app locally.
  4. Open http://localhost:3000, upload a CSV, and start chatting.

What you’ll need

  • An E2B account (for the sandbox execution environment).
  • API credentials for at least one LLM provider (TogetherAI, Fireworks, Anthropic, OpenAI, or a local Ollama server).
  • Node.js ≥ 18 (the typical Next.js requirement).

Why it matters

AI Analyst demonstrates a practical use‑case of LLM‑driven code interpretation: the model writes real Python code that runs in an isolated sandbox, turning a plain text query into data‑driven insights and visualisations without the user writing any code. It showcases how the E2B SDK can be combined with Vercel’s AI tooling to deliver a full‑stack, server‑less AI product.


TL;DR – AI Analyst is a Next.js web app that lets you ask an LLM to analyse CSV data and produce interactive charts, using the E2B sandbox to safely run the generated code. It supports multiple LLM providers and can be self‑hosted with a few environment variables.

Related

  • Project
  • Project
  • Project
  • Project