Skip to content

MHDataExpert/divar-car-agent

Repository files navigation

Divar Car Search Agent

This project is an intelligent chatbot that helps users find car listings on Divar.ir, a popular classifieds website in Iran. The agent uses AI to understand natural language queries, scrapes the website for relevant data, and presents it in a user-friendly way. The frontend is built with Streamlit.

Features

  • Natural Language Understanding: Ask for cars in plain Persian (e.g., "پراید در شیراز بین 300 تا 500 میلیون").
  • Web Scraping: Extracts real-time car listing data from Divar.ir.
  • Detailed Information: Can retrieve detailed information about a specific car, including price, mileage, color, and seller's description.
  • Interactive Chat: A simple and intuitive chat interface powered by Streamlit.
  • AI-Powered: Uses a Large Language Model (via OpenRouter) to process queries and generate responses.

How It Works

  1. User Input: The user enters a query in the Streamlit chat interface.
  2. AI Agent: The query is sent to a LangChain-based agent.
  3. Tool Selection: The agent decides which tool to use:
    • DivarCarSearch: To search for a list of cars based on model, city, and price.
    • DivarCarSearchDetail: To get more details about a specific car from its URL.
  4. Scraping: The selected tool scrapes Divar.ir using httpx and BeautifulSoup.
  5. Response Generation: The scraped data is sent back to the agent, which then generates a natural language response for the user.
  6. Display: The response is displayed in the chat interface.

Installation

  1. Clone the repository:

    git clone <your-repository-url>
    cd final_divar
  2. Create a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows, use `venv\Scripts\activate`
  3. Install the required packages:

    pip install -r requirements.txt
  4. Set up your environment variables: Create a file named .env in the root of the project and add your OpenRouter API key:

    OPENROUTER_API_KEY="your-openrouter-api-key"
    

How to Run

Once you have completed the installation steps, run the following command in your terminal:

streamlit run main.py

This will start the Streamlit application, and you can open it in your web browser at the provided URL (usually http://localhost:8501).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages