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.
- 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.
- User Input: The user enters a query in the Streamlit chat interface.
- AI Agent: The query is sent to a LangChain-based agent.
- 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.
- Scraping: The selected tool scrapes Divar.ir using
httpx
andBeautifulSoup
. - Response Generation: The scraped data is sent back to the agent, which then generates a natural language response for the user.
- Display: The response is displayed in the chat interface.
-
Clone the repository:
git clone <your-repository-url> cd final_divar
-
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install the required packages:
pip install -r requirements.txt
-
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"
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
).