A production-ready Data Analyst AI Agent that uses LangGraph, FastAPI, and Streamlit to analyze data and generate visualizations.
- LangGraph Workflow: Structured agent workflow (Query Analysis -> Code Generation -> Execution -> Reasoning).
- FastAPI Backend: REST API for handling data sessions and agent interactions.
- Streamlit Frontend: Interactive web interface for uploading data and chatting with the agent.
- Code Execution: safely executes pandas/matplotlib code.
- NVIDIA AI Endpoints: Uses Llama-3.1-Nemotron for high-quality reasoning and code generation.
data_analyst_ai_agent/
├── backend/ # FastAPI application
│ ├── app/
│ │ ├── api/ # API endpoints
│ │ ├── core/ # Configuration
│ │ ├── graph/ # LangGraph nodes and workflow
│ │ └── services/ # LLM and Session services
│ └── main.py # Entry point
├── frontend/ # Streamlit application
│ └── app.py
├── .env.example # Environment variables example
└── requirements.txt # Project dependencies
- Clone the repository.
- Install dependencies:
pip install -r requirements.txt
- Environment Variables:
Copy
.env.exampleto.envand add your NVIDIA API Key.cp .env.example .env # Edit .env and set NVIDIA_API_KEY
You need to run both the backend and frontend.
Run this in one terminal:
python -m backend.app.mainOr using uvicorn directly (from root):
uvicorn backend.app.main:app --reloadThe API will be available at http://localhost:8000.
Run this in a second terminal:
streamlit run frontend/app.pyThe frontend will open in your browser (usually http://localhost:8501).
- Upload a CSV file in the Streamlit sidebar.
- Ask questions about the data (e.g., "Analyze the trends", "Plot sales over time").
- The agent generates code, executes it, and explains the results.