"""Hotel Search App — Gradio Interface A free-form, natural-language hotel search application. Deployed on Hugging Face Spaces. """ import os from pathlib import Path import gradio as gr from dotenv import load_dotenv # Load .env from the same directory as this script so it works # both locally and on Hugging Face Spaces. _env_path = Path(__file__).resolve().parent / ".env" load_dotenv(dotenv_path=_env_path, override=True) from search import hotel_search TITLE = "🏨 Hotel Search — Find Your Perfect Stay" DESCRIPTION = """\ **Describe your ideal hotel in plain English** and this app will find matching hotels \ with direct links to their websites — no travel agency middlemen. Mention your **location**, **dates**, **budget**, and any **amenities** you need. \ You can mark features as *required* ("must have a pool") or *preferred* \ ("ideally has a spa") and the app will rank results accordingly. """ EXAMPLES = [ [ "I'm looking for a beachfront hotel in Miami, Florida for March 15-18, 2026. " "I need free parking and it must be under $200 per night. " "A pool and spa would be nice but aren't required." ], [ "Find me a pet-friendly hotel in downtown Austin, Texas for next weekend. " "Must have free breakfast. Ideally has a rooftop bar and is walkable to " "live music venues. Budget around $150/night." ], [ "I need a luxury hotel in Manhattan, New York for 2 guests, April 5-8, 2026. " "Must have a fitness center and concierge service. " "Would prefer a room with a city view and a hotel restaurant." ], [ "Budget-friendly hotel near Disneyland in Anaheim, California for a family " "of 4. Must be under $120/night and have free Wi-Fi. " "Would be nice to have a shuttle to the park and a pool for the kids." ], [ "Romantic boutique hotel in Savannah, Georgia for a weekend getaway. " "Must be in the historic district. Prefer a hotel with a garden, " "complimentary wine hour, and within walking distance of restaurants." ], ] def search_wrapper(user_input: str) -> str: """Thin wrapper so Gradio can call the search pipeline.""" return hotel_search(user_input) with gr.Blocks( title="Hotel Search", theme=gr.themes.Soft( primary_hue="blue", secondary_hue="sky", font=gr.themes.GoogleFont("Inter"), ), ) as demo: gr.Markdown(f"# {TITLE}") gr.Markdown(DESCRIPTION) with gr.Row(): with gr.Column(scale=3): user_input = gr.Textbox( label="Describe Your Ideal Hotel", placeholder=( "e.g. I need a beachfront hotel in Miami for March 15-18 " "under $200/night with free parking. A pool would be nice..." ), lines=5, ) search_btn = gr.Button("🔍 Search Hotels", variant="primary", size="lg") with gr.Column(scale=1): gr.Markdown( "### Tips for Best Results\n" "- **Be specific** about location\n" "- **Include dates** if you have them\n" "- **Set a budget** (e.g. under $150/night)\n" "- **Say 'must have'** for requirements\n" "- **Say 'would be nice'** for preferences\n" "- Avoid requiring features rarely listed " "(e.g. Wi-Fi is universal but rarely advertised)" ) results_output = gr.Markdown(label="Search Results") search_btn.click(fn=search_wrapper, inputs=user_input, outputs=results_output) user_input.submit(fn=search_wrapper, inputs=user_input, outputs=results_output) gr.Examples( examples=EXAMPLES, inputs=user_input, label="Example Searches — Click to Try", ) gr.Markdown( "---\n" "*This app uses AI to interpret your request and searches the web for " "matching hotels. All links point to hotel websites directly — never to " "travel agencies like Expedia or Booking.com.*" ) if __name__ == "__main__": demo.launch()