travel / app.py
ritwikbiswas's picture
cols to itinerary
ff09048
import streamlit as st
import pandas as pd
import numpy as np
#page configs
st.set_page_config(layout="centered", page_icon="🧭", page_title="GPT-3 Travel Agent")
st.markdown("<h1 style='text-align: center; color: grey;'>GPTravel Agent ✈️</h1>", unsafe_allow_html=True)
hide_menu_style = """
<style>
#MainMenu {visibility: hidden;}
</style>
"""
st.markdown(hide_menu_style, unsafe_allow_html=True)
# sidebar
with st.sidebar:
locations=st.text_input(label='Places to Be (Comma Seperated', value="london, paris, munich", max_chars=25)
activities = st.multiselect(
'Things to Do',
['food', 'drinking', 'hiking', 'sightseeing', 'museums'],
['drinking', 'museums'])
vibe = st.selectbox(
'Vibe ',
['touristy', 'lowkey', 'active', 'lazy'])
days = st.slider(label='Trip Length',min_value=1, max_value=5, value=3,)
yo = ','.join(activities)
st.write(days, f' days\n {locations}, doing {yo}, {vibe} vibes')
generate_button = st.button('Take me there')
#generate chart and plan
if generate_button:
if len(activities) <= 2 and len(locations.split(','))<=3:
#st.success('Scroll down to see your full itinerary!', icon="🧭")
#openai request
activity_list =','.join(activities)
#st.write(f'Plan a trip day by day with the given parameters, give a lat/long per day: 5 days in {locations} doing {activity_list} with a {vibe} vibe:')
#post process response, strip all lat/lons in order to plot,
tab1, tab2 = st.tabs(["Map", "Itinerary"])
with tab1:
#CHART GENERATION
df = pd.DataFrame(np.random.randn(1000, 2) / [50, 50] + [37.76, -122.4],columns=['lat', 'lon'])
st.map(df)
with tab2:
# TEXT TRIP
st.subheader("Day by Day Itinerary")
trip_view = st.container()
col1, col2 = st.columns(2)
with col1:
for i in [1,3,5]:
st.subheader(f'Day {i}')
st.markdown(f' \n- Start the day in London by visiting the British Museum and other historic sites \n- Afterward, explore the city by taking a walking tour of the city \n- Finish the day by enjoying a pint at a local pub')
with col2:
for i in [2,4]:
st.subheader(f'Day {i}')
st.markdown(f' \n- Start the day in London by visiting the British Museum and other historic sites \n- Afterward, explore the city by taking a walking tour of the city \n- Finish the day by enjoying a pint at a local pub')
# for i in range(days):
# st.markdown(f' \n- Start the day in London by visiting the British Museum and other historic sites \n- Afterward, explore the city by taking a walking tour of the city \n- Finish the day by enjoying a pint at a local pub')
# st.text(" \n")
else:
st.error('Make sure you only enter no more than 2 activities and 3 locations!', icon="🌍")
else:
st.info('Enter your trip idea so I can do some planning!', icon="🧭")
df = pd.DataFrame(np.random.randn(1000, 2) / [50, 50] + [37.76, -122.4],columns=['lat', 'lon'])
st.map(df)
# days, locations, activities, transportation, lowkey/touristy,
#add map along with trip plan either split by the items or all on one of the sides
# eventually store trips in a db and show top trips
#plan a trip day by day with the given parameters, give rough lat/long per day: 5 days in london,paris,munich involving drinking,museums the transportation is train,bike: