# app/ai/utils/draft_html_generator.py # Generate beautiful HTML UI for listing drafts def generate_draft_html(draft: dict) -> str: """ Generate a beautiful HTML UI for the listing draft. This HTML is returned to frontend and displayed directly. Args: draft: Dictionary with listing data Returns: Complete HTML string for the draft preview """ # Extract data title = draft.get("title", "Untitled") description = draft.get("description", "No description") location = draft.get("location", "N/A") bedrooms = draft.get("bedrooms", "?") bathrooms = draft.get("bathrooms", "?") price = draft.get("price", "?") currency = draft.get("currency", "N/A") price_type = draft.get("price_type", "N/A") amenities = draft.get("amenities", []) requirements = draft.get("requirements", "") images = draft.get("images", []) # Format amenities with icons amenity_icons = { "wifi": "๐ถ", "parking": "๐ ฟ๏ธ", "furnished": "๐๏ธ", "washing machine": "๐งผ", "dryer": "๐", "balcony": "๐", "pool": "๐", "gym": "๐ช", "garden": "๐ฟ", "air conditioning": "โ๏ธ", "kitchen": "๐ณ", "ac": "โ๏ธ", "washer": "๐งผ", } amenities_html = "" if amenities: amenities_html = '
{requirements}
{description}
{location}
{bedrooms}
{bathrooms}
{draft.get('listing_type', 'N/A').title()}