# Product Recommendation Chatbot - Chainlit + MAF
This is an AI-powered chatbot for outdoor equipment recommendations, built with:
- **Chainlit** - Interactive chat interface
- **Microsoft Agent Framework** - Agent orchestration
- **MCP (Model Context Protocol)** - Product search tools
- **Azure OpenAI** - Language model
## Features
- π Natural language product search
- π·οΈ Filter by category, brand, and price
- π¬ Interactive chat interface
- π€ AI-powered recommendations
- π Real-time product data via MCP
## Prerequisites
1. MCP Server running at `http://localhost:8000/mcp`
2. Azure OpenAI credentials configured in `.env`
## Installation
```bash
# Install dependencies
pip install -r requirements.txt
```
## Configuration
Make sure your `.env` file contains:
```env
# Azure OpenAI Configuration
AZURE_OPENAI_ENDPOINT=your_endpoint
AZURE_OPENAI_API_KEY=your_key
AZURE_OPENAI_API_VERSION=2024-08-01-preview
AZURE_OPENAI_DEPLOYMENT_NAME=gpt-4o-mini
# MCP Server URL
MCP_SERVER_URL=http://localhost:8000/mcp
```
## Running the App
### Start the MCP Server (in one terminal)
```bash
python mcp_server.py
```
### Start the Chainlit App (in another terminal)
```bash
chainlit run chainlit_app.py -w
```
The app will open automatically at `http://localhost:8000` (or another port if 8000 is taken).
## Usage Examples
Try asking the chatbot:
- "Show me waterproof tents under $300"
- "What hiking boots do you have?"
- "I need a lightweight backpack for day trips"
- "What categories are available?"
- "Find me products from the HikeMate brand"
- "Show me premium camping gear over $200"
## Architecture
```
User β Chainlit UI β MAF Agent β MCP Server β ChromaDB
β
Azure OpenAI
```
1. User sends a message via Chainlit interface
2. Microsoft Agent Framework receives the query
3. Agent uses Azure OpenAI to understand intent
4. Agent calls appropriate MCP tools (search, filter, etc.)
5. MCP server queries ChromaDB vector database
6. Results are formatted and returned to user
## Customization
### Modify Agent Behavior
Edit the `instructions` parameter in `chainlit_app.py`:
```python
agent = ChatAgent(
chat_client=chat_client,
name="ProductRecommendationAgent",
instructions="Your custom instructions here...",
)
```
### Customize UI
Edit `.chainlit/config.toml` to change:
- App name and description
- Theme colors
- UI behavior
- Features enabled/disabled
## Troubleshooting
**"Agent not initialized"**
- Ensure MCP server is running
- Check Azure OpenAI credentials in `.env`
**"Connection refused"**
- Verify MCP server is running on the correct port
- Check MCP_SERVER_URL in `.env`
**"No module named 'chainlit'"**
- Run `pip install chainlit`
## Development
To run in development mode with auto-reload:
```bash
chainlit run chainlit_app.py -w --debug
```
## License
Same as parent project