AI system that converts unstructured car listing text and images into standardized JSON data for automotive platforms, with automated email delivery to designated recipients.
Converts unstructured car listings (text + image) → structured JSON → email delivery to designated recipients.
- 🧠 AI-Powered Extraction - GPT-4 with hardened prompts (injection-resistant)
- 🔒 Strict Validation - Pydantic models with year ranges (1975-2025)
- 📧 Email Delivery - Sends processed listings to designated recipients
- 🛡️ Robust Implementation - Token limits, error handling, logging
git clone https://github.com/Youssef-Ashraf-Dev/Car_Listing.git
cd car-listing-processor
pip install -r requirements.txt
cp .env.example .env # Add your Azure OpenAI + Gmail credentials
streamlit run app.pyTech Stack: Python • Streamlit • LangChain • Azure OpenAI • Pydantic
Input Text:
Blue Ford Fusion produced in 2015 featuring a 2.0-liter engine. The vehicle has low mileage with
only 40,000 miles on the odometer. Equipped with brand-new all-season tires manufactured in 2022.
The car's windows are tinted for added privacy. Notably, the rear bumper has been replaced after
a minor collision. Priced at 1 million L.E.
Input Image:
Output JSON:
{
"car": {
"body_type": "sedan",
"color": "Blue",
"brand": "Ford",
"model": "Fusion",
"manufactured_year": 2015,
"motor_size_cc": 2000,
"tires": {
"type": "brand-new",
"manufactured_year": 2022
},
"windows": "tinted",
"notices": [
{
"type": "collision",
"description": "The rear bumper has been replaced after a minor collision."
}
],
"price": {
"amount": 1000000,
"currency": "L.E"
}
}
}Key Files:
app.py- Streamlit UI & orchestrationllm_parser.py- Hardened prompts + Pydantic modelsutils.py- Email delivery + image analysis.env.example- Configuration template
Prompt Injection Protection:
- Strict system instructions that forbid responding to user commands
- Schema-locked output (JSON only, no markdown/comments)
- Temperature 0 for deterministic results
Data Validation:
- Year constraints (1975-2025 for cars, 2000-2025 for tires)
- Required field validation with clear error messages
- Optional field omission (no hallucinated data)
Error Handling:
- Specific catches for API, parsing, and SMTP failures
- Comprehensive logging for debugging
- Development fallback: saves to local
outbox/directory when email credentials are missing (testing convenience)
# Test individual components
python llm_parser.py # LLM parsing test
python utils.py # Email delivery test (needs test_car.jpg)
# Run full workflow via UI
streamlit run app.py- Token Efficiency: Optimized prompts reduce costs
- Input Limits: 800 char descriptions, 5MB images
- Capped Responses: 300 tokens max (sufficient for complete JSON)


