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.
- 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
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
- Python 3.8+
- OpenAI API key
- Jupyter Notebook or Google Colab
- 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 file-
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
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
Create a .env file with:
OPENAI_API_KEY=your_openai_api_key_here
LANGCHAIN_API_KEY=your_langchain_api_key_here # Optional
USE_GRADIO = True: Web-based interfaceUSE_GRADIO = False: Command-line interface
The agent starts by asking about your car preferences:
- Budget range
- Intended usage (commuting, family trips)
- Size preferences
- Special features or constraints
Based on your requirements, it automatically:
- Builds search filters for AutoTrader
- Constructs optimized query URLs
- Applies intelligent parameter mapping
- Scrapes car listings using Playwright
- Extracts detailed information (price, mileage, features)
- Handles dynamic content loading
- Researches car reliability using web search
- Identifies common issues for specific models
- Provides personalized recommendations
- 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()]🤖 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...]
- 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
- 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
This project is licensed under the MIT License - see the LICENSE file for details.
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
- 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!