An AI-powered chatbot that lets you explore the Titanic dataset through natural language. Ask questions in plain English and get text answers, statistics, and auto-generated visualizations.
- Natural language queries — ask anything about the Titanic dataset
- Auto-generated charts — request histograms, bar charts, scatter plots, etc.
- Conversational UI — chat interface with full message history
- Real-time analysis — powered by a LangChain ReAct agent that writes and executes Python code on the fly
- Redis caching — repeated questions return instantly from cache (1-hour TTL, graceful fallback if Redis unavailable)
┌─────────────────────┐ ┌──────────────────────────────┐
│ Streamlit (8501) │ POST │ FastAPI (8000) │
│ │ ──────► │ │
│ • Chat UI │ /chat │ • Redis cache check │
│ • Message history │ ◄────── │ • LangChain ReAct Agent │
│ • Image rendering │ JSON │ • Plot generation → static/ │
│ │ │ • OpenRouter LLM │
└─────────────────────┘ └──────────────────────────────┘
git clone <repo-url>
cd tailortalk
python -m venv venv
venv\Scripts\activate # Windows
# source venv/bin/activate # macOS/Linux
pip install -r requirements.txtCopy the example env file and add your API key:
cp .example.env .envEdit .env and set your OpenRouter API key:
OPENAI_API_KEY=sk-or-v1-your-key-hereuvicorn backend.main:app --reloadThe API will be available at http://localhost:8000.
In a separate terminal:
streamlit run frontend/app.pyThe UI will open at http://localhost:8501.
| Query | Expected Output |
|---|---|
| "What percentage of passengers were male?" | Text answer with percentage |
| "Show me a histogram of passenger ages" | Age distribution chart |
| "What was the average ticket fare?" | Text answer with fare value |
| "How many passengers embarked from each port?" | Count breakdown or bar chart |
| "What was the survival rate by gender?" | Comparison statistics or chart |
tailortalk/
├── backend/
│ ├── agent.py # LangChain agent setup & LLM config
│ └── main.py # FastAPI app & /chat endpoint
├── frontend/
│ └── app.py # Streamlit chat interface
├── titanic/
│ └── train.csv # Titanic dataset
├── static/ # Auto-generated plot images
├── .streamlit/
│ └── config.toml # Streamlit theme config
├── .env # API keys (not committed)
├── .example.env # Example env template
├── requirements.txt # Python dependencies
└── README.md
- Backend: FastAPI + Uvicorn
- AI Agent: LangChain ReAct Agent with
PythonAstREPLTool - LLM:
openai/gpt-oss-120bvia OpenRouter - Caching: Redis with graceful fallback
- Visualization: Matplotlib + Seaborn
- Frontend: Streamlit with custom CSS theming
- User types a question in the Streamlit chat interface
- Streamlit sends a
POSTrequest to the FastAPI/chatendpoint - FastAPI checks Redis for a cached response — if found, returns it instantly
- On cache miss, the LangChain ReAct agent interprets the question, writes Python/Pandas code, and executes it
- If a visualization is requested, the agent saves the plot to
static/with a unique filename - Text-only responses are cached in Redis (1-hour TTL); plot responses are not cached
- FastAPI parses the agent's response, extracts any image paths, and returns a clean JSON response
- Streamlit renders the text answer and any generated charts in the chat
MIT