-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
74 lines (61 loc) · 2.54 KB
/
Copy pathapp.py
File metadata and controls
74 lines (61 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import streamlit as st
from utils.budget_utils import estimate_budget
from utils.cohere_logic import generate_travel_description
from utils.image_utils import get_unsplash_image
from dotenv import load_dotenv
import os
# Load environment variables
load_dotenv()
# Configure Streamlit page
st.set_page_config(page_title="AI Summer Travel Guide ☀️", layout="centered")
# Add blurred background image
st.markdown("""
<style>
.stApp {
background-image: url("https://images.pexels.com/photos/1103970/pexels-photo-1103970.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940");
background-size: cover;
background-repeat: no-repeat;
background-attachment: fixed;
}
.stApp::before {
content: "";
position: fixed;
top: 0;
left: 0;
height: 100%;
width: 100%;
z-index: -1;
background: rgba(255, 255, 255, 0.5); /* translucent white */
backdrop-filter: blur(10px); /* soft blur */
}
</style>
""", unsafe_allow_html=True)
# App Title
st.title("🌴 WanderGenie – AI-Powered Summer Travel Guide ✈️")
# Input Form
with st.form("travel_form"):
destination = st.text_input("Enter a Destination (e.g., Bali, Paris, Ladakh)", "")
theme = st.selectbox("Choose a Travel Theme", ["beach", "camping", "city", "desert", "forest", "historical", "island", "lake", "mountains", "snow"])
days = st.slider("Duration of Stay (in days)", 1, 30, 5)
travel_style = st.radio("Select Travel Style", ["budget", "standard", "luxury"])
submitted = st.form_submit_button("Generate My Guide")
# Handle form submission
if submitted and destination:
with st.spinner("Generating your perfect summer trip..."):
# Generate AI guide
guide = generate_travel_description(destination, theme)
# Fetch Unsplash image
image_url = get_unsplash_image(destination)
# Estimate budget
budget = estimate_budget(theme, days, travel_style)
# Display output
st.subheader(f"🌍 Your Summer Travel Guide to {destination}")
if image_url:
st.image(image_url, caption=f"{destination}", use_container_width=True)
else:
st.warning("Image could not be fetched.")
st.markdown(guide)
st.success(f"💰 Estimated Budget for {days} days ({travel_style.title()}): **${budget}**")
st.caption("Includes transport (round-trip), accommodation, food, and activity costs.")
elif submitted:
st.warning("Please enter a destination to continue.")