Debarjita/Smart-Product-Buyer-AI-Agent
An intelligent car buying assistant powered by LangGraph and OpenAI that helps users make informed purchasing decisions through automated web scraping, intelligent filtering, and comprehensive market analysis.
Smart Product Buyer AI Agent ๐
An intelligent car buying assistant powered by LangGraph and OpenAI that helps users make informed purchasing decisions through automated web scraping, intelligent filtering, and comprehensive market analysis.
๐ Features
- Conversational Interface: Natural language interaction to understand user requirements
- Intelligent Filtering: Dynamic filter creation based on user preferences
- Web Scraping: Automated car listing retrieval from AutoTrader
- Market Analysis: Real-time research on car reliability and common issues
- Detailed Insights: Comprehensive summaries and recommendations
- Extensible Design: Easily adaptable to other platforms and product categories
๐๏ธ Architecture
The agent follows a structured workflow using LangGraph's state management:
- User Need Assessment - Gathers requirements and preferences
- Filter Building - Constructs search parameters
- Listing Retrieval - Scrapes relevant car listings
- Analysis & Insights - Provides market research and recommendations
๐ Getting Started
Prerequisites
- Python 3.8+
- OpenAI API key
- Jupyter Notebook or Google Colab
Installation
- Clone the repository:
git clone https://github.com/Debarjita/smart-car-buyer-agent.git
cd smart-car-buyer-agent- Install dependencies:
pip install -r requirements.txt
playwright install
patchright install chromium- Set up environment variables:
cp .env.example .env
# Add your OPENAI_API_KEY to .env fileQuick Start
-
Run in Jupyter Notebook:
- Open
car_buyer_agent.ipynb - Execute all cells
- Follow the Gradio interface link
- Open
-
Run without GUI:
- Set
USE_GRADIO = Falsein the notebook - Execute cells for command-line interaction
- Set
๐ Requirements
langgraph==0.2.28
langchain==0.3.1
langchain-openai==0.2.1
langchain-community==0.3.0
python-dotenv==1.0.0
playwright==1.47.0
patchright==1.16.0
lxml==5.3.0
nest-asyncio==1.6.0
duckduckgo-search==6.2.13
gradio==4.44.0
๐ ๏ธ Configuration
Environment Variables
Create a .env file with:
OPENAI_API_KEY=your_openai_api_key_here
LANGCHAIN_API_KEY=your_langchain_api_key_here # Optional
Usage Settings
USE_GRADIO = True: Web-based interfaceUSE_GRADIO = False: Command-line interface
๐ฏ How It Works
1. User Interaction
The agent starts by asking about your car preferences:
- Budget range
- Intended usage (commuting, family trips)
- Size preferences
- Special features or constraints
2. Smart Filtering
Based on your requirements, it automatically:
- Builds search filters for AutoTrader
- Constructs optimized query URLs
- Applies intelligent parameter mapping
3. Data Collection
- Scrapes car listings using Playwright
- Extracts detailed information (price, mileage, features)
- Handles dynamic content loading
4. Analysis & Recommendations
- Researches car reliability using web search
- Identifies common issues for specific models
- Provides personalized recommendations
๐ง Extending the Agent
Adding New Platforms
- Create a new scraper class inheriting from
WebsiteInterface:
class NewPlatformInterface(WebsiteInterface):
def __init__(self):
self.base_url = "https://newplatform.com"
async def crawl(self):
# Implement scraping logic
pass
def get_filters_info(self):
# Return filter information
pass- Add it to the web interfaces list:
web_interfaces=[AutotraderInterface(), NewPlatformInterface()]๐ฑ Example Output
๐ค Car Buyer Assistant: Hi! I'm here to help you find the perfect car.
What are you looking for in terms of:
- Budget range
- Intended use (daily commuting, family trips, etc.)
- Size preferences
- Any specific features?
๐ค User: I need a reliable SUV under $25,000 for family trips
๐ค Assistant: Building filters based on your needs...
Successfully set filters for: AutotraderInterface
Updated URL: https://www.autotrader.com/cars-for-sale/all-cars/cars-under-25000?makeCode=HONDA&makeCode=TOYOTA&vehicleStyleCode=SUVCROSS
Found 15 listings matching your criteria:
1. 2018 Honda CR-V EX - $22,995 - 45,000 miles
Dealer: Metro Honda
[Additional details and analysis...]
โ ๏ธ Important Notes
- Performance: Best performance on macOS/Linux. Windows users should use WSL
- Rate Limits: Respects website rate limits and robots.txt
- Legal Compliance: Only scrapes publicly available data
- API Usage: Monitor OpenAI API usage for cost management
๐ค Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Troubleshooting
Common Issues
Gradio interface not loading:
- Check if all dependencies are installed
- Ensure ports are not blocked
- Try setting
USE_GRADIO = Falsefor debugging
Scraping errors:
- Verify internet connection
- Check if AutoTrader is accessible
- Update Playwright browsers:
playwright install
API errors:
- Verify OpenAI API key is valid
- Check API quotas and billing
- Ensure environment variables are set correctly
๐ Acknowledgments
- Built with LangGraph for state management
- Uses Playwright for web scraping
- Powered by OpenAI for intelligent processing
- Inspired by the GenAI_Agents tutorial collection
โญ Star this repository if you found it helpful!