Commit
·
5ea33bf
1
Parent(s):
c8a3780
skeleton without the meat
Browse files
app.py
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
from datetime import datetime
|
4 |
+
import numpy as np
|
5 |
+
import plotly.express as px
|
6 |
+
import datetime as dt
|
7 |
+
|
8 |
+
#page configs
|
9 |
+
st.set_page_config(layout="centered", page_icon="🧭", page_title="GPT-3 Travel Agent")
|
10 |
+
st.markdown("<h1 style='text-align: center; color: grey;'>GPTravel Agent ✈️</h1>", unsafe_allow_html=True)
|
11 |
+
hide_menu_style = """
|
12 |
+
<style>
|
13 |
+
#MainMenu {visibility: hidden;}
|
14 |
+
</style>
|
15 |
+
"""
|
16 |
+
st.markdown(hide_menu_style, unsafe_allow_html=True)
|
17 |
+
|
18 |
+
# sidebar
|
19 |
+
with st.sidebar:
|
20 |
+
locations=st.text_input(label='Places to Be (Comma Seperated', value="london, paris, munich", max_chars=25)
|
21 |
+
activities = st.multiselect(
|
22 |
+
'Things to Do',
|
23 |
+
['food', 'drinking', 'hiking', 'sightseeing', 'museums'],
|
24 |
+
['drinking', 'museums'])
|
25 |
+
vibe = st.selectbox(
|
26 |
+
'Vibe ',
|
27 |
+
['touristy', 'lowkey', 'active', 'lazy'])
|
28 |
+
days = st.slider(label='Trip Length',min_value=1, max_value=5, value=3,)
|
29 |
+
yo = ','.join(activities)
|
30 |
+
st.write(days, f' days\n {locations}, doing {yo}, {vibe} vibes')
|
31 |
+
generate_button = st.button('Take me there')
|
32 |
+
|
33 |
+
#generate chart and plan
|
34 |
+
if generate_button:
|
35 |
+
if len(activities) <= 2 and len(locations.split(','))<=3:
|
36 |
+
st.success('Scroll down to see your full itinerary!', icon="🧭")
|
37 |
+
|
38 |
+
#openai request
|
39 |
+
activity_list =','.join(activities)
|
40 |
+
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:')
|
41 |
+
|
42 |
+
#post process response, strip all lat/lons in order to plot,
|
43 |
+
|
44 |
+
#CHART GENERATION
|
45 |
+
df = pd.DataFrame(np.random.randn(1000, 2) / [50, 50] + [37.76, -122.4],columns=['lat', 'lon'])
|
46 |
+
st.map(df)
|
47 |
+
|
48 |
+
# TEXT TRIP
|
49 |
+
st.subheader("Day by Day Itinerary")
|
50 |
+
trip_view = st.container()
|
51 |
+
for i in range(days):
|
52 |
+
trip_view.write(f'**Day {i+1}** \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')
|
53 |
+
st.text(" \n")
|
54 |
+
else:
|
55 |
+
st.error('Make sure you only enter no more than 2 activities and 3 locations!', icon="🌍")
|
56 |
+
else:
|
57 |
+
st.info('Enter your trip idea so I can do some planning!', icon="🧭")
|
58 |
+
df = pd.DataFrame(np.random.randn(1000, 2) / [50, 50] + [37.76, -122.4],columns=['lat', 'lon'])
|
59 |
+
st.map(df)
|
60 |
+
|
61 |
+
|
62 |
+
# days, locations, activities, transportation, lowkey/touristy,
|
63 |
+
#add map along with trip plan either split by the items or all on one of the sides
|
64 |
+
# eventually store trips in a db and show top trips
|
65 |
+
#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:
|