Update app.py
Browse files
app.py
CHANGED
@@ -6,11 +6,6 @@ from dotenv import load_dotenv
|
|
6 |
from datetime import datetime
|
7 |
import zipfile
|
8 |
|
9 |
-
# Langchain Imports
|
10 |
-
from langchain.memory import ConversationBufferMemory
|
11 |
-
from langchain.chains import ConversationChain
|
12 |
-
from langchain_community.llms import HuggingFaceHub
|
13 |
-
|
14 |
|
15 |
# π Extract .streamlit folder if zipped
|
16 |
if not os.path.exists(".streamlit"):
|
@@ -68,25 +63,24 @@ generate_button = st.button("βοΈ Generate Trip Plan")
|
|
68 |
if generate_button:
|
69 |
if from_location and destination and budget and preferences and start_date and end_date:
|
70 |
user_prompt = (
|
71 |
-
f"Create a detailed
|
72 |
f"The trip should start on {start_date.strftime('%B %d, %Y')} and end on {end_date.strftime('%B %d, %Y')}, "
|
73 |
-
f"with a total budget of βΉ{budget} INR. The
|
74 |
f"Provide a **day-wise breakdown** of the trip including:\n"
|
75 |
f"- Top tourist attractions\n"
|
76 |
f"- Recommended local food\n"
|
77 |
-
f"- Suggested
|
78 |
-
f"
|
79 |
-
f"Make sure the total plan is budget-friendly and culturally immersive. End with final tips."
|
80 |
)
|
81 |
|
82 |
-
with st.spinner("π§ Generating trip
|
83 |
ai_response = st.session_state.conversation.run(user_prompt)
|
84 |
|
85 |
-
st.subheader("π Your AI-Generated Trip
|
86 |
st.write(ai_response)
|
87 |
|
88 |
save_trip_plan_as_pdf(ai_response)
|
89 |
-
with open("
|
90 |
st.download_button("π Download as PDF", f, file_name="trip_plan.pdf")
|
91 |
|
92 |
else:
|
@@ -99,6 +93,6 @@ follow_up = st.text_input("Ask a follow-up about your trip plan")
|
|
99 |
|
100 |
if follow_up:
|
101 |
with st.spinner("π‘ Thinking..."):
|
102 |
-
response = st.session_state.conversation.run(follow_up)
|
103 |
-
st.
|
104 |
|
|
|
6 |
from datetime import datetime
|
7 |
import zipfile
|
8 |
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
# π Extract .streamlit folder if zipped
|
11 |
if not os.path.exists(".streamlit"):
|
|
|
63 |
if generate_button:
|
64 |
if from_location and destination and budget and preferences and start_date and end_date:
|
65 |
user_prompt = (
|
66 |
+
f"Create a detailed,day-wise travel itinerary for a trip from {from_location} to {destination}."
|
67 |
f"The trip should start on {start_date.strftime('%B %d, %Y')} and end on {end_date.strftime('%B %d, %Y')}, "
|
68 |
+
f"with a total budget of βΉ{budget} INR. The traveller prefers a trip with the theme:{preferences.lower()}.\n"
|
69 |
f"Provide a **day-wise breakdown** of the trip including:\n"
|
70 |
f"- Top tourist attractions\n"
|
71 |
f"- Recommended local food\n"
|
72 |
+
f"- Suggested places to visit(such as markets,museums,temples etc.)\n"
|
73 |
+
f"End with final tips for the trip."
|
|
|
74 |
)
|
75 |
|
76 |
+
with st.spinner("π§ Generating trip itinerary..."):
|
77 |
ai_response = st.session_state.conversation.run(user_prompt)
|
78 |
|
79 |
+
st.subheader("π Your AI-Generated Trip Itinerary")
|
80 |
st.write(ai_response)
|
81 |
|
82 |
save_trip_plan_as_pdf(ai_response)
|
83 |
+
with open("trip_itinerary.pdf", "rb") as f:
|
84 |
st.download_button("π Download as PDF", f, file_name="trip_plan.pdf")
|
85 |
|
86 |
else:
|
|
|
93 |
|
94 |
if follow_up:
|
95 |
with st.spinner("π‘ Thinking..."):
|
96 |
+
response = st.session_state.conversation.run(user_prompt+"Also,"+follow_up)
|
97 |
+
st.write("Sure,here is your updated travel itinerary: \n"+response)
|
98 |
|